ePaper Display
This article aims to provide a detailed guide on how to use Luckfox Pico Plus to drive a 2.13-inch ePaper screen (differentiated from Pico by the right-side pin numbering). We are using Waveshare's Pico-ePaper-2.13 ePaper display, and you can find specific details about the screen in the Pico-ePaper-2.13 product wiki. You can download the image file and sample program to use directly or follow the steps below to configure it yourself.
1. Compatible Device Configuration
The Luckfox Pico / Plus / Pro / Max series mainly refers to the pin layout of the Raspberry Pi Pico, and through pin configuration, it can be compatible with some Raspberry Pi Pico peripherals.

For the list of compatible devices supported by different models of Luckfox Pico, refer to Luckfox-Pico_support-List.
The compatible device option is essentially a combination of multiple pin configurations, which can simplify the configuration process.
Due to the lack of io commands to directly configure registers under Ubuntu, the Luckfox Pico cannot configure the pins as default pull-up when configuring the compatible device Pico-LCD, so it cannot properly control the buttons.
When starting the compatible device configuration, it will overwrite the original configuration. To cancel the compatible device, go to the Advanced Options screen to disable the started device function.
2. Example Program
The Pico-ResTouch-LCD-3.5 resistive touch screen expansion board features the XPT2046 resistive touch control chip and a Micro SD card slot, allowing for display, touch, and SD card reading functionalities. To achieve these functions, we need to define pins in the program and implement SPI communication, followed by compiling the program using a cross-compilation tool. Let's delve into the specific implementation steps.
Pin Definitions
Define the pin numbers in
DEV_Config.h#define EPD_DC_PIN (34)
#define EPD_CS_PIN (48)
#define EPD_RST_PIN (51)
#define EPD_BUSY_PIN (4)Add Control Pin Level Macro Definitions in
DEV_Config.h#define EPD_CS_0 DEV_Digital_Write(EPD_CS_PIN,0)
#define EPD_CS_1 DEV_Digital_Write(EPD_CS_PIN,1)
#define EPD_RST_0 DEV_Digital_Write(EPD_RST_PIN,0)
#define EPD_RST_1 DEV_Digital_Write(EPD_RST_PIN,1)
#define EPD_DC_0 DEV_Digital_Write(EPD_DC_PIN,0)
#define EPD_DC_1 DEV_Digital_Write(EPD_DC_PIN,1)
#define EPD_BUSY_0 DEV_Digital_Write(EPD_BUSY_PIN,0)
#define EPD_BUSY_1 DEV_Digital_Write(EPD_BUSY_PIN,1)Initialize GPIO in
DEV_GPIO_InitFunctionstatic void DEV_GPIO_Init(void)
{
DEV_GPIO_Mode(EPD_CS_PIN, 1);
DEV_GPIO_Mode(EPD_RST_PIN, 1);
DEV_GPIO_Mode(EPD_DC_PIN, 1);
DEV_GPIO_Mode(EPD_BUSY_PIN, 0);
EPD_CS_1;
}
SPI Communication
Request SPI Resources in the
DEV_ModuleInitFunctionDEV_HARDWARE_SPI_begin("/dev/spidev0.0");Initialization
Initialize the LCD by calling the
EPD_2in13_V4_Initfunction in themainfunction.void EPD_2in13_V4_Init(void)
{
EPD_2in13_V4_Reset();
EPD_2in13_V4_ReadBusy();
EPD_2in13_V4_SendCommand(0x12); //SWRESET
EPD_2in13_V4_ReadBusy();
EPD_2in13_V4_SendCommand(0x01); //Driver output control
EPD_2in13_V4_SendData(0xF9);
......
}Sending Data
In the
EPD_2in13_V4_SendCommandfunction, you can lower theEPD_DC_PINpin to indicate that you're sending a command, and then use theDEV_SPI_WriteBytefunction to send data to the ePaper.static void EPD_2in13_V4_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_DC_PIN, 0); // Send command, set DC pin low
DEV_Digital_Write(EPD_CS_PIN, 0); // Start communication, pull CS pin low
DEV_HARDWARE_SPI_TransferByte(Reg); // Send data
DEV_Digital_Write(EPD_CS_PIN, 1); // End communication, set CS pin high
}In the
EPD_2in13_V4_SendDatafunction, set theEPD_DC_PINpin to high, indicating data transmission, and then call theDEV_SPI_WriteBytefunction to send data to the LCD.static void EPD_2in13_V4_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1); // Send data, set DC pin high
DEV_Digital_Write(EPD_CS_PIN, 0); // Start communication, pull CS pin low
DEV_HARDWARE_SPI_TransferByte(Data); // Send data
DEV_Digital_Write(EPD_CS_PIN, 1); // End communication, set CS pin high
}
交叉编译
Specify the Cross Compilation Tool
Users should move the entire "c" folder to the virtual machine and edit the
Makefilefile within the "c" folder. Modify the content after CC= in theMakefileto specify the cross-compilation tool.Replace
<SDK Directory>with your own SDK path in the Makefile, for example,/home/luckfox/luckfox-pico/.DIR_Config = ./lib/Config
DIR_EPD = ./lib/ePaper
DIR_FONTS = ./lib/Fonts
DIR_GUI = ./lib/GUI
DIR_Examples = ./examples
DIR_BIN = ./bin
OBJ_C = $(wildcard ${DIR_EPD}/*.c ${DIR_Config}/*.c ${DIR_GUI}/*.c ${DIR_Examples}/*.c ${DIR_FONTS}/*.c)
OBJ_O = $(patsubst %.c,${DIR_BIN}/%.o,$(notdir ${OBJ_C}))
TARGET = main
USELIB = USE_DEV_LIB
DEBUG = -D $(USELIB)
CC = <SDK Directory>/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc
MSG = -g -O0 -Wall
CFLAGS += $(MSG) $(DEBUG)
${TARGET}:${OBJ_O}
$(CC) $(CFLAGS) $(OBJ_O) -o $@ $(LIB)
${DIR_BIN}/%.o:$(DIR_Examples)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) -I $(DIR_GUI) -I $(DIR_EPD)
${DIR_BIN}/%.o:$(DIR_EPD)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config)
${DIR_BIN}/%.o:$(DIR_FONTS)/%.c
$(CC) $(CFLAGS) -c $< -o $@
${DIR_BIN}/%.o:$(DIR_GUI)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(DIR_Config) -I $(DIR_EPD) -I $(DIR_Examples)
${DIR_BIN}/%.o:$(DIR_Config)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LIB)
clean :
rm $(DIR_BIN)/*.*
rm $(TARGET)Compile the Program
After editing the
Makefile, use the 'make' command to cross-compile the program.luckfox@luckfox:~/c$ makeOnce cross-compilation is successful, an executable file named
mainwill be generated in the current directory.luckfox@luckfox:~/c$ ls
bin examples lib main Makefile pic readme_CN.txt readme_EN.txt
3. Achieving the Desired Outcomes
Transferring Compiled Files to the Development Board
To start, transfer the entire "c" folder from the virtual machine to your Windows computer. Next, use either TFTP or ADB to move the files to the development board. Here are the steps for using ADB to transfer files from Windows to the development board:
adb push [path_to_files] [board_storage_path]
Example: (Transferring the "c" folder from the current directory to the root directory of the development board)
adb push c /Running the Program
After adjusting the permissions of the
mainfile, execute the program:#cd c/
#chmod 777 main
#./main 2.13Experimental Observations
Image Display

GUI Interface 1

GUI Interface 2
