├── .gitignore ├── LICENSE ├── Python ├── Pico-LCD-0.96 │ ├── ReadmeCN.txt │ ├── ReadmeEN.txt │ └── pico-lcd-0.96.py ├── Pico-LCD-1.14 │ ├── Pico-LCD-1.14.py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Pico-LCD-1.3 │ ├── Pico-LCD-1.3.py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Pico-LCD-1.44 │ ├── Pico-lcd-1.44.py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Pico-LCD-1.8 │ ├── Pico-LCD-1.8.py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Pico-LCD-2 │ ├── Pico-LCD-2.py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Pico-OLED-1.3 │ ├── Pico-OLED-1.3(i2c).py │ ├── Pico-OLED-1.3(spi).py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Pico-OLED-2.23 │ ├── Pico-OLED-2.23(i2c).py │ ├── Pico-OLED-2.23(spi).py │ ├── ReadmeCN.txt │ └── ReadmeEN.txt ├── Readme.txt └── pico_micropython_20210121.uf2 ├── README.md ├── c ├── CMakeLists.txt ├── ReadmeCN.txt ├── ReadmeEN.txt ├── examples │ ├── CMakeLists.txt │ ├── EPD_Test.h │ ├── ImageData.c │ ├── ImageData.h │ ├── LCD_0in96_test.c │ ├── LCD_1in14_test.c │ ├── LCD_1in3_test.c │ ├── LCD_1in44_test.c │ ├── LCD_1in8_test.c │ ├── LCD_2in_test.c │ ├── OLED_1in3_C_test.c │ └── OLED_2in23_test.c ├── lib │ ├── .LCD.c.swp │ ├── Config │ │ ├── CMakeLists.txt │ │ ├── DEV_Config.c │ │ ├── DEV_Config.h │ │ ├── DEV_Config.h.gch │ │ └── Debug.h │ ├── Fonts │ │ ├── CMakeLists.txt │ │ ├── font12.c │ │ ├── font12CN.c │ │ ├── font16.c │ │ ├── font20.c │ │ ├── font24.c │ │ ├── font24CN.c │ │ ├── font8.c │ │ └── fonts.h │ ├── GUI │ │ ├── CMakeLists.txt │ │ ├── GUI_Paint.c │ │ └── GUI_Paint.h │ ├── Icm20948 │ │ ├── CMakeLists.txt │ │ ├── icm20948.c │ │ └── icm20948.h │ ├── Infrared │ │ ├── CMakeLists.txt │ │ ├── Infrared.c │ │ └── Infrared.h │ ├── LCD │ │ ├── CMakeLists.txt │ │ ├── LCD_0in96.c │ │ ├── LCD_0in96.h │ │ ├── LCD_1in14.c │ │ ├── LCD_1in14.h │ │ ├── LCD_1in3.c │ │ ├── LCD_1in3.h │ │ ├── LCD_1in44.c │ │ ├── LCD_1in44.h │ │ ├── LCD_1in54.c │ │ ├── LCD_1in54.h │ │ ├── LCD_1in8.c │ │ ├── LCD_1in8.h │ │ ├── LCD_2in.c │ │ └── LCD_2in.h │ └── OLED │ │ ├── CMakeLists.txt │ │ ├── OLED_1in3_c.c │ │ ├── OLED_1in3_c.h │ │ ├── OLED_2in23.c │ │ └── OLED_2in23.h ├── main.c ├── pico_sdk_import.cmake └── uf2 │ ├── LCD_1in14_test.uf2 │ ├── LCD_1in3.uf2 │ ├── LCD_1in44_test.uf2 │ ├── LCD_1in8_test.uf2 │ ├── LCD_2in_test.uf2 │ ├── OLED_1in3_C_test_I2C.uf2 │ ├── OLED_1in3_C_test_SPI.uf2 │ ├── OLED_2in23_test_I2C.uf2 │ └── OLED_2in23_test_SPI .uf2 └── waveshare_logo.png /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /Python/Pico-LCD-0.96/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-31 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-LCD-0.96.py查看,这里也再重述一次: 19 | LCD 0.96 20 | LCD => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | BL -> 13 29 | ----------------------------- 30 | (KEY) Pico 31 | UP: -> 2 32 | DOWN: -> 18 33 | LEFT: -> 16 34 | RIGHT: -> 20 35 | CTRL: -> 3 36 | A: -> 15 37 | B: -> 17 38 | 39 | 3.基本使用: 40 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到树莓派的USB接口,然后松开按键。 41 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 42 | 43 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 44 | 45 | 3): 更新Thonny IDE 46 | sudo apt upgrade thonny 47 | 48 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 49 | 选择Tools -> Options... -> Interpreter 50 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 51 | 52 | 5): 在Thonny IDE中打开python/Pico-LCD-0.96/Pico-LCD-0.96.py文件 53 | 然后运行当前脚本(绿色小三角)即可 54 | 55 | 4.例程中像素画板的使用说明: 56 | 例程中会显示一个8*16大小的方格(方格大小10*10 pixels) 57 | 摇杆: 58 | 上 -> 画笔上移 59 | 下 -> 画笔下移 60 | 左 -> 画笔左移 61 | 右 -> 画笔右移 62 | ctrl(摇杆中心键) -> 更换画笔颜色 63 | A -> 按住A按键不放,在画笔位置填充实心像素块,颜色为当前画笔颜色,此时可操作摇杆连续填充 64 | B -> 清空像素画板 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Python/Pico-LCD-0.96/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-31 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-LCD-0.96.py, and repeat it here: 20 | LCD 0.96 21 | LCD => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | BL -> 13 30 | ----------------------------- 31 | (KEY) Pico 32 | UP: -> 2 33 | DOWN: -> 18 34 | LEFT: -> 16 35 | RIGHT: -> 20 36 | CTRL: -> 3 37 | A: -> 15 38 | B: -> 17 39 | 40 | 3. Basic use: 41 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 42 | Raspberry Pi through the Micro USB cable, and then release the button. 43 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 44 | 45 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 46 | removable disk (RPI-RP2) 47 | 48 | 3): Update Thonny IDE 49 | sudo apt upgrade thonny 50 | 51 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 52 | select Tools -> Options... -> Interpreter 53 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 54 | 55 | 5): Open the python/Pico-LCD-0.96/Pico-LCD-0.96.py file in Thonny IDE 56 | Then run the current script (green triangle) 57 | 58 | 4. Instructions for the use of pixel artboard in the routine: 59 | The routine displays an 8*16 square (10*10 pixels). 60 | Handle: 61 | Up -> brush up 62 | Down -> brush down 63 | Left -> brush move left 64 | Right -> brush move right 65 | Control (Joystick Center) -> change the brush color 66 | A -> Hold down the A button and fill the solid pixel block at the brush position. 67 | The color is the current brush color. 68 | At this time, you can continuously fill with the joystick 69 | B -> Empties Pixel Artboard 70 | -------------------------------------------------------------------------------- /Python/Pico-LCD-0.96/pico-lcd-0.96.py: -------------------------------------------------------------------------------- 1 | from machine import Pin,SPI,PWM 2 | import framebuf 3 | import time 4 | 5 | #color is BGR 6 | RED = 0x00F8 7 | GREEN = 0xE007 8 | BLUE = 0x1F00 9 | WHITE = 0xFFFF 10 | BLACK = 0x0000 11 | class LCD_0inch96(framebuf.FrameBuffer): 12 | def __init__(self): 13 | 14 | self.width = 160 15 | self.height = 80 16 | 17 | self.cs = Pin(9,Pin.OUT) 18 | self.rst = Pin(12,Pin.OUT) 19 | # self.bl = Pin(13,Pin.OUT) 20 | self.cs(1) 21 | # pwm = PWM(Pin(13))#BL 22 | # pwm.freq(1000) 23 | self.spi = SPI(1) 24 | self.spi = SPI(1,1000_000) 25 | self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(10),mosi=Pin(11),miso=None) 26 | self.dc = Pin(8,Pin.OUT) 27 | self.dc(1) 28 | self.buffer = bytearray(self.height * self.width * 2) 29 | super().__init__(self.buffer, self.width, self.height, framebuf.RGB565) 30 | self.Init() 31 | self.SetWindows(0, 0, self.width-1, self.height-1) 32 | 33 | def reset(self): 34 | self.rst(1) 35 | time.sleep(0.2) 36 | self.rst(0) 37 | time.sleep(0.2) 38 | self.rst(1) 39 | time.sleep(0.2) 40 | 41 | def write_cmd(self, cmd): 42 | self.dc(0) 43 | self.cs(0) 44 | self.spi.write(bytearray([cmd])) 45 | 46 | def write_data(self, buf): 47 | self.dc(1) 48 | self.cs(0) 49 | self.spi.write(bytearray([buf])) 50 | self.cs(1) 51 | 52 | def backlight(self,value):#value: min:0 max:1000 53 | pwm = PWM(Pin(13))#BL 54 | pwm.freq(1000) 55 | if value>=1000: 56 | value=1000 57 | data=int (value*65536/1000) 58 | pwm.duty_u16(data) 59 | 60 | def Init(self): 61 | self.reset() 62 | self.backlight(10000) 63 | 64 | self.write_cmd(0x11) 65 | time.sleep(0.12) 66 | self.write_cmd(0x21) 67 | self.write_cmd(0x21) 68 | 69 | self.write_cmd(0xB1) 70 | self.write_data(0x05) 71 | self.write_data(0x3A) 72 | self.write_data(0x3A) 73 | 74 | self.write_cmd(0xB2) 75 | self.write_data(0x05) 76 | self.write_data(0x3A) 77 | self.write_data(0x3A) 78 | 79 | self.write_cmd(0xB3) 80 | self.write_data(0x05) 81 | self.write_data(0x3A) 82 | self.write_data(0x3A) 83 | self.write_data(0x05) 84 | self.write_data(0x3A) 85 | self.write_data(0x3A) 86 | 87 | self.write_cmd(0xB4) 88 | self.write_data(0x03) 89 | 90 | self.write_cmd(0xC0) 91 | self.write_data(0x62) 92 | self.write_data(0x02) 93 | self.write_data(0x04) 94 | 95 | self.write_cmd(0xC1) 96 | self.write_data(0xC0) 97 | 98 | self.write_cmd(0xC2) 99 | self.write_data(0x0D) 100 | self.write_data(0x00) 101 | 102 | self.write_cmd(0xC3) 103 | self.write_data(0x8D) 104 | self.write_data(0x6A) 105 | 106 | self.write_cmd(0xC4) 107 | self.write_data(0x8D) 108 | self.write_data(0xEE) 109 | 110 | self.write_cmd(0xC5) 111 | self.write_data(0x0E) 112 | 113 | self.write_cmd(0xE0) 114 | self.write_data(0x10) 115 | self.write_data(0x0E) 116 | self.write_data(0x02) 117 | self.write_data(0x03) 118 | self.write_data(0x0E) 119 | self.write_data(0x07) 120 | self.write_data(0x02) 121 | self.write_data(0x07) 122 | self.write_data(0x0A) 123 | self.write_data(0x12) 124 | self.write_data(0x27) 125 | self.write_data(0x37) 126 | self.write_data(0x00) 127 | self.write_data(0x0D) 128 | self.write_data(0x0E) 129 | self.write_data(0x10) 130 | 131 | self.write_cmd(0xE1) 132 | self.write_data(0x10) 133 | self.write_data(0x0E) 134 | self.write_data(0x03) 135 | self.write_data(0x03) 136 | self.write_data(0x0F) 137 | self.write_data(0x06) 138 | self.write_data(0x02) 139 | self.write_data(0x08) 140 | self.write_data(0x0A) 141 | self.write_data(0x13) 142 | self.write_data(0x26) 143 | self.write_data(0x36) 144 | self.write_data(0x00) 145 | self.write_data(0x0D) 146 | self.write_data(0x0E) 147 | self.write_data(0x10) 148 | 149 | self.write_cmd(0x3A) 150 | self.write_data(0x05) 151 | 152 | self.write_cmd(0x36) 153 | self.write_data(0xA8) 154 | 155 | self.write_cmd(0x29) 156 | 157 | def SetWindows(self, Xstart, Ystart, Xend, Yend):#example max:0,0,159,79 158 | Xstart=Xstart+1 159 | Xend=Xend+1 160 | Ystart=Ystart+26 161 | Yend=Yend+26 162 | self.write_cmd(0x2A) 163 | self.write_data(0x00) 164 | self.write_data(Xstart) 165 | self.write_data(0x00) 166 | self.write_data(Xend) 167 | 168 | self.write_cmd(0x2B) 169 | self.write_data(0x00) 170 | self.write_data(Ystart) 171 | self.write_data(0x00) 172 | self.write_data(Yend) 173 | 174 | self.write_cmd(0x2C) 175 | 176 | def display(self): 177 | 178 | self.SetWindows(0,0,self.width-1,self.height-1) 179 | self.dc(1) 180 | self.cs(0) 181 | self.spi.write(self.buffer) 182 | self.cs(1) 183 | 184 | 185 | if __name__=='__main__': 186 | 187 | lcd = LCD_0inch96() 188 | lcd.fill(BLACK) 189 | lcd.text("Hello pico!",35,15,GREEN) 190 | lcd.text("This is:",50,35,GREEN) 191 | lcd.text("Pico-LCD-0.96",30,55,GREEN) 192 | lcd.display() 193 | 194 | lcd.hline(10,10,140,BLUE) 195 | lcd.hline(10,70,140,BLUE) 196 | lcd.vline(10,10,60,BLUE) 197 | lcd.vline(150,10,60,BLUE) 198 | 199 | lcd.hline(0,0,160,BLUE) 200 | lcd.hline(0,79,160,BLUE) 201 | lcd.vline(0,0,80,BLUE) 202 | lcd.vline(159,0,80,BLUE) 203 | 204 | lcd.display() 205 | time.sleep(3) 206 | #game GUI 207 | ### 208 | lcd.fill(WHITE) 209 | 210 | i=0 211 | while(i<=80): 212 | lcd.hline(0,i,160,BLACK) 213 | i=i+10 214 | i=0 215 | while(i<=160): 216 | lcd.vline(i,0,80,BLACK) 217 | i=i+10 218 | lcd.display() 219 | ### 220 | 221 | x=80 222 | y=40 223 | color=RED 224 | colorflag=0 225 | 226 | KEY_UP = Pin(2,Pin.IN,Pin.PULL_UP) 227 | KEY_DOWN = Pin(18,Pin.IN,Pin.PULL_UP) 228 | KEY_LEFT= Pin(16,Pin.IN,Pin.PULL_UP) 229 | KEY_RIGHT= Pin(20,Pin.IN,Pin.PULL_UP) 230 | KEY_CTRL=Pin(3,Pin.IN,Pin.PULL_UP) 231 | KEY_A=Pin(15,Pin.IN,Pin.PULL_UP) 232 | KEY_B=Pin(17,Pin.IN,Pin.PULL_UP) 233 | 234 | while(1): 235 | key_flag=1 236 | if(key_flag and (KEY_UP.value()==0 or KEY_DOWN.value()==0 \ 237 | or KEY_LEFT.value()==0 or KEY_RIGHT.value()==0 \ 238 | or KEY_CTRL.value()==0 or KEY_A.value()==0 \ 239 | or KEY_B.value()==0 )): 240 | time.sleep(0.05) 241 | key_flag=0 242 | m=x 243 | n=y 244 | ###go up 245 | if(KEY_UP.value() == 0): 246 | y=y-10 247 | if(y<0): 248 | y=70 249 | if(KEY_DOWN.value() == 0): 250 | y=y+10 251 | if(y>=80): 252 | y=0 253 | if(KEY_LEFT.value() == 0): 254 | x=x-10 255 | if(x<0): 256 | x=150 257 | if(KEY_RIGHT.value() == 0): 258 | x=x+10 259 | if(x>=160): 260 | x=0 261 | if(KEY_CTRL.value() == 0): 262 | colorflag+=1 263 | if(colorflag==1): 264 | color=RED 265 | elif(colorflag==2): 266 | color=GREEN 267 | elif(colorflag==3): 268 | color=BLUE 269 | colorflag=0 270 | 271 | lcd.fill_rect(m,n,10,10,WHITE) 272 | lcd.hline(m,n,10,BLACK) 273 | lcd.hline(m,n+10,10,BLACK) 274 | lcd.vline(m,n,10,BLACK) 275 | lcd.vline(m+10,n,10,BLACK) 276 | 277 | 278 | lcd.rect(x+1,y+1,9,9,color) 279 | 280 | if(KEY_A.value() == 0): 281 | lcd.fill_rect(x+1,y+1,9,9,color) 282 | lcd.fill_rect(m+1,n+1,9,9,color) 283 | 284 | if(KEY_B.value() == 0): 285 | lcd.fill(WHITE) 286 | i=0 287 | while(i<=80): 288 | lcd.hline(0,i,160,BLACK) 289 | i=i+10 290 | i=0 291 | while(i<=160): 292 | lcd.vline(i,0,80,BLACK) 293 | i=i+10 294 | 295 | 296 | 297 | lcd.display() 298 | 299 | time.sleep(1) 300 | 301 | 302 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.14/Pico-LCD-1.14.py: -------------------------------------------------------------------------------- 1 | 2 | from machine import Pin,SPI,PWM 3 | import framebuf 4 | import time 5 | 6 | BL = 13 7 | DC = 8 8 | RST = 12 9 | MOSI = 11 10 | SCK = 10 11 | CS = 9 12 | 13 | 14 | class LCD_1inch14(framebuf.FrameBuffer): 15 | def __init__(self): 16 | self.width = 240 17 | self.height = 135 18 | 19 | self.cs = Pin(CS,Pin.OUT) 20 | self.rst = Pin(RST,Pin.OUT) 21 | 22 | self.cs(1) 23 | self.spi = SPI(1) 24 | self.spi = SPI(1,1000_000) 25 | self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 26 | self.dc = Pin(DC,Pin.OUT) 27 | self.dc(1) 28 | self.buffer = bytearray(self.height * self.width * 2) 29 | super().__init__(self.buffer, self.width, self.height, framebuf.RGB565) 30 | self.init_display() 31 | 32 | self.red = 0x07E0 33 | self.green = 0x001f 34 | self.blue = 0xf800 35 | self.white = 0xffff 36 | 37 | def write_cmd(self, cmd): 38 | self.cs(1) 39 | self.dc(0) 40 | self.cs(0) 41 | self.spi.write(bytearray([cmd])) 42 | self.cs(1) 43 | 44 | def write_data(self, buf): 45 | self.cs(1) 46 | self.dc(1) 47 | self.cs(0) 48 | self.spi.write(bytearray([buf])) 49 | self.cs(1) 50 | 51 | def init_display(self): 52 | """Initialize dispaly""" 53 | self.rst(1) 54 | self.rst(0) 55 | self.rst(1) 56 | 57 | self.write_cmd(0x36) 58 | self.write_data(0x70) 59 | 60 | self.write_cmd(0x3A) 61 | self.write_data(0x05) 62 | 63 | self.write_cmd(0xB2) 64 | self.write_data(0x0C) 65 | self.write_data(0x0C) 66 | self.write_data(0x00) 67 | self.write_data(0x33) 68 | self.write_data(0x33) 69 | 70 | self.write_cmd(0xB7) 71 | self.write_data(0x35) 72 | 73 | self.write_cmd(0xBB) 74 | self.write_data(0x19) 75 | 76 | self.write_cmd(0xC0) 77 | self.write_data(0x2C) 78 | 79 | self.write_cmd(0xC2) 80 | self.write_data(0x01) 81 | 82 | self.write_cmd(0xC3) 83 | self.write_data(0x12) 84 | 85 | self.write_cmd(0xC4) 86 | self.write_data(0x20) 87 | 88 | self.write_cmd(0xC6) 89 | self.write_data(0x0F) 90 | 91 | self.write_cmd(0xD0) 92 | self.write_data(0xA4) 93 | self.write_data(0xA1) 94 | 95 | self.write_cmd(0xE0) 96 | self.write_data(0xD0) 97 | self.write_data(0x04) 98 | self.write_data(0x0D) 99 | self.write_data(0x11) 100 | self.write_data(0x13) 101 | self.write_data(0x2B) 102 | self.write_data(0x3F) 103 | self.write_data(0x54) 104 | self.write_data(0x4C) 105 | self.write_data(0x18) 106 | self.write_data(0x0D) 107 | self.write_data(0x0B) 108 | self.write_data(0x1F) 109 | self.write_data(0x23) 110 | 111 | self.write_cmd(0xE1) 112 | self.write_data(0xD0) 113 | self.write_data(0x04) 114 | self.write_data(0x0C) 115 | self.write_data(0x11) 116 | self.write_data(0x13) 117 | self.write_data(0x2C) 118 | self.write_data(0x3F) 119 | self.write_data(0x44) 120 | self.write_data(0x51) 121 | self.write_data(0x2F) 122 | self.write_data(0x1F) 123 | self.write_data(0x1F) 124 | self.write_data(0x20) 125 | self.write_data(0x23) 126 | 127 | self.write_cmd(0x21) 128 | 129 | self.write_cmd(0x11) 130 | 131 | self.write_cmd(0x29) 132 | 133 | def show(self): 134 | self.write_cmd(0x2A) 135 | self.write_data(0x00) 136 | self.write_data(0x28) 137 | self.write_data(0x01) 138 | self.write_data(0x17) 139 | 140 | self.write_cmd(0x2B) 141 | self.write_data(0x00) 142 | self.write_data(0x35) 143 | self.write_data(0x00) 144 | self.write_data(0xBB) 145 | 146 | self.write_cmd(0x2C) 147 | 148 | self.cs(1) 149 | self.dc(1) 150 | self.cs(0) 151 | self.spi.write(self.buffer) 152 | self.cs(1) 153 | 154 | if __name__=='__main__': 155 | pwm = PWM(Pin(BL)) 156 | pwm.freq(1000) 157 | pwm.duty_u16(32768)#max 65535 158 | 159 | LCD = LCD_1inch14() 160 | #color BRG 161 | LCD.fill(LCD.white) 162 | 163 | LCD.show() 164 | LCD.text("Raspberry Pi Pico",60,40,LCD.red) 165 | LCD.text("PicoGo",60,60,LCD.green) 166 | LCD.text("Pico-LCD-1.14",60,80,LCD.blue) 167 | 168 | 169 | 170 | LCD.hline(10,10,220,LCD.blue) 171 | LCD.hline(10,125,220,LCD.blue) 172 | LCD.vline(10,10,115,LCD.blue) 173 | LCD.vline(230,10,115,LCD.blue) 174 | 175 | 176 | LCD.rect(12,12,20,20,LCD.red) 177 | LCD.rect(12,103,20,20,LCD.red) 178 | LCD.rect(208,12,20,20,LCD.red) 179 | LCD.rect(208,103,20,20,LCD.red) 180 | 181 | LCD.show() 182 | key0 = Pin(15,Pin.IN) 183 | key1 = Pin(17,Pin.IN) 184 | key2 = Pin(2 ,Pin.IN) 185 | key3 = Pin(3 ,Pin.IN) 186 | while(1): 187 | if(key0.value() == 0): 188 | LCD.fill_rect(12,12,20,20,LCD.red) 189 | else : 190 | LCD.fill_rect(12,12,20,20,LCD.white) 191 | LCD.rect(12,12,20,20,LCD.red) 192 | 193 | if(key1.value() == 0): 194 | LCD.fill_rect(12,103,20,20,LCD.red) 195 | else : 196 | LCD.fill_rect(12,103,20,20,LCD.white) 197 | LCD.rect(12,103,20,20,LCD.red) 198 | 199 | if(key2.value() == 0): 200 | LCD.fill_rect(208,12,20,20,LCD.red) 201 | else : 202 | LCD.fill_rect(208,12,20,20,LCD.white) 203 | LCD.rect(208,12,20,20,LCD.red) 204 | 205 | if(key3.value() == 0): 206 | LCD.fill_rect(208,103,20,20,LCD.red) 207 | else : 208 | LCD.fill_rect(208,103,20,20,LCD.white) 209 | LCD.rect(208,103,20,20,LCD.red) 210 | 211 | 212 | LCD.show() 213 | time.sleep(1) 214 | LCD.fill(0xFFFF) 215 | 216 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.14/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-02-04 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-LCD-1.14.py查看,这里也再重述一次: 19 | LCD 1.14 20 | LCD => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | BL -> 13 29 | 30 | 3.基本使用: 31 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 32 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 33 | 34 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 35 | 36 | 3): 更新Thonny IDE 37 | sudo apt upgrade thonny 38 | 39 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 40 | 选择Tools -> Options... -> Interpreter 41 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 42 | 43 | 5): 在Thonny IDE中打开python/Pico-LCD-1.14/Pico-LCD-1.14.py文件 44 | 然后运行当前脚本(绿色小三角)即可 45 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.14/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-02-04 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-LCD-1.14.py, and repeat it here: 20 | LCD 1.14 21 | LCD => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | BL -> 13 30 | 31 | 32 | 3. Basic use: 33 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 34 | computer through the Micro USB cable, and then release the button. 35 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 36 | 37 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 38 | removable disk (RPI-RP2) 39 | 40 | 3): Update Thonny IDE 41 | sudo apt upgrade thonny 42 | 43 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 44 | select Tools -> Options... -> Interpreter 45 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 46 | 47 | 5): Open the python/Pico-LCD-1.14/Pico-LCD-1.14.py file in Thonny IDE 48 | Then run the current script (green triangle) 49 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.3/Pico-LCD-1.3.py: -------------------------------------------------------------------------------- 1 | 2 | from machine import Pin,SPI,PWM 3 | import framebuf 4 | import time 5 | import os 6 | 7 | BL = 13 8 | DC = 8 9 | RST = 12 10 | MOSI = 11 11 | SCK = 10 12 | CS = 9 13 | 14 | 15 | class LCD_1inch3(framebuf.FrameBuffer): 16 | def __init__(self): 17 | self.width = 240 18 | self.height = 240 19 | 20 | self.cs = Pin(CS,Pin.OUT) 21 | self.rst = Pin(RST,Pin.OUT) 22 | 23 | self.cs(1) 24 | self.spi = SPI(1) 25 | self.spi = SPI(1,1000_000) 26 | self.spi = SPI(1,100000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 27 | self.dc = Pin(DC,Pin.OUT) 28 | self.dc(1) 29 | self.buffer = bytearray(self.height * self.width * 2) 30 | super().__init__(self.buffer, self.width, self.height, framebuf.RGB565) 31 | self.init_display() 32 | 33 | self.red = 0x07E0 34 | self.green = 0x001f 35 | self.blue = 0xf800 36 | self.white = 0xffff 37 | 38 | def write_cmd(self, cmd): 39 | self.cs(1) 40 | self.dc(0) 41 | self.cs(0) 42 | self.spi.write(bytearray([cmd])) 43 | self.cs(1) 44 | 45 | def write_data(self, buf): 46 | self.cs(1) 47 | self.dc(1) 48 | self.cs(0) 49 | self.spi.write(bytearray([buf])) 50 | self.cs(1) 51 | 52 | def init_display(self): 53 | """Initialize dispaly""" 54 | self.rst(1) 55 | self.rst(0) 56 | self.rst(1) 57 | 58 | self.write_cmd(0x36) 59 | self.write_data(0x70) 60 | 61 | self.write_cmd(0x3A) 62 | self.write_data(0x05) 63 | 64 | self.write_cmd(0xB2) 65 | self.write_data(0x0C) 66 | self.write_data(0x0C) 67 | self.write_data(0x00) 68 | self.write_data(0x33) 69 | self.write_data(0x33) 70 | 71 | self.write_cmd(0xB7) 72 | self.write_data(0x35) 73 | 74 | self.write_cmd(0xBB) 75 | self.write_data(0x19) 76 | 77 | self.write_cmd(0xC0) 78 | self.write_data(0x2C) 79 | 80 | self.write_cmd(0xC2) 81 | self.write_data(0x01) 82 | 83 | self.write_cmd(0xC3) 84 | self.write_data(0x12) 85 | 86 | self.write_cmd(0xC4) 87 | self.write_data(0x20) 88 | 89 | self.write_cmd(0xC6) 90 | self.write_data(0x0F) 91 | 92 | self.write_cmd(0xD0) 93 | self.write_data(0xA4) 94 | self.write_data(0xA1) 95 | 96 | self.write_cmd(0xE0) 97 | self.write_data(0xD0) 98 | self.write_data(0x04) 99 | self.write_data(0x0D) 100 | self.write_data(0x11) 101 | self.write_data(0x13) 102 | self.write_data(0x2B) 103 | self.write_data(0x3F) 104 | self.write_data(0x54) 105 | self.write_data(0x4C) 106 | self.write_data(0x18) 107 | self.write_data(0x0D) 108 | self.write_data(0x0B) 109 | self.write_data(0x1F) 110 | self.write_data(0x23) 111 | 112 | self.write_cmd(0xE1) 113 | self.write_data(0xD0) 114 | self.write_data(0x04) 115 | self.write_data(0x0C) 116 | self.write_data(0x11) 117 | self.write_data(0x13) 118 | self.write_data(0x2C) 119 | self.write_data(0x3F) 120 | self.write_data(0x44) 121 | self.write_data(0x51) 122 | self.write_data(0x2F) 123 | self.write_data(0x1F) 124 | self.write_data(0x1F) 125 | self.write_data(0x20) 126 | self.write_data(0x23) 127 | 128 | self.write_cmd(0x21) 129 | 130 | self.write_cmd(0x11) 131 | 132 | self.write_cmd(0x29) 133 | 134 | def show(self): 135 | self.write_cmd(0x2A) 136 | self.write_data(0x00) 137 | self.write_data(0x00) 138 | self.write_data(0x00) 139 | self.write_data(0xef) 140 | 141 | self.write_cmd(0x2B) 142 | self.write_data(0x00) 143 | self.write_data(0x00) 144 | self.write_data(0x00) 145 | self.write_data(0xEF) 146 | 147 | self.write_cmd(0x2C) 148 | 149 | self.cs(1) 150 | self.dc(1) 151 | self.cs(0) 152 | self.spi.write(self.buffer) 153 | self.cs(1) 154 | 155 | 156 | if __name__=='__main__': 157 | pwm = PWM(Pin(BL)) 158 | pwm.freq(1000) 159 | pwm.duty_u16(32768)#max 65535 160 | 161 | LCD = LCD_1inch3() 162 | #color BRG 163 | LCD.fill(LCD.white) 164 | LCD.show() 165 | 166 | 167 | keyA = Pin(15,Pin.IN,Pin.PULL_UP) 168 | keyB = Pin(17,Pin.IN,Pin.PULL_UP) 169 | keyX = Pin(19 ,Pin.IN,Pin.PULL_UP) 170 | keyY= Pin(21 ,Pin.IN,Pin.PULL_UP) 171 | 172 | up = Pin(2,Pin.IN,Pin.PULL_UP) 173 | dowm = Pin(18,Pin.IN,Pin.PULL_UP) 174 | left = Pin(16,Pin.IN,Pin.PULL_UP) 175 | right = Pin(20,Pin.IN,Pin.PULL_UP) 176 | ctrl = Pin(3,Pin.IN,Pin.PULL_UP) 177 | 178 | while(1): 179 | if keyA.value() == 0: 180 | LCD.fill_rect(208,15,30,30,LCD.red) 181 | print("A") 182 | else : 183 | LCD.fill_rect(208,15,30,30,LCD.white) 184 | LCD.rect(208,15,30,30,LCD.red) 185 | 186 | 187 | if(keyB.value() == 0): 188 | LCD.fill_rect(208,75,30,30,LCD.red) 189 | print("B") 190 | else : 191 | LCD.fill_rect(208,75,30,30,LCD.white) 192 | LCD.rect(208,75,30,30,LCD.red) 193 | 194 | 195 | if(keyX.value() == 0): 196 | LCD.fill_rect(208,135,30,30,LCD.red) 197 | print("C") 198 | else : 199 | LCD.fill_rect(208,135,30,30,LCD.white) 200 | LCD.rect(208,135,30,30,LCD.red) 201 | 202 | if(keyY.value() == 0): 203 | LCD.fill_rect(208,195,30,30,LCD.red) 204 | print("D") 205 | else : 206 | LCD.fill_rect(208,195,30,30,LCD.white) 207 | LCD.rect(208,195,30,30,LCD.red) 208 | 209 | if(up.value() == 0): 210 | LCD.fill_rect(60,60,30,30,LCD.red) 211 | print("UP") 212 | else : 213 | LCD.fill_rect(60,60,30,30,LCD.white) 214 | LCD.rect(60,60,30,30,LCD.red) 215 | 216 | if(dowm.value() == 0): 217 | LCD.fill_rect(60,150,30,30,LCD.red) 218 | print("DOWM") 219 | else : 220 | LCD.fill_rect(60,150,30,30,LCD.white) 221 | LCD.rect(60,150,30,30,LCD.red) 222 | 223 | if(left.value() == 0): 224 | LCD.fill_rect(15,105,30,30,LCD.red) 225 | print("LEFT") 226 | else : 227 | LCD.fill_rect(15,105,30,30,LCD.white) 228 | LCD.rect(15,105,30,30,LCD.red) 229 | 230 | if(right.value() == 0): 231 | LCD.fill_rect(105,105,30,30,LCD.red) 232 | print("RIGHT") 233 | else : 234 | LCD.fill_rect(105,105,30,30,LCD.white) 235 | LCD.rect(105,105,30,30,LCD.red) 236 | 237 | if(ctrl.value() == 0): 238 | LCD.fill_rect(60,105,30,30,LCD.red) 239 | print("CTRL") 240 | else : 241 | LCD.fill_rect(60,105,30,30,LCD.white) 242 | LCD.rect(60,105,30,30,LCD.red) 243 | 244 | LCD.show() 245 | time.sleep(1) 246 | LCD.fill(0xFFFF) 247 | 248 | 249 | 250 | 251 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.3/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-LCD-1.3.py查看,这里也再重述一次: 19 | LCD 1.3 20 | LCD => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | BL -> 13 29 | A -> 15 30 | B -> 17 31 | X -> 19 32 | Y -> 21 33 | UP -> 2 34 | DOWM -> 18 35 | LEFT -> 16 36 | RIGHT -> 20 37 | CTRL -> 3 38 | 39 | 3.基本使用: 40 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 41 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 42 | 43 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 44 | 45 | 3): 更新Thonny IDE 46 | sudo apt upgrade thonny 47 | 48 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 49 | 选择Tools -> Options... -> Interpreter 50 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 51 | 52 | 5): 在Thonny IDE中打开python/Pico-LCD-1.3/Pico-LCD-1.3.py文件 53 | 然后运行当前脚本(绿色小三角)即可 54 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.3/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-LCD-1.3.py, and repeat it here: 20 | LCD 1.3 21 | LCD => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | BL -> 13 30 | A -> 15 31 | B -> 17 32 | X -> 19 33 | Y -> 21 34 | UP -> 2 35 | DOWM -> 18 36 | LEFT -> 16 37 | RIGHT -> 20 38 | CTRL -> 3 39 | 40 | 41 | 3. Basic use: 42 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 43 | computer through the Micro USB cable, and then release the button. 44 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 45 | 46 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 47 | removable disk (RPI-RP2) 48 | 49 | 3): Update Thonny IDE 50 | sudo apt upgrade thonny 51 | 52 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 53 | select Tools -> Options... -> Interpreter 54 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 55 | 56 | 5): Open the python/Pico-LCD-1.3/Pico-LCD-1.3.py file in Thonny IDE 57 | Then run the current script (green triangle) 58 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.44/Pico-lcd-1.44.py: -------------------------------------------------------------------------------- 1 | 2 | from machine import Pin,SPI,PWM 3 | import framebuf 4 | import time 5 | 6 | BL = 13 7 | DC = 8 8 | RST = 12 9 | MOSI = 11 10 | SCK = 10 11 | CS = 9 12 | 13 | 14 | class LCD_1inch44(framebuf.FrameBuffer): 15 | def __init__(self): 16 | self.width = 128 17 | self.height = 128 18 | 19 | self.cs = Pin(CS,Pin.OUT) 20 | self.rst = Pin(RST,Pin.OUT) 21 | 22 | self.cs(1) 23 | self.spi = SPI(1) 24 | self.spi = SPI(1,1000_000) 25 | self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 26 | self.dc = Pin(DC,Pin.OUT) 27 | self.dc(1) 28 | self.buffer = bytearray(self.height * self.width * 2) 29 | super().__init__(self.buffer, self.width, self.height, framebuf.RGB565) 30 | self.init_display() 31 | 32 | 33 | self.WHITE = 0xFFFF 34 | self.BLACK = 0x0000 35 | self.GREEN = 0x001F 36 | self.RED = 0xF800 37 | self.BLUE = 0x07E0 38 | self.GBLUE = 0X07FF 39 | self.YELLOW = 0xFFE0 40 | 41 | def write_cmd(self, cmd): 42 | self.cs(1) 43 | self.dc(0) 44 | self.cs(0) 45 | self.spi.write(bytearray([cmd])) 46 | self.cs(1) 47 | 48 | def write_data(self, buf): 49 | self.cs(1) 50 | self.dc(1) 51 | self.cs(0) 52 | self.spi.write(bytearray([buf])) 53 | self.cs(1) 54 | 55 | def init_display(self): 56 | """Initialize dispaly""" 57 | self.rst(1) 58 | self.rst(0) 59 | self.rst(1) 60 | 61 | self.write_cmd(0x36); 62 | self.write_data(0x70); 63 | 64 | self.write_cmd(0x3A); 65 | self.write_data(0x05); 66 | 67 | #ST7735R Frame Rate 68 | self.write_cmd(0xB1); 69 | self.write_data(0x01); 70 | self.write_data(0x2C); 71 | self.write_data(0x2D); 72 | 73 | self.write_cmd(0xB2); 74 | self.write_data(0x01); 75 | self.write_data(0x2C); 76 | self.write_data(0x2D); 77 | 78 | self.write_cmd(0xB3); 79 | self.write_data(0x01); 80 | self.write_data(0x2C); 81 | self.write_data(0x2D); 82 | self.write_data(0x01); 83 | self.write_data(0x2C); 84 | self.write_data(0x2D); 85 | 86 | self.write_cmd(0xB4); #Column inversion 87 | self.write_data(0x07); 88 | 89 | #ST7735R Power Sequence 90 | self.write_cmd(0xC0); 91 | self.write_data(0xA2); 92 | self.write_data(0x02); 93 | self.write_data(0x84); 94 | self.write_cmd(0xC1); 95 | self.write_data(0xC5); 96 | 97 | self.write_cmd(0xC2); 98 | self.write_data(0x0A); 99 | self.write_data(0x00); 100 | 101 | self.write_cmd(0xC3); 102 | self.write_data(0x8A); 103 | self.write_data(0x2A); 104 | self.write_cmd(0xC4); 105 | self.write_data(0x8A); 106 | self.write_data(0xEE); 107 | 108 | self.write_cmd(0xC5); #VCOM 109 | self.write_data(0x0E); 110 | 111 | #ST7735R Gamma Sequence 112 | self.write_cmd(0xe0); 113 | self.write_data(0x0f); 114 | self.write_data(0x1a); 115 | self.write_data(0x0f); 116 | self.write_data(0x18); 117 | self.write_data(0x2f); 118 | self.write_data(0x28); 119 | self.write_data(0x20); 120 | self.write_data(0x22); 121 | self.write_data(0x1f); 122 | self.write_data(0x1b); 123 | self.write_data(0x23); 124 | self.write_data(0x37); 125 | self.write_data(0x00); 126 | self.write_data(0x07); 127 | self.write_data(0x02); 128 | self.write_data(0x10); 129 | 130 | self.write_cmd(0xe1); 131 | self.write_data(0x0f); 132 | self.write_data(0x1b); 133 | self.write_data(0x0f); 134 | self.write_data(0x17); 135 | self.write_data(0x33); 136 | self.write_data(0x2c); 137 | self.write_data(0x29); 138 | self.write_data(0x2e); 139 | self.write_data(0x30); 140 | self.write_data(0x30); 141 | self.write_data(0x39); 142 | self.write_data(0x3f); 143 | self.write_data(0x00); 144 | self.write_data(0x07); 145 | self.write_data(0x03); 146 | self.write_data(0x10); 147 | 148 | self.write_cmd(0xF0); #Enable test command 149 | self.write_data(0x01); 150 | 151 | self.write_cmd(0xF6); #Disable ram power save mode 152 | self.write_data(0x00); 153 | #sleep out 154 | self.write_cmd(0x11); 155 | #Turn on the LCD display 156 | self.write_cmd(0x29); 157 | 158 | def show(self): 159 | self.write_cmd(0x2A) 160 | self.write_data(0x00) 161 | self.write_data(0x01) 162 | self.write_data(0x00) 163 | self.write_data(0x80) 164 | 165 | self.write_cmd(0x2B) 166 | self.write_data(0x00) 167 | self.write_data(0x02) 168 | self.write_data(0x00) 169 | self.write_data(0x82) 170 | 171 | self.write_cmd(0x2C) 172 | 173 | self.cs(1) 174 | self.dc(1) 175 | self.cs(0) 176 | self.spi.write(self.buffer) 177 | self.cs(1) 178 | 179 | if __name__=='__main__': 180 | pwm = PWM(Pin(BL)) 181 | pwm.freq(1000) 182 | pwm.duty_u16(32768)#max 65535 183 | 184 | LCD = LCD_1inch44() 185 | #color BRG 186 | LCD.fill(LCD.BLACK) 187 | 188 | LCD.show() 189 | 190 | LCD.fill_rect(15,40,75,12,LCD.YELLOW) 191 | LCD.rect(15,40,75,12,LCD.YELLOW) 192 | LCD.text("1in44-LCD",17,42,LCD.WHITE) 193 | 194 | LCD.fill_rect(15,60,75,12,LCD.BLUE) 195 | LCD.rect(15,60,75,12,LCD.BLUE) 196 | LCD.text("128x128Px ",17,62,LCD.WHITE) 197 | 198 | LCD.fill_rect(15,80,75,12,LCD.GREEN) 199 | LCD.rect(15,80,75,12,LCD.GREEN) 200 | LCD.text("ST7735S",17,82,LCD.WHITE) 201 | 202 | LCD.hline(5,5,120,LCD.GBLUE) 203 | LCD.hline(5,125,120,LCD.GBLUE) 204 | LCD.vline(5,5,120,LCD.GBLUE) 205 | LCD.vline(125,5,120,LCD.GBLUE) 206 | 207 | LCD.show() 208 | 209 | key0 = Pin(15,Pin.IN,Pin.PULL_UP) 210 | key1 = Pin(17,Pin.IN,Pin.PULL_UP) 211 | key2 = Pin(2 ,Pin.IN,Pin.PULL_UP) 212 | key3 = Pin(3 ,Pin.IN,Pin.PULL_UP) 213 | 214 | while(1): 215 | if(key0.value() == 0): 216 | LCD.fill_rect(100,100,20,20,LCD.GBLUE) 217 | else : 218 | LCD.fill_rect(100,100,20,20,LCD.BLACK) 219 | LCD.rect(100,100,20,20,LCD.GBLUE) 220 | 221 | if(key1.value() == 0): 222 | LCD.fill_rect(100,70,20,20,LCD.GBLUE) 223 | else : 224 | LCD.fill_rect(100,70,20,20,LCD.BLACK) 225 | LCD.rect(100,70,20,20,LCD.GBLUE) 226 | 227 | if(key2.value() == 0): 228 | LCD.fill_rect(100,40,20,20,LCD.GBLUE) 229 | else : 230 | LCD.fill_rect(100,40,20,20,LCD.BLACK) 231 | LCD.rect(100,40,20,20,LCD.GBLUE) 232 | if(key3.value() == 0): 233 | 234 | LCD.fill_rect(100,10,20,20,LCD.GBLUE) 235 | else : 236 | LCD.fill_rect(100,10,20,20,LCD.BLACK) 237 | LCD.rect(100,10,20,20,LCD.GBLUE) 238 | 239 | LCD.show() 240 | time.sleep(1) 241 | LCD.fill(0xFFFF) 242 | 243 | 244 | 245 | 246 | 247 | 248 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.44/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-LCD-1.44.py查看,这里也再重述一次: 19 | LCD 1.44 20 | LCD => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | BL -> 13 29 | 30 | 3.基本使用: 31 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 32 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 33 | 34 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 35 | 36 | 3): 更新Thonny IDE 37 | sudo apt upgrade thonny 38 | 39 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 40 | 选择Tools -> Options... -> Interpreter 41 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 42 | 43 | 5): 在Thonny IDE中打开python/Pico-LCD-1.44/Pico-LCD-1.44.py文件 44 | 然后运行当前脚本(绿色小三角)即可 45 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.44/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-LCD-1.44.py, and repeat it here: 20 | LCD 1.44 21 | LCD => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | BL -> 13 30 | 31 | 32 | 3. Basic use: 33 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 34 | computer through the Micro USB cable, and then release the button. 35 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 36 | 37 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 38 | removable disk (RPI-RP2) 39 | 40 | 3): Update Thonny IDE 41 | sudo apt upgrade thonny 42 | 43 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 44 | select Tools -> Options... -> Interpreter 45 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 46 | 47 | 5): Open the python/Pico-LCD-1.44/Pico-LCD-1.44.py file in Thonny IDE 48 | Then run the current script (green triangle) 49 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.8/Pico-LCD-1.8.py: -------------------------------------------------------------------------------- 1 | 2 | from machine import Pin,SPI,PWM 3 | import framebuf 4 | import time 5 | 6 | BL = 13 7 | DC = 8 8 | RST = 12 9 | MOSI = 11 10 | SCK = 10 11 | CS = 9 12 | 13 | 14 | class LCD_1inch8(framebuf.FrameBuffer): 15 | def __init__(self): 16 | self.width = 161 17 | self.height = 130 18 | 19 | self.cs = Pin(CS,Pin.OUT) 20 | self.rst = Pin(RST,Pin.OUT) 21 | 22 | self.cs(1) 23 | self.spi = SPI(1) 24 | self.spi = SPI(1,1000_000) 25 | self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 26 | self.dc = Pin(DC,Pin.OUT) 27 | self.dc(1) 28 | self.buffer = bytearray(self.height * self.width * 2) 29 | super().__init__(self.buffer, self.width, self.height, framebuf.RGB565) 30 | self.init_display() 31 | 32 | 33 | self.WHITE = 0xFFFF 34 | self.BLACK = 0x0000 35 | self.GREEN = 0x001F 36 | self.BLUE = 0xF800 37 | self.RED = 0x07E0 38 | 39 | 40 | def write_cmd(self, cmd): 41 | self.cs(1) 42 | self.dc(0) 43 | self.cs(0) 44 | self.spi.write(bytearray([cmd])) 45 | self.cs(1) 46 | 47 | def write_data(self, buf): 48 | self.cs(1) 49 | self.dc(1) 50 | self.cs(0) 51 | self.spi.write(bytearray([buf])) 52 | self.cs(1) 53 | 54 | def init_display(self): 55 | """Initialize dispaly""" 56 | self.rst(1) 57 | self.rst(0) 58 | self.rst(1) 59 | 60 | self.write_cmd(0x36); 61 | self.write_data(0x70); 62 | 63 | self.write_cmd(0x3A); 64 | self.write_data(0x05); 65 | 66 | #ST7735R Frame Rate 67 | self.write_cmd(0xB1); 68 | self.write_data(0x01); 69 | self.write_data(0x2C); 70 | self.write_data(0x2D); 71 | 72 | self.write_cmd(0xB2); 73 | self.write_data(0x01); 74 | self.write_data(0x2C); 75 | self.write_data(0x2D); 76 | 77 | self.write_cmd(0xB3); 78 | self.write_data(0x01); 79 | self.write_data(0x2C); 80 | self.write_data(0x2D); 81 | self.write_data(0x01); 82 | self.write_data(0x2C); 83 | self.write_data(0x2D); 84 | 85 | self.write_cmd(0xB4); #Column inversion 86 | self.write_data(0x07); 87 | 88 | #ST7735R Power Sequence 89 | self.write_cmd(0xC0); 90 | self.write_data(0xA2); 91 | self.write_data(0x02); 92 | self.write_data(0x84); 93 | self.write_cmd(0xC1); 94 | self.write_data(0xC5); 95 | 96 | self.write_cmd(0xC2); 97 | self.write_data(0x0A); 98 | self.write_data(0x00); 99 | 100 | self.write_cmd(0xC3); 101 | self.write_data(0x8A); 102 | self.write_data(0x2A); 103 | self.write_cmd(0xC4); 104 | self.write_data(0x8A); 105 | self.write_data(0xEE); 106 | 107 | self.write_cmd(0xC5); #VCOM 108 | self.write_data(0x0E); 109 | 110 | #ST7735R Gamma Sequence 111 | self.write_cmd(0xe0); 112 | self.write_data(0x0f); 113 | self.write_data(0x1a); 114 | self.write_data(0x0f); 115 | self.write_data(0x18); 116 | self.write_data(0x2f); 117 | self.write_data(0x28); 118 | self.write_data(0x20); 119 | self.write_data(0x22); 120 | self.write_data(0x1f); 121 | self.write_data(0x1b); 122 | self.write_data(0x23); 123 | self.write_data(0x37); 124 | self.write_data(0x00); 125 | self.write_data(0x07); 126 | self.write_data(0x02); 127 | self.write_data(0x10); 128 | 129 | self.write_cmd(0xe1); 130 | self.write_data(0x0f); 131 | self.write_data(0x1b); 132 | self.write_data(0x0f); 133 | self.write_data(0x17); 134 | self.write_data(0x33); 135 | self.write_data(0x2c); 136 | self.write_data(0x29); 137 | self.write_data(0x2e); 138 | self.write_data(0x30); 139 | self.write_data(0x30); 140 | self.write_data(0x39); 141 | self.write_data(0x3f); 142 | self.write_data(0x00); 143 | self.write_data(0x07); 144 | self.write_data(0x03); 145 | self.write_data(0x10); 146 | 147 | self.write_cmd(0xF0); #Enable test command 148 | self.write_data(0x01); 149 | 150 | self.write_cmd(0xF6); #Disable ram power save mode 151 | self.write_data(0x00); 152 | 153 | #sleep out 154 | self.write_cmd(0x11); 155 | #DEV_Delay_ms(120); 156 | 157 | #Turn on the LCD display 158 | self.write_cmd(0x29); 159 | 160 | def show(self): 161 | self.write_cmd(0x2A) 162 | self.write_data(0x00) 163 | self.write_data(0x01) 164 | self.write_data(0x00) 165 | self.write_data(0xf1) 166 | 167 | 168 | 169 | self.write_cmd(0x2B) 170 | self.write_data(0x00) 171 | self.write_data(0x01) 172 | self.write_data(0x00) 173 | self.write_data(0xf1) 174 | 175 | self.write_cmd(0x2C) 176 | 177 | self.cs(1) 178 | self.dc(1) 179 | self.cs(0) 180 | self.spi.write(self.buffer) 181 | self.cs(1) 182 | 183 | if __name__=='__main__': 184 | pwm = PWM(Pin(BL)) 185 | pwm.freq(1000) 186 | pwm.duty_u16(32768)#max 65535 187 | 188 | LCD = LCD_1inch8() 189 | #color BRG 190 | LCD.fill(LCD.WHITE) 191 | 192 | LCD.show() 193 | 194 | LCD.fill_rect(0,0,160,20,LCD.RED) 195 | LCD.rect(0,0,160,20,LCD.RED) 196 | LCD.text("Raspberry Pi Pico",2,8,LCD.WHITE) 197 | 198 | LCD.fill_rect(0,20,160,20,LCD.BLUE) 199 | LCD.rect(0,20,160,20,LCD.BLUE) 200 | LCD.text("PicoGo",2,28,LCD.WHITE) 201 | 202 | LCD.fill_rect(0,40,160,20,LCD.GREEN) 203 | LCD.rect(0,40,160,20,LCD.GREEN) 204 | LCD.text("Pico-LCD-1.8",2,48,LCD.WHITE) 205 | 206 | LCD.fill_rect(0,60,160,10,0X07FF) 207 | LCD.rect(0,60,160,10,0X07FF) 208 | LCD.fill_rect(0,70,160,10,0xF81F) 209 | LCD.rect(0,70,160,10,0xF81F) 210 | LCD.fill_rect(0,80,160,10,0x7FFF) 211 | LCD.rect(0,80,160,10,0x7FFF) 212 | LCD.fill_rect(0,90,160,10,0xFFE0) 213 | LCD.rect(0,90,160,10,0xFFE0) 214 | LCD.fill_rect(0,100,160,10,0XBC40) 215 | LCD.rect(0,100,160,10,0XBC40) 216 | LCD.fill_rect(0,110,160,10,0XFC07) 217 | LCD.rect(0,110,160,10,0XFC07) 218 | LCD.fill_rect(0,120,160,10,0X8430) 219 | LCD.rect(0,120,160,10,0X8430) 220 | 221 | 222 | 223 | 224 | LCD.show() 225 | time.sleep(1) 226 | LCD.fill(0xFFFF) 227 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.8/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-02-04 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-LCD-1.8.py查看,这里也再重述一次: 19 | LCD 1.8 20 | LCD => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | BL -> 13 29 | 30 | 3.基本使用: 31 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 32 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 33 | 34 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 35 | 36 | 3): 更新Thonny IDE 37 | sudo apt upgrade thonny 38 | 39 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 40 | 选择Tools -> Options... -> Interpreter 41 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 42 | 43 | 5): 在Thonny IDE中打开python/Pico-LCD-1.8/Pico-LCD-1.8.py文件 44 | 然后运行当前脚本(绿色小三角)即可 45 | -------------------------------------------------------------------------------- /Python/Pico-LCD-1.8/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-02-04 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-LCD-1.8.py, and repeat it here: 20 | LCD 1.8 21 | LCD => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | BL -> 13 30 | 31 | 32 | 3. Basic use: 33 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 34 | computer through the Micro USB cable, and then release the button. 35 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 36 | 37 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 38 | removable disk (RPI-RP2) 39 | 40 | 3): Update Thonny IDE 41 | sudo apt upgrade thonny 42 | 43 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 44 | select Tools -> Options... -> Interpreter 45 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 46 | 47 | 5): Open the python/Pico-LCD-1.8/Pico-LCD-1.8.py file in Thonny IDE 48 | Then run the current script (green triangle) 49 | -------------------------------------------------------------------------------- /Python/Pico-LCD-2/Pico-LCD-2.py: -------------------------------------------------------------------------------- 1 | 2 | from machine import Pin,SPI,PWM 3 | import framebuf 4 | import time 5 | import os 6 | 7 | BL = 13 8 | DC = 8 9 | RST = 12 10 | MOSI = 11 11 | SCK = 10 12 | CS = 9 13 | 14 | 15 | class LCD_1inch3(framebuf.FrameBuffer): 16 | def __init__(self): 17 | self.width = 320 18 | self.height = 240 19 | 20 | self.cs = Pin(CS,Pin.OUT) 21 | self.rst = Pin(RST,Pin.OUT) 22 | 23 | self.cs(1) 24 | self.spi = SPI(1) 25 | self.spi = SPI(1,1000_000) 26 | self.spi = SPI(1,100000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 27 | self.dc = Pin(DC,Pin.OUT) 28 | self.dc(1) 29 | self.buffer = bytearray(self.height * self.width * 2) 30 | super().__init__(self.buffer, self.width, self.height, framebuf.RGB565) 31 | self.init_display() 32 | 33 | self.RED = 0x07E0 34 | self.GREEN = 0x001f 35 | self.BLUE = 0xf800 36 | self.WHITE = 0xffff 37 | self.BALCK = 0x0000 38 | 39 | def write_cmd(self, cmd): 40 | self.cs(1) 41 | self.dc(0) 42 | self.cs(0) 43 | self.spi.write(bytearray([cmd])) 44 | self.cs(1) 45 | 46 | def write_data(self, buf): 47 | self.cs(1) 48 | self.dc(1) 49 | self.cs(0) 50 | self.spi.write(bytearray([buf])) 51 | self.cs(1) 52 | 53 | def init_display(self): 54 | """Initialize dispaly""" 55 | self.rst(1) 56 | self.rst(0) 57 | self.rst(1) 58 | 59 | self.write_cmd(0x36) 60 | self.write_data(0x70) 61 | 62 | self.write_cmd(0x3A) 63 | self.write_data(0x05) 64 | 65 | self.write_cmd(0xB2) 66 | self.write_data(0x0C) 67 | self.write_data(0x0C) 68 | self.write_data(0x00) 69 | self.write_data(0x33) 70 | self.write_data(0x33) 71 | 72 | self.write_cmd(0xB7) 73 | self.write_data(0x35) 74 | 75 | self.write_cmd(0xBB) 76 | self.write_data(0x19) 77 | 78 | self.write_cmd(0xC0) 79 | self.write_data(0x2C) 80 | 81 | self.write_cmd(0xC2) 82 | self.write_data(0x01) 83 | 84 | self.write_cmd(0xC3) 85 | self.write_data(0x12) 86 | 87 | self.write_cmd(0xC4) 88 | self.write_data(0x20) 89 | 90 | self.write_cmd(0xC6) 91 | self.write_data(0x0F) 92 | 93 | self.write_cmd(0xD0) 94 | self.write_data(0xA4) 95 | self.write_data(0xA1) 96 | 97 | self.write_cmd(0xE0) 98 | self.write_data(0xD0) 99 | self.write_data(0x04) 100 | self.write_data(0x0D) 101 | self.write_data(0x11) 102 | self.write_data(0x13) 103 | self.write_data(0x2B) 104 | self.write_data(0x3F) 105 | self.write_data(0x54) 106 | self.write_data(0x4C) 107 | self.write_data(0x18) 108 | self.write_data(0x0D) 109 | self.write_data(0x0B) 110 | self.write_data(0x1F) 111 | self.write_data(0x23) 112 | 113 | self.write_cmd(0xE1) 114 | self.write_data(0xD0) 115 | self.write_data(0x04) 116 | self.write_data(0x0C) 117 | self.write_data(0x11) 118 | self.write_data(0x13) 119 | self.write_data(0x2C) 120 | self.write_data(0x3F) 121 | self.write_data(0x44) 122 | self.write_data(0x51) 123 | self.write_data(0x2F) 124 | self.write_data(0x1F) 125 | self.write_data(0x1F) 126 | self.write_data(0x20) 127 | self.write_data(0x23) 128 | 129 | self.write_cmd(0x21) 130 | 131 | self.write_cmd(0x11) 132 | 133 | self.write_cmd(0x29) 134 | 135 | def show(self): 136 | self.write_cmd(0x2A) 137 | self.write_data(0x00) 138 | self.write_data(0x00) 139 | self.write_data(0x01) 140 | self.write_data(0x3f) 141 | 142 | self.write_cmd(0x2B) 143 | self.write_data(0x00) 144 | self.write_data(0x00) 145 | self.write_data(0x00) 146 | self.write_data(0xEF) 147 | 148 | self.write_cmd(0x2C) 149 | 150 | self.cs(1) 151 | self.dc(1) 152 | self.cs(0) 153 | self.spi.write(self.buffer) 154 | self.cs(1) 155 | 156 | 157 | if __name__=='__main__': 158 | pwm = PWM(Pin(BL)) 159 | pwm.freq(1000) 160 | pwm.duty_u16(32768)#max 65535 161 | 162 | LCD = LCD_1inch3() 163 | #color BRG 164 | LCD.fill(LCD.WHITE) 165 | LCD.show() 166 | 167 | 168 | while(1): 169 | time.sleep(0.1) 170 | LCD.fill_rect(0,0,320,24,LCD.RED) 171 | LCD.rect(0,0,320,24,LCD.RED) 172 | LCD.text("Raspberry Pi Pico",2,8,LCD.WHITE) 173 | time.sleep(0.1) 174 | LCD.show() 175 | LCD.fill_rect(0,24,320,24,LCD.BLUE) 176 | LCD.rect(0,24,320,24,LCD.BLUE) 177 | LCD.text("PicoGo",2,32,LCD.WHITE) 178 | time.sleep(0.1) 179 | LCD.show() 180 | LCD.fill_rect(0,48,320,24,LCD.GREEN) 181 | LCD.rect(0,48,320,24,LCD.GREEN) 182 | LCD.text("Pico-LCD-2",2,54,LCD.WHITE) 183 | time.sleep(0.1) 184 | LCD.show() 185 | LCD.fill_rect(0,72,320,24,0X07FF) 186 | LCD.rect(0,72,320,24,0X07FF) 187 | time.sleep(0.1) 188 | LCD.show() 189 | LCD.fill_rect(0,96,320,24,0xF81F) 190 | LCD.rect(0,96,320,24,0xF81F) 191 | time.sleep(0.1) 192 | LCD.show() 193 | LCD.fill_rect(0,120,320,24,0x7FFF) 194 | LCD.rect(0,120,320,24,0x7FFF) 195 | time.sleep(0.1) 196 | LCD.show() 197 | LCD.fill_rect(0,144,320,24,0xFFE0) 198 | LCD.rect(0,144,320,24,0xFFE0) 199 | time.sleep(0.1) 200 | LCD.show() 201 | LCD.fill_rect(0,168,320,24,0XBC40) 202 | LCD.rect(0,168,320,24,0XBC40) 203 | time.sleep(0.1) 204 | LCD.show() 205 | LCD.fill_rect(0,192,320,24,0XFC07) 206 | LCD.rect(0,192,320,24,0XFC07) 207 | time.sleep(0.1) 208 | LCD.show() 209 | LCD.fill_rect(0,216,320,24,0X8430) 210 | LCD.rect(0,216,320,24,0X8430) 211 | time.sleep(0.1) 212 | LCD.show() 213 | LCD.fill(0xFFFF) 214 | time.sleep(0.1) 215 | LCD.show() 216 | time.sleep(1) 217 | LCD.fill(0xFFFF) 218 | 219 | 220 | 221 | 222 | -------------------------------------------------------------------------------- /Python/Pico-LCD-2/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-05-14 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-LCD-2.py查看,这里也再重述一次: 19 | LCD 2 20 | LCD => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | BL -> 13 29 | KEY0 -> 15 30 | KEY1 -> 17 31 | KEY2 -> 2 32 | KEY3 -> 3 33 | 34 | 3.基本使用: 35 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 36 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 37 | 38 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 39 | 40 | 3): 更新Thonny IDE 41 | sudo apt upgrade thonny 42 | 43 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 44 | 选择Tools -> Options... -> Interpreter 45 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 46 | 47 | 5): 在Thonny IDE中打开python/Pico-LCD-2/Pico-LCD-2.py文件 48 | 然后运行当前脚本(绿色小三角)即可 49 | -------------------------------------------------------------------------------- /Python/Pico-LCD-2/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-05-14 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-LCD-2.py, and repeat it here: 20 | LCD 2 21 | LCD => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | BL -> 13 30 | KEY0 -> 15 31 | KEY1 -> 17 32 | KEY2 -> 2 33 | KEY3 -> 3 34 | 35 | 36 | 3. Basic use: 37 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 38 | computer through the Micro USB cable, and then release the button. 39 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 40 | 41 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 42 | removable disk (RPI-RP2) 43 | 44 | 3): Update Thonny IDE 45 | sudo apt upgrade thonny 46 | 47 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 48 | select Tools -> Options... -> Interpreter 49 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 50 | 51 | 5): Open the python/Pico-LCD-2/Pico-LCD-2.py file in Thonny IDE 52 | Then run the current script (green triangle) 53 | -------------------------------------------------------------------------------- /Python/Pico-OLED-1.3/Pico-OLED-1.3(i2c).py: -------------------------------------------------------------------------------- 1 | from machine import Pin,I2C 2 | import framebuf 3 | import time 4 | 5 | RST = 12 6 | class OLED_1inch3(framebuf.FrameBuffer): 7 | def __init__(self): 8 | self.width = 128 9 | self.height = 64 10 | 11 | self.rst = Pin(RST,Pin.OUT) 12 | 13 | self.i2c = I2C(1) 14 | self.i2c = I2C(1,1000_000) 15 | self.i2c = I2C(1, scl=Pin(7), sda=Pin(6), freq=10000_000) 16 | self.temp = bytearray(2) 17 | self.buffer = bytearray(self.height * self.width // 8) 18 | super().__init__(self.buffer, self.width, self.height, framebuf.MONO_HMSB) 19 | self.init_display() 20 | 21 | self.white = 0xffff 22 | self.balck = 0x0000 23 | 24 | def write_cmd(self, cmd): 25 | self.temp[0] = 0x00 26 | self.temp[1] = cmd 27 | self.i2c.writeto(0x3c, self.temp) 28 | 29 | def write_data(self, buf): 30 | self.temp[0] = 0x40 31 | self.temp[1] = buf 32 | self.i2c.writeto(0x3c, self.temp) 33 | 34 | def init_display(self): 35 | """Initialize dispaly""" 36 | 37 | self.rst(1) 38 | time.sleep(0.001) 39 | self.rst(0) 40 | time.sleep(0.01) 41 | self.rst(1) 42 | 43 | self.write_cmd(0xAE)#turn off OLED display 44 | 45 | self.write_cmd(0x00) #set lower column address 46 | self.write_cmd(0x10) #set higher column address 47 | 48 | self.write_cmd(0xB0) #set page address 49 | 50 | self.write_cmd(0xdc) #et display start line 51 | self.write_cmd(0x00) 52 | self.write_cmd(0x81) #contract control 53 | self.write_cmd(0x6f) #128 54 | self.write_cmd(0x21) # Set Memory addressing mode (0x20/0x21) # 55 | 56 | self.write_cmd(0xa0) #set segment remap 57 | self.write_cmd(0xc0) #Com scan direction 58 | self.write_cmd(0xa4) #Disable Entire Display On (0xA4/0xA5) 59 | 60 | self.write_cmd(0xa6) #normal / reverse 61 | self.write_cmd(0xa8) #multiplex ratio 62 | self.write_cmd(0x3f) #duty = 1/64 63 | 64 | self.write_cmd(0xd3) #set display offset 65 | self.write_cmd(0x60) 66 | 67 | self.write_cmd(0xd5) #set osc division 68 | self.write_cmd(0x41) 69 | 70 | self.write_cmd(0xd9) #set pre-charge period 71 | self.write_cmd(0x22) 72 | 73 | self.write_cmd(0xdb) #set vcomh 74 | self.write_cmd(0x35) 75 | 76 | self.write_cmd(0xad) #set charge pump enable 77 | self.write_cmd(0x8a) #Set DC-DC enable (a=0:disable; a=1:enable) 78 | self.write_cmd(0XAF) 79 | def show(self): 80 | self.write_cmd(0xb0) 81 | for page in range(0,64): 82 | self.column = 63 - page 83 | self.write_cmd(0x00 + (self.column & 0x0f)) 84 | self.write_cmd(0x10 + (self.column >> 4)) 85 | for num in range(0,16): 86 | self.write_data(self.buffer[page*16+num]) 87 | 88 | 89 | if __name__=='__main__': 90 | 91 | OLED = OLED_1inch3() 92 | OLED.fill(0x0000) 93 | OLED.show() 94 | OLED.rect(0,0,128,64,OLED.white) 95 | time.sleep(0.5) 96 | OLED.show() 97 | OLED.rect(10,22,20,20,OLED.white) 98 | time.sleep(0.5) 99 | OLED.show() 100 | OLED.fill_rect(40,22,20,20,OLED.white) 101 | time.sleep(0.5) 102 | OLED.show() 103 | OLED.rect(70,22,20,20,OLED.white) 104 | time.sleep(0.5) 105 | OLED.show() 106 | OLED.fill_rect(100,22,20,20,OLED.white) 107 | time.sleep(0.5) 108 | OLED.show() 109 | time.sleep(1) 110 | 111 | OLED.fill(0x0000) 112 | OLED.line(0,0,5,64,OLED.white) 113 | OLED.show() 114 | time.sleep(0.01) 115 | OLED.line(0,0,20,64,OLED.white) 116 | OLED.show() 117 | time.sleep(0.01) 118 | OLED.line(0,0,35,64,OLED.white) 119 | OLED.show() 120 | time.sleep(0.01) 121 | OLED.line(0,0,65,64,OLED.white) 122 | OLED.show() 123 | time.sleep(0.01) 124 | OLED.line(0,0,95,64,OLED.white) 125 | OLED.show() 126 | time.sleep(0.01) 127 | OLED.line(0,0,125,64,OLED.white) 128 | OLED.show() 129 | time.sleep(0.01) 130 | OLED.line(0,0,125,41,OLED.white) 131 | OLED.show() 132 | time.sleep(0.1) 133 | OLED.line(0,0,125,21,OLED.white) 134 | OLED.show() 135 | time.sleep(0.01) 136 | OLED.line(0,0,125,3,OLED.white) 137 | OLED.show() 138 | time.sleep(0.01) 139 | 140 | OLED.line(127,1,125,64,OLED.white) 141 | OLED.show() 142 | time.sleep(0.01) 143 | OLED.line(127,1,110,64,OLED.white) 144 | OLED.show() 145 | time.sleep(0.01) 146 | OLED.line(127,1,95,64,OLED.white) 147 | OLED.show() 148 | time.sleep(0.01) 149 | OLED.line(127,1,65,64,OLED.white) 150 | OLED.show() 151 | time.sleep(0.01) 152 | OLED.line(127,1,35,64,OLED.white) 153 | OLED.show() 154 | time.sleep(0.01) 155 | OLED.line(127,1,1,64,OLED.white) 156 | OLED.show() 157 | time.sleep(0.01) 158 | OLED.line(127,1,1,44,OLED.white) 159 | OLED.show() 160 | time.sleep(0.01) 161 | OLED.line(127,1,1,24,OLED.white) 162 | OLED.show() 163 | time.sleep(0.01) 164 | OLED.line(127,1,1,3,OLED.white) 165 | OLED.show() 166 | time.sleep(1) 167 | OLED.fill(0x0000) 168 | OLED.text("128 x 64 Pixels",1,10,OLED.white) 169 | OLED.text("Pico-OLED-1.3",1,27,OLED.white) 170 | OLED.text("SH1107",1,44,OLED.white) 171 | OLED.show() 172 | 173 | 174 | time.sleep(1) 175 | OLED.fill(0x0000) 176 | keyA = Pin(15,Pin.IN,Pin.PULL_UP) 177 | keyB = Pin(17,Pin.IN,Pin.PULL_UP) 178 | while(1): 179 | if keyA.value() == 0: 180 | OLED.fill_rect(0,0,128,20,OLED.white) 181 | print("A") 182 | else : 183 | OLED.fill_rect(0,0,128,20,OLED.balck) 184 | 185 | 186 | 187 | if(keyB.value() == 0): 188 | OLED.fill_rect(0,44,128,20,OLED.white) 189 | print("B") 190 | else : 191 | OLED.fill_rect(0,44,128,20,OLED.balck) 192 | OLED.fill_rect(0,22,128,20,OLED.white) 193 | OLED.text("press the button",0,28,OLED.balck) 194 | 195 | OLED.show() 196 | 197 | time.sleep(1) 198 | OLED.fill(0xFFFF) 199 | 200 | 201 | 202 | 203 | 204 | 205 | -------------------------------------------------------------------------------- /Python/Pico-OLED-1.3/Pico-OLED-1.3(spi).py: -------------------------------------------------------------------------------- 1 | from machine import Pin,SPI 2 | import framebuf 3 | import time 4 | 5 | DC = 8 6 | RST = 12 7 | MOSI = 11 8 | SCK = 10 9 | CS = 9 10 | 11 | 12 | class OLED_1inch3(framebuf.FrameBuffer): 13 | def __init__(self): 14 | self.width = 128 15 | self.height = 64 16 | 17 | self.cs = Pin(CS,Pin.OUT) 18 | self.rst = Pin(RST,Pin.OUT) 19 | 20 | self.cs(1) 21 | self.spi = SPI(1) 22 | self.spi = SPI(1,2000_000) 23 | self.spi = SPI(1,20000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 24 | self.dc = Pin(DC,Pin.OUT) 25 | self.dc(1) 26 | self.buffer = bytearray(self.height * self.width // 8) 27 | super().__init__(self.buffer, self.width, self.height, framebuf.MONO_HMSB) 28 | self.init_display() 29 | 30 | self.white = 0xffff 31 | self.balck = 0x0000 32 | 33 | def write_cmd(self, cmd): 34 | self.cs(1) 35 | self.dc(0) 36 | self.cs(0) 37 | self.spi.write(bytearray([cmd])) 38 | self.cs(1) 39 | 40 | def write_data(self, buf): 41 | self.cs(1) 42 | self.dc(1) 43 | self.cs(0) 44 | self.spi.write(bytearray([buf])) 45 | self.cs(1) 46 | 47 | def init_display(self): 48 | """Initialize dispaly""" 49 | self.rst(1) 50 | time.sleep(0.001) 51 | self.rst(0) 52 | time.sleep(0.01) 53 | self.rst(1) 54 | 55 | self.write_cmd(0xAE)#turn off OLED display 56 | 57 | self.write_cmd(0x00) #set lower column address 58 | self.write_cmd(0x10) #set higher column address 59 | 60 | self.write_cmd(0xB0) #set page address 61 | 62 | self.write_cmd(0xdc) #et display start line 63 | self.write_cmd(0x00) 64 | self.write_cmd(0x81) #contract control 65 | self.write_cmd(0x6f) #128 66 | self.write_cmd(0x21) # Set Memory addressing mode (0x20/0x21) # 67 | 68 | self.write_cmd(0xa0) #set segment remap 69 | self.write_cmd(0xc0) #Com scan direction 70 | self.write_cmd(0xa4) #Disable Entire Display On (0xA4/0xA5) 71 | 72 | self.write_cmd(0xa6) #normal / reverse 73 | self.write_cmd(0xa8) #multiplex ratio 74 | self.write_cmd(0x3f) #duty = 1/64 75 | 76 | self.write_cmd(0xd3) #set display offset 77 | self.write_cmd(0x60) 78 | 79 | self.write_cmd(0xd5) #set osc division 80 | self.write_cmd(0x41) 81 | 82 | self.write_cmd(0xd9) #set pre-charge period 83 | self.write_cmd(0x22) 84 | 85 | self.write_cmd(0xdb) #set vcomh 86 | self.write_cmd(0x35) 87 | 88 | self.write_cmd(0xad) #set charge pump enable 89 | self.write_cmd(0x8a) #Set DC-DC enable (a=0:disable; a=1:enable) 90 | self.write_cmd(0XAF) 91 | def show(self): 92 | self.write_cmd(0xb0) 93 | for page in range(0,64): 94 | self.column = 63 - page 95 | self.write_cmd(0x00 + (self.column & 0x0f)) 96 | self.write_cmd(0x10 + (self.column >> 4)) 97 | for num in range(0,16): 98 | self.write_data(self.buffer[page*16+num]) 99 | 100 | 101 | if __name__=='__main__': 102 | 103 | OLED = OLED_1inch3() 104 | OLED.fill(0x0000) 105 | OLED.show() 106 | OLED.rect(0,0,128,64,OLED.white) 107 | time.sleep(0.5) 108 | OLED.show() 109 | OLED.rect(10,22,20,20,OLED.white) 110 | time.sleep(0.5) 111 | OLED.show() 112 | OLED.fill_rect(40,22,20,20,OLED.white) 113 | time.sleep(0.5) 114 | OLED.show() 115 | OLED.rect(70,22,20,20,OLED.white) 116 | time.sleep(0.5) 117 | OLED.show() 118 | OLED.fill_rect(100,22,20,20,OLED.white) 119 | time.sleep(0.5) 120 | OLED.show() 121 | time.sleep(1) 122 | 123 | OLED.fill(0x0000) 124 | OLED.line(0,0,5,64,OLED.white) 125 | OLED.show() 126 | time.sleep(0.01) 127 | OLED.line(0,0,20,64,OLED.white) 128 | OLED.show() 129 | time.sleep(0.01) 130 | OLED.line(0,0,35,64,OLED.white) 131 | OLED.show() 132 | time.sleep(0.01) 133 | OLED.line(0,0,65,64,OLED.white) 134 | OLED.show() 135 | time.sleep(0.01) 136 | OLED.line(0,0,95,64,OLED.white) 137 | OLED.show() 138 | time.sleep(0.01) 139 | OLED.line(0,0,125,64,OLED.white) 140 | OLED.show() 141 | time.sleep(0.01) 142 | OLED.line(0,0,125,41,OLED.white) 143 | OLED.show() 144 | time.sleep(0.1) 145 | OLED.line(0,0,125,21,OLED.white) 146 | OLED.show() 147 | time.sleep(0.01) 148 | OLED.line(0,0,125,3,OLED.white) 149 | OLED.show() 150 | time.sleep(0.01) 151 | 152 | OLED.line(127,1,125,64,OLED.white) 153 | OLED.show() 154 | time.sleep(0.01) 155 | OLED.line(127,1,110,64,OLED.white) 156 | OLED.show() 157 | time.sleep(0.01) 158 | OLED.line(127,1,95,64,OLED.white) 159 | OLED.show() 160 | time.sleep(0.01) 161 | OLED.line(127,1,65,64,OLED.white) 162 | OLED.show() 163 | time.sleep(0.01) 164 | OLED.line(127,1,35,64,OLED.white) 165 | OLED.show() 166 | time.sleep(0.01) 167 | OLED.line(127,1,1,64,OLED.white) 168 | OLED.show() 169 | time.sleep(0.01) 170 | OLED.line(127,1,1,44,OLED.white) 171 | OLED.show() 172 | time.sleep(0.01) 173 | OLED.line(127,1,1,24,OLED.white) 174 | OLED.show() 175 | time.sleep(0.01) 176 | OLED.line(127,1,1,3,OLED.white) 177 | OLED.show() 178 | time.sleep(1) 179 | OLED.fill(0x0000) 180 | OLED.text("128 x 64 Pixels",1,10,OLED.white) 181 | OLED.text("Pico-OLED-1.3",1,27,OLED.white) 182 | OLED.text("SH1107",1,44,OLED.white) 183 | OLED.show() 184 | 185 | time.sleep(1) 186 | OLED.fill(0x0000) 187 | keyA = Pin(15,Pin.IN,Pin.PULL_UP) 188 | keyB = Pin(17,Pin.IN,Pin.PULL_UP) 189 | while(1): 190 | if keyA.value() == 0: 191 | OLED.fill_rect(0,0,128,20,OLED.white) 192 | print("A") 193 | else : 194 | OLED.fill_rect(0,0,128,20,OLED.balck) 195 | 196 | 197 | if(keyB.value() == 0): 198 | OLED.fill_rect(0,44,128,20,OLED.white) 199 | print("B") 200 | else : 201 | OLED.fill_rect(0,44,128,20,OLED.balck) 202 | OLED.fill_rect(0,22,128,20,OLED.white) 203 | OLED.text("press the button",0,28,OLED.balck) 204 | 205 | OLED.show() 206 | 207 | 208 | time.sleep(1) 209 | OLED.fill(0xFFFF) 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /Python/Pico-OLED-1.3/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-04-02 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-OLED-1.3(spi).py查看,这里也再重述一次: 19 | OLED 1.3 20 | OLED => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | 29 | 3.基本使用: 30 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 31 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 32 | 33 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 34 | 35 | 3): 更新Thonny IDE 36 | sudo apt upgrade thonny 37 | 38 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 39 | 选择Tools -> Options... -> Interpreter 40 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 41 | 42 | 5): 在Thonny IDE中打开python/Pico-OLED-1.3/Pico-OLED-1.3(spi).py文件 43 | 然后运行当前脚本(绿色小三角)即可 44 | -------------------------------------------------------------------------------- /Python/Pico-OLED-1.3/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-04-02 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-OLED-1.3(spi).py, and repeat it here: 20 | OLED 1.3 21 | OLED => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | 30 | 3. Basic use: 31 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 32 | computer through the Micro USB cable, and then release the button. 33 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 34 | 35 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 36 | removable disk (RPI-RP2) 37 | 38 | 3): Update Thonny IDE 39 | sudo apt upgrade thonny 40 | 41 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 42 | select Tools -> Options... -> Interpreter 43 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 44 | 45 | 5): Open the python/Pico-OLED-1.3/Pico-OLED-1.3(spi).py file in Thonny IDE 46 | Then run the current script (green triangle) 47 | -------------------------------------------------------------------------------- /Python/Pico-OLED-2.23/Pico-OLED-2.23(i2c).py: -------------------------------------------------------------------------------- 1 | from machine import Pin,I2C 2 | import framebuf 3 | import time 4 | 5 | RST = 12 6 | class OLED_2inch23(framebuf.FrameBuffer): 7 | def __init__(self): 8 | self.width = 128 9 | self.height = 32 10 | 11 | self.rst = Pin(RST,Pin.OUT) 12 | 13 | self.i2c = I2C(1) 14 | self.i2c = I2C(1,1000_000) 15 | self.i2c = I2C(1, scl=Pin(7), sda=Pin(6), freq=10000_000) 16 | self.temp = bytearray(2) 17 | self.buffer = bytearray(self.height * self.width // 8) 18 | super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB) 19 | self.init_display() 20 | 21 | self.white = 0xffff 22 | self.balck = 0x0000 23 | 24 | def write_cmd(self, cmd): 25 | self.temp[0] = 0x00 # Co=1, D/C#=0 26 | self.temp[1] = cmd 27 | self.i2c.writeto(0x3c, self.temp) 28 | 29 | def write_data(self, buf): 30 | 31 | self.temp[0] = 0x40 # Co=1, D/C#=0 32 | self.temp[1] = buf 33 | self.i2c.writeto(0x3c, self.temp) 34 | 35 | def init_display(self): 36 | """Initialize dispaly""" 37 | self.rst(1) 38 | time.sleep(0.001) 39 | self.rst(0) 40 | time.sleep(0.01) 41 | self.rst(1) 42 | 43 | self.write_cmd(0xAE)#turn off OLED display*/ 44 | 45 | self.write_cmd(0x04)#turn off OLED display*/ 46 | 47 | self.write_cmd(0x10)#turn off OLED display*/ 48 | 49 | self.write_cmd(0x40)#set lower column address*/ 50 | self.write_cmd(0x81)#set higher column address*/ 51 | self.write_cmd(0x80)#--set start line address Set Mapping RAM Display Start Line (0x00~0x3F, SSD1305_CMD) 52 | self.write_cmd(0xA1)#--set contrast control register 53 | self.write_cmd(0xA6)# Set SEG Output Current Brightness 54 | self.write_cmd(0xA8)#--Set SEG/Column Mapping 55 | self.write_cmd(0x1F)#Set COM/Row Scan Direction 56 | self.write_cmd(0xC8)#--set normal display 57 | self.write_cmd(0xD3)#--set multiplex ratio(1 to 64) 58 | self.write_cmd(0x00)#--1/64 duty 59 | self.write_cmd(0xD5)#-set display offset Shift Mapping RAM Counter (0x00~0x3F) 60 | self.write_cmd(0xF0)#-not offset 61 | self.write_cmd(0xD8) #--set display clock divide ratio/oscillator frequency 62 | self.write_cmd(0x05)#--set divide ratio, Set Clock as 100 Frames/Sec 63 | self.write_cmd(0xD9)#--set pre-charge period 64 | self.write_cmd(0xC2)#Set Pre-Charge as 15 Clocks & Discharge as 1 Clock 65 | self.write_cmd(0xDA) #--set com pins hardware configuration 66 | self.write_cmd(0x12) 67 | self.write_cmd(0xDB) #set vcomh 68 | self.write_cmd(0x08)#Set VCOM Deselect Level 69 | self.write_cmd(0xAF); #-Set Page Addressing Mode (0x00/0x01/0x02) 70 | 71 | def show(self): 72 | for page in range(0,4): 73 | self.write_cmd(0xb0 + page) 74 | self.write_cmd(0x04) 75 | self.write_cmd(0x10) 76 | for num in range(0,128): 77 | self.write_data(self.buffer[page*128+num]) 78 | 79 | 80 | if __name__=='__main__': 81 | 82 | OLED = OLED_2inch23() 83 | OLED.fill(0x0000) 84 | OLED.show() 85 | OLED.rect(0,0,128,32,OLED.white) 86 | OLED.rect(10,6,20,20,OLED.white) 87 | time.sleep(0.5) 88 | OLED.show() 89 | OLED.fill_rect(40,6,20,20,OLED.white) 90 | time.sleep(0.5) 91 | OLED.show() 92 | OLED.rect(70,6,20,20,OLED.white) 93 | time.sleep(0.5) 94 | OLED.show() 95 | OLED.fill_rect(100,6,20,20,OLED.white) 96 | time.sleep(0.5) 97 | OLED.show() 98 | time.sleep(1) 99 | 100 | OLED.fill(0x0000) 101 | OLED.line(0,0,5,31,OLED.white) 102 | OLED.show() 103 | time.sleep(0.01) 104 | OLED.line(0,0,20,31,OLED.white) 105 | OLED.show() 106 | time.sleep(0.01) 107 | OLED.line(0,0,35,31,OLED.white) 108 | OLED.show() 109 | time.sleep(0.01) 110 | OLED.line(0,0,65,31,OLED.white) 111 | OLED.show() 112 | time.sleep(0.01) 113 | OLED.line(0,0,95,31,OLED.white) 114 | OLED.show() 115 | time.sleep(0.01) 116 | OLED.line(0,0,125,31,OLED.white) 117 | OLED.show() 118 | time.sleep(0.01) 119 | OLED.line(0,0,125,21,OLED.white) 120 | OLED.show() 121 | time.sleep(0.1) 122 | OLED.line(0,0,125,11,OLED.white) 123 | OLED.show() 124 | time.sleep(0.01) 125 | OLED.line(0,0,125,3,OLED.white) 126 | OLED.show() 127 | time.sleep(0.01) 128 | 129 | OLED.line(127,1,125,31,OLED.white) 130 | OLED.show() 131 | time.sleep(0.01) 132 | OLED.line(127,1,110,31,OLED.white) 133 | OLED.show() 134 | time.sleep(0.01) 135 | OLED.line(127,1,95,31,OLED.white) 136 | OLED.show() 137 | time.sleep(0.01) 138 | OLED.line(127,1,65,31,OLED.white) 139 | OLED.show() 140 | time.sleep(0.01) 141 | OLED.line(127,1,35,31,OLED.white) 142 | OLED.show() 143 | time.sleep(0.01) 144 | OLED.line(127,1,1,31,OLED.white) 145 | OLED.show() 146 | time.sleep(0.01) 147 | OLED.line(127,1,1,21,OLED.white) 148 | OLED.show() 149 | time.sleep(0.01) 150 | OLED.line(127,1,1,11,OLED.white) 151 | OLED.show() 152 | time.sleep(0.01) 153 | OLED.line(127,1,1,1,OLED.white) 154 | OLED.show() 155 | time.sleep(1) 156 | 157 | OLED.fill(0x0000) 158 | OLED.text("128 x 32 Pixels",1,2,OLED.white) 159 | OLED.text("Pico-OLED-2.23",1,12,OLED.white) 160 | OLED.text("SSD1503",1,22,OLED.white) 161 | OLED.show() 162 | 163 | time.sleep(1) 164 | OLED.fill(0xFFFF) 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /Python/Pico-OLED-2.23/Pico-OLED-2.23(spi).py: -------------------------------------------------------------------------------- 1 | from machine import Pin,SPI 2 | import framebuf 3 | import time 4 | 5 | DC = 8 6 | RST = 12 7 | MOSI = 11 8 | SCK = 10 9 | CS = 9 10 | 11 | 12 | class OLED_2inch23(framebuf.FrameBuffer): 13 | def __init__(self): 14 | self.width = 128 15 | self.height = 32 16 | 17 | self.cs = Pin(CS,Pin.OUT) 18 | self.rst = Pin(RST,Pin.OUT) 19 | 20 | self.cs(1) 21 | self.spi = SPI(1) 22 | self.spi = SPI(1,1000_000) 23 | self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None) 24 | self.dc = Pin(DC,Pin.OUT) 25 | self.dc(1) 26 | self.buffer = bytearray(self.height * self.width // 8) 27 | super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB) 28 | self.init_display() 29 | 30 | self.white = 0xffff 31 | self.balck = 0x0000 32 | 33 | def write_cmd(self, cmd): 34 | self.cs(1) 35 | self.dc(0) 36 | self.cs(0) 37 | self.spi.write(bytearray([cmd])) 38 | self.cs(1) 39 | 40 | def write_data(self, buf): 41 | self.cs(1) 42 | self.dc(1) 43 | self.cs(0) 44 | self.spi.write(bytearray([buf])) 45 | self.cs(1) 46 | 47 | def init_display(self): 48 | """Initialize dispaly""" 49 | self.rst(1) 50 | time.sleep(0.001) 51 | self.rst(0) 52 | time.sleep(0.01) 53 | self.rst(1) 54 | 55 | self.write_cmd(0xAE)#turn off OLED display*/ 56 | 57 | self.write_cmd(0x04)#turn off OLED display*/ 58 | 59 | self.write_cmd(0x10)#turn off OLED display*/ 60 | 61 | self.write_cmd(0x40)#set lower column address*/ 62 | self.write_cmd(0x81)#set higher column address*/ 63 | self.write_cmd(0x80)#--set start line address Set Mapping RAM Display Start Line (0x00~0x3F, SSD1305_CMD) 64 | self.write_cmd(0xA1)#--set contrast control register 65 | self.write_cmd(0xA6)# Set SEG Output Current Brightness 66 | self.write_cmd(0xA8)#--Set SEG/Column Mapping 67 | self.write_cmd(0x1F)#Set COM/Row Scan Direction 68 | self.write_cmd(0xC8)#--set normal display 69 | self.write_cmd(0xD3)#--set multiplex ratio(1 to 64) 70 | self.write_cmd(0x00)#--1/64 duty 71 | self.write_cmd(0xD5)#-set display offset Shift Mapping RAM Counter (0x00~0x3F) 72 | self.write_cmd(0xF0)#-not offset 73 | self.write_cmd(0xD8) #--set display clock divide ratio/oscillator frequency 74 | self.write_cmd(0x05)#--set divide ratio, Set Clock as 100 Frames/Sec 75 | self.write_cmd(0xD9)#--set pre-charge period 76 | self.write_cmd(0xC2)#Set Pre-Charge as 15 Clocks & Discharge as 1 Clock 77 | self.write_cmd(0xDA) #--set com pins hardware configuration 78 | self.write_cmd(0x12) 79 | self.write_cmd(0xDB) #set vcomh 80 | self.write_cmd(0x08)#Set VCOM Deselect Level 81 | self.write_cmd(0xAF); #-Set Page Addressing Mode (0x00/0x01/0x02) 82 | 83 | def show(self): 84 | for page in range(0,4): 85 | self.write_cmd(0xb0 + page) 86 | self.write_cmd(0x04) 87 | self.write_cmd(0x10) 88 | self.dc(1) 89 | for num in range(0,128): 90 | self.write_data(self.buffer[page*128+num]) 91 | 92 | 93 | if __name__=='__main__': 94 | 95 | OLED = OLED_2inch23() 96 | OLED.fill(0x0000) 97 | OLED.show() 98 | OLED.rect(0,0,128,32,OLED.white) 99 | OLED.rect(10,6,20,20,OLED.white) 100 | time.sleep(0.5) 101 | OLED.show() 102 | OLED.fill_rect(40,6,20,20,OLED.white) 103 | time.sleep(0.5) 104 | OLED.show() 105 | OLED.rect(70,6,20,20,OLED.white) 106 | time.sleep(0.5) 107 | OLED.show() 108 | OLED.fill_rect(100,6,20,20,OLED.white) 109 | time.sleep(0.5) 110 | OLED.show() 111 | time.sleep(1) 112 | 113 | OLED.fill(0x0000) 114 | OLED.line(0,0,5,31,OLED.white) 115 | OLED.show() 116 | time.sleep(0.01) 117 | OLED.line(0,0,20,31,OLED.white) 118 | OLED.show() 119 | time.sleep(0.01) 120 | OLED.line(0,0,35,31,OLED.white) 121 | OLED.show() 122 | time.sleep(0.01) 123 | OLED.line(0,0,65,31,OLED.white) 124 | OLED.show() 125 | time.sleep(0.01) 126 | OLED.line(0,0,95,31,OLED.white) 127 | OLED.show() 128 | time.sleep(0.01) 129 | OLED.line(0,0,125,31,OLED.white) 130 | OLED.show() 131 | time.sleep(0.01) 132 | OLED.line(0,0,125,21,OLED.white) 133 | OLED.show() 134 | time.sleep(0.1) 135 | OLED.line(0,0,125,11,OLED.white) 136 | OLED.show() 137 | time.sleep(0.01) 138 | OLED.line(0,0,125,3,OLED.white) 139 | OLED.show() 140 | time.sleep(0.01) 141 | 142 | OLED.line(127,1,125,31,OLED.white) 143 | OLED.show() 144 | time.sleep(0.01) 145 | OLED.line(127,1,110,31,OLED.white) 146 | OLED.show() 147 | time.sleep(0.01) 148 | OLED.line(127,1,95,31,OLED.white) 149 | OLED.show() 150 | time.sleep(0.01) 151 | OLED.line(127,1,65,31,OLED.white) 152 | OLED.show() 153 | time.sleep(0.01) 154 | OLED.line(127,1,35,31,OLED.white) 155 | OLED.show() 156 | time.sleep(0.01) 157 | OLED.line(127,1,1,31,OLED.white) 158 | OLED.show() 159 | time.sleep(0.01) 160 | OLED.line(127,1,1,21,OLED.white) 161 | OLED.show() 162 | time.sleep(0.01) 163 | OLED.line(127,1,1,11,OLED.white) 164 | OLED.show() 165 | time.sleep(0.01) 166 | OLED.line(127,1,1,1,OLED.white) 167 | OLED.show() 168 | time.sleep(1) 169 | 170 | OLED.fill(0x0000) 171 | OLED.text("128 x 32 Pixels",1,2,OLED.white) 172 | OLED.text("Pico-OLED-2.23",1,12,OLED.white) 173 | OLED.text("SSD1503",1,22,OLED.white) 174 | OLED.show() 175 | 176 | time.sleep(1) 177 | OLED.fill(0xFFFF) 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /Python/Pico-OLED-2.23/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-04-01 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 在这里简略的描述本工程的使用: 13 | 14 | 1.基本信息: 15 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的中查看对应的测试例程; 16 | 17 | 2.管脚连接: 18 | 管脚连接你可以在Pico-OLED-2.23(spi).py查看,这里也再重述一次: 19 | OLED 2.23 20 | OLED => Pico 21 | VCC -> VSYS 22 | GND -> GND 23 | DIN -> 11 24 | CLK -> 10 25 | CS -> 9 26 | DC -> 8 27 | RST -> 12 28 | 29 | SDA -> 6 30 | SCL -> 7 31 | 32 | 3.基本使用: 33 | 1): 按住Pico板上的按键,将pico通过Micro USB线接到电脑的USB接口,然后松开按键。 34 | 接入之后,电脑会自动识别到一个可移动盘(RPI-RP2) 35 | 36 | 2): 将python目录中pico_micropython_20210121.uf2 文件复制到识别的可移动盘(RPI-RP2)中 37 | 38 | 3): 更新Thonny IDE 39 | sudo apt upgrade thonny 40 | 41 | 4): 打开Thonny IDE (点击树莓logo -> Programming -> Thonny Python IDE ) 42 | 选择Tools -> Options... -> Interpreter 43 | 选择MicroPython(Raspberry Pi Pico 和ttyACM0端口 44 | 45 | 5): 在Thonny IDE中打开python/Pico-OLED-2.23/Pico-OLED-2.23(spi).py文件 46 | 然后运行当前脚本(绿色小三角)即可 47 | -------------------------------------------------------------------------------- /Python/Pico-OLED-2.23/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-04-01 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Here is a brief description of the use of this project: 13 | 14 | 1. Basic information: 15 | This routine has been verified using the corresponding module with Pico, 16 | you can view the corresponding test routine in the project; 17 | 18 | 2. Pin connection: 19 | You can check the pin connection at Pico-OLED-2.23(spi).py, and repeat it here: 20 | OLED 2.23 21 | OLED => Pico 22 | VCC -> VSYS 23 | GND -> GND 24 | DIN -> 11 25 | CLK -> 10 26 | CS -> 9 27 | DC -> 8 28 | RST -> 12 29 | 30 | SDA -> 6 31 | SCL -> 7 32 | 33 | 3. Basic use: 34 | 1): Press and hold the button on the Pico board, connect Pico to the USB port of the 35 | computer through the Micro USB cable, and then release the button. 36 | After connecting, the computer will automatically recognize a removable disk (RPI-RP2) 37 | 38 | 2): Copy the pico_micropython_20210121.uf2 file in the python directory to the recognized 39 | removable disk (RPI-RP2) 40 | 41 | 3): Update Thonny IDE 42 | sudo apt upgrade thonny 43 | 44 | 4): Open Thonny IDE (Click raspberry logo -> Programming -> Thonny Python IDE ) 45 | select Tools -> Options... -> Interpreter 46 | select MicroPython(Raspberry Pi Pico and ttyACM0 port 47 | 48 | 5): Open the python/Pico-OLED-2.23/Pico-OLED-2.23(spi).py file in Thonny IDE 49 | Then run the current script (green triangle) 50 | -------------------------------------------------------------------------------- /Python/Readme.txt: -------------------------------------------------------------------------------- 1 | 20210316:Add Pico-LCD-1.14 example 2 | 20210316:Add Pico-LCD-1.44 example 3 | 20210316:Add Pico-LCD-1.8 example 4 | 20210401:Add Pico-LCD-1.3 example 5 | 20210401:Add Pico-OLED-2.23 example 6 | 20210402:Add Pico-OLED-1.3 example 7 | -------------------------------------------------------------------------------- /Python/pico_micropython_20210121.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/Python/pico_micropython_20210121.uf2 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pico_code 2 | 3 | ## waveshare electronics 4 | ![waveshare_logo.png](waveshare_logo.png) 5 | 6 | ## 中文: 7 | 微雪电子 Pico-LCD/OLED 系列驱动代码,支持C和Python 8 | 9 | 更多资料请在官网搜索相关产品: 10 | > https://www.waveshare.net or https://www.waveshare.net/wiki 11 | *** 12 | ## English: 13 | Waveshrae Pico-LCD/OLED series drivers code, Support C and Python. 14 | 15 | For more information, please search on the official website: 16 | > https://www.waveshare.com or https://www.waveshare.com/wiki/Main_Page -------------------------------------------------------------------------------- /c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | include(pico_sdk_import.cmake) 3 | project(Pico_ePaper_Code) 4 | pico_sdk_init() 5 | 6 | #添加编译子目录 7 | add_subdirectory(lib/Config) 8 | add_subdirectory(lib/Infrared) 9 | add_subdirectory(lib/OLED) 10 | add_subdirectory(lib/Icm20948) 11 | add_subdirectory(lib/LCD) 12 | add_subdirectory(lib/Fonts) 13 | add_subdirectory(lib/GUI) 14 | add_subdirectory(examples) 15 | 16 | 17 | 18 | #添加头文件目录 19 | include_directories(examples) 20 | include_directories(./lib/Config) 21 | include_directories(./lib/GUI) 22 | include_directories(./lib/Icm20948) 23 | include_directories(./lib/LCD) 24 | include_directories(./lib/Infrared) 25 | include_directories(./lib/OLED) 26 | 27 | 28 | # 生成可执行文件 29 | add_executable(main 30 | main.c 31 | ) 32 | 33 | # enable usb output, disable uart output 34 | pico_enable_stdio_usb(main 1) 35 | pico_enable_stdio_uart(main 1) 36 | 37 | # create map/bin/hex/uf2 file etc. 38 | pico_add_extra_outputs(main) 39 | 40 | target_link_libraries(main examples LCD OLED Infrared Icm20948 GUI Fonts Config pico_stdlib hardware_spi) -------------------------------------------------------------------------------- /c/ReadmeCN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_CN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-02-04 9 | * | Info : 在这里提供一个中文版本的使用文档,以便你的快速使用 10 | ******************************************************************************/ 11 | 这个文件是帮助您使用本例程。 12 | 由于我们的LCD越来越多,不便于我们的维护,因此把所有的LCD程序做成一个工程。 13 | 在这里简略的描述本工程的使用: 14 | 15 | 1.基本信息: 16 | 本例程使用相对应的模块搭配Pico进行了验证,你可以在工程的examples\中查看对应的测试例程; 17 | 18 | 2.管脚连接: 19 | 20 | 管脚连接你可以在\lib\Config目录下查看DEV_Config.c/h中查看,这里也再重述一次: 21 | LCD 1.14 22 | LCD => Pico 23 | VCC -> VSYS 24 | GND -> GND 25 | DIN -> 11 26 | CLK -> 10 27 | CS -> 9 28 | DC -> 8 29 | RST -> 12 30 | BL -> 13 31 | 32 | 33 | LCD 1.3 34 | LCD => Pico 35 | VCC -> VSYS 36 | GND -> GND 37 | DIN -> 11 38 | CLK -> 10 39 | CS -> 9 40 | DC -> 8 41 | RST -> 12 42 | BL -> 13 43 | A -> 15 44 | B -> 17 45 | X -> 19 46 | Y -> 21 47 | UP -> 2 48 | DOWM -> 18 49 | LEFT -> 16 50 | RIGHT -> 20 51 | CTRL -> 3 52 | 53 | 54 | OLED 1.3 55 | OLED => Pico 56 | VCC -> VSYS 57 | GND -> GND 58 | DIN -> 11 59 | CLK -> 10 60 | CS -> 9 61 | DC -> 8 62 | RST -> 12 63 | 64 | LCD 1.44 65 | LCD => Pico 66 | VCC -> VSYS 67 | GND -> GND 68 | DIN -> 11 69 | CLK -> 10 70 | CS -> 9 71 | DC -> 8 72 | RST -> 12 73 | BL -> 13 74 | 75 | LCD 1.8 76 | LCD => Pico 77 | VCC -> VSYS 78 | GND -> GND 79 | DIN -> 11 80 | CLK -> 10 81 | CS -> 9 82 | DC -> 8 83 | RST -> 12 84 | BL -> 13 85 | 86 | OLED 2.23 87 | OLED => Pico 88 | VCC -> VSYS 89 | GND -> GND 90 | DIN -> 11 91 | CLK -> 10 92 | CS -> 9 93 | DC -> 8 94 | RST -> 12 95 | SDA -> 6 96 | SCL -> 7 97 | 98 | LCD 2 99 | LCD => Pico 100 | VCC -> VSYS 101 | GND -> GND 102 | DIN -> 11 103 | CLK -> 10 104 | CS -> 9 105 | DC -> 8 106 | RST -> 12 107 | BL -> 13 108 | KEY0 -> 15 109 | KEY1 -> 17 110 | KEY2 -> 2 111 | KEY3 -> 3 112 | 3.基本使用: 113 | 你需要执行: 114 | 如果目录已经存在,则可以直接进入。 如果没有目录,执行: 115 | mkdir build 116 | 进入目录,并添加SDK: 117 | cd build 118 | export PICO_SDK_PATH=../../pico-sdk 119 | 其中 ../../pico-sdk 是你的SDK的目录。 120 | 执行cmake,自动生成Makefile文件: 121 | cmake .. 122 | 执行make生成可执行文件,然后在终端中输入: 123 | make 124 | 编译好的uf2文件复制到pico中即可 125 | 126 | 4.目录结构(选读): 127 | 如果你经常使用我们的产品,对我们的程序目录结构会十分熟悉,关于具体的函数的我们有一份 128 | 函数的API手册,你可以在我们的WIKI上下载或像售后客服索取,这里简单介绍一次: 129 | \lib\Config\:此目录为硬件接口层文件,在DEV_Config.c(.h)可以看到很多定义,包括: 130 | 数据类型; 131 | GPIO; 132 | 读写GPIO; 133 | 延时:注意:此延时函数并未使用示波器测量具体数值,因此会不准; 134 | 模块初始化与退出的处理: 135 | void DEV_Module_Init(void); 136 | void DEV_Module_Exit(void); 137 | 138 | 139 | \lib\GUI\:此目录为一些基本的图像处理函数,在GUI_Paint.c(.h)中: 140 | 常用图像处理:创建图形、翻转图形、镜像图形、设置像素点、清屏等; 141 | 常用画图处理:画点、线、框、圆、中文字符、英文字符、数字等; 142 | 常用时间显示:提供一个常用的显示时间函数; 143 | 常用显示图片:提供一个显示图片的函数; 144 | 145 | \lib\Fonts\:为一些常用的字体: 146 | Ascii: 147 | font8: 5*8 148 | font12: 7*12 149 | font16: 11*16 150 | font20: 14*20 151 | font24: 17*24 152 | 中文: 153 | font12CN: 16*21 154 | font24CN: 32*41 155 | 156 | \lib\e-paper\:此目录下为LCD驱动函数; 157 | examples\:此目录下为LCD的测试程序,你可在其中看到具体的使用方法; -------------------------------------------------------------------------------- /c/ReadmeEN.txt: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Readme_EN.txt 3 | * | Author : 4 | * | Function : Help with use 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-02-04 9 | * | Info : Here is an English version of the documentation for your quick use. 10 | ******************************************************************************/ 11 | This file is to help you use this routine. 12 | Since our ink screens are getting more and more, it is not convenient for our maintenance, so all the ink screen programs are made into one project. 13 | A brief description of the use of this project is here: 14 | 15 | 1. Basic information: 16 | This routine is verified using the corresponding module with the PICO. 17 | You can see the corresponding test routine in the examples\ of the project. 18 | 19 | 2. Pin connection: 20 | Pin connection You can look at dev_config.c/h in \lib\Config. Again, here: 21 | LCD 1.14 22 | LCD => Pico 23 | VCC -> VSYS 24 | GND -> GND 25 | DIN -> 11 26 | CLK -> 10 27 | CS -> 9 28 | DC -> 8 29 | RST -> 12 30 | BL -> 13 31 | 32 | LCD 1.3 33 | LCD => Pico 34 | VCC -> VSYS 35 | GND -> GND 36 | DIN -> 11 37 | CLK -> 10 38 | CS -> 9 39 | DC -> 8 40 | RST -> 12 41 | BL -> 13 42 | A -> 15 43 | B -> 17 44 | X -> 19 45 | Y -> 21 46 | UP -> 2 47 | DOWM -> 18 48 | LEFT -> 16 49 | RIGHT -> 20 50 | CTRL -> 3 51 | 52 | 53 | OLED 1.3 54 | OLED => Pico 55 | VCC -> VSYS 56 | GND -> GND 57 | DIN -> 11 58 | CLK -> 10 59 | CS -> 9 60 | DC -> 8 61 | RST -> 12 62 | 63 | LCD 1.44 64 | LCD => Pico 65 | VCC -> VSYS 66 | GND -> GND 67 | DIN -> 11 68 | CLK -> 10 69 | CS -> 9 70 | DC -> 8 71 | RST -> 12 72 | BL -> 13 73 | 74 | LCD 1.8 75 | LCD => Pico 76 | VCC -> VSYS 77 | GND -> GND 78 | DIN -> 11 79 | CLK -> 10 80 | CS -> 9 81 | DC -> 8 82 | RST -> 12 83 | BL -> 13 84 | 85 | OLED 2.23 86 | OLED => Pico 87 | VCC -> VSYS 88 | GND -> GND 89 | DIN -> 11 90 | CLK -> 10 91 | CS -> 9 92 | DC -> 8 93 | RST -> 12 94 | SDA -> 6 95 | SCL -> 7 96 | 97 | LCD 2 98 | LCD => Pico 99 | VCC -> VSYS 100 | GND -> GND 101 | DIN -> 11 102 | CLK -> 10 103 | CS -> 9 104 | DC -> 8 105 | RST -> 12 106 | BL -> 13 107 | KEY0 -> 15 108 | KEY1 -> 17 109 | KEY2 -> 2 110 | KEY3 -> 3 111 | 3. Basic use: 112 | You need to execute: 113 | If the directory already exists, you can go directly. If there is no build directory, execute 114 | mkdir build 115 | Enter the build directory and type in the terminal: 116 | cd build 117 | export PICO_SDK_PATH=../../pico-sdk 118 | Where ../../pico-sdk is your installed SDK directory 119 | Execute cmake, automatically generate Makefile file, enter in the terminal: 120 | cmake .. 121 | Execute make to generate an executable file, and enter in the terminal: 122 | make 123 | Copy the compiled uf2 file to pico 124 | 125 | 4. Directory structure (selection): 126 | 127 | If you use our products frequently, we will be very familiar with our program directory structure. We have a copy of the specific function. 128 | The API manual for the function, you can download it on our WIKI or request it as an after-sales customer service. Here is a brief introduction: 129 | Config\: This directory is a hardware interface layer file. You can see many definitions in DEV_Config.c(.h), including: 130 | type of data; 131 | GPIO; 132 | Read and write GPIO; 133 | Delay: Note: This delay function does not use an oscilloscope to measure specific values. 134 | Module Init and exit processing: 135 | void DEV_Module_Init(void); 136 | void DEV_Module_Exit(void); 137 | 138 | \lib\GUI\: This directory is some basic image processing functions, in GUI_Paint.c(.h): 139 | Common image processing: creating graphics, flipping graphics, mirroring graphics, setting pixels, clearing screens, etc. 140 | Common drawing processing: drawing points, lines, boxes, circles, Chinese characters, English characters, numbers, etc.; 141 | Common time display: Provide a common display time function; 142 | Commonly used display pictures: provide a function to display bitmaps; 143 | 144 | \lib\Fonts\: for some commonly used fonts: 145 | Ascii: 146 | Font8: 5*8 147 | Font12: 7*12 148 | Font16: 11*16 149 | Font20: 14*20 150 | Font24: 17*24 151 | Chinese: 152 | font12CN: 16*21 153 | font24CN: 32*41 154 | 155 | \lib\e-paper\: This directory is the LCD driver function; 156 | examples\: This directory is the test program of LCD, you can see the specific usage method in it; -------------------------------------------------------------------------------- /c/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_examples_SRCS 变量 3 | aux_source_directory(. DIR_examples_SRCS) 4 | 5 | include_directories(../lib/Config) 6 | include_directories(../lib/GUI) 7 | include_directories(../lib/Infrared) 8 | include_directories(../lib/LCD) 9 | include_directories(../lib/Icm20948) 10 | include_directories(../lib/OLED) 11 | 12 | # 生成链接库 13 | add_library(examples ${DIR_examples_SRCS}) 14 | target_link_libraries(examples PUBLIC Config LCD Infrared OLED Icm20948) -------------------------------------------------------------------------------- /c/examples/EPD_Test.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : EPD_Test.h 3 | * | Author : 4 | * | Function : test Demo 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documnetation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in 19 | # all copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | # THE SOFTWARE. 28 | # 29 | ******************************************************************************/ 30 | #ifndef _EPD_TEST_H_ 31 | #define _EPD_TEST_H_ 32 | 33 | #include "DEV_Config.h" 34 | #include "GUI_Paint.h" 35 | #include "ImageData.h" 36 | #include "Debug.h" 37 | #include // malloc() free() 38 | 39 | #include "Infrared.h" 40 | 41 | int OLED_1in3_C_test(void); 42 | int OLED_2in23_test(void); 43 | 44 | int LCD_0in96_test(void); 45 | int LCD_1in14_test(void); 46 | int LCD_1in44_test(void); 47 | void LCD_1IN54_test(void); 48 | int LCD_1in8_test(void); 49 | int LCD_1in3_test(void); 50 | int LCD_2in_test(void); 51 | #endif 52 | -------------------------------------------------------------------------------- /c/examples/ImageData.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : ImageData.h 3 | * | Author : 4 | * | Function : test Demo 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documnetation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of the Software, and to permit persons to whom the Software is 16 | # furished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in 19 | # all copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | # THE SOFTWARE. 28 | ******************************************************************************/ 29 | 30 | #ifndef _IMAGEDATA_H_ 31 | #define _IMAGEDATA_H_ 32 | 33 | extern const unsigned char Signal816[]; 34 | extern const unsigned char Msg816[]; 35 | extern const unsigned char Bat816[]; 36 | extern const unsigned char Bluetooth88[]; 37 | extern const unsigned char GPRS88[]; 38 | extern const unsigned char Alarm88[]; 39 | 40 | extern const unsigned char gImage_0inch96_1[]; 41 | extern const unsigned char gImage_1inch14_1[]; 42 | extern const unsigned char gImage_1inch3_C_1[]; 43 | extern const unsigned char gImage_1inch44_1[]; 44 | extern const unsigned char gImage_1inch8_1[]; 45 | extern const unsigned char gImage_1inch3_1[]; 46 | extern const unsigned char gImage_2inch_1[]; 47 | #endif 48 | /* FILE END */ 49 | 50 | 51 | -------------------------------------------------------------------------------- /c/examples/LCD_0in96_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/LCD_0in96_test.c -------------------------------------------------------------------------------- /c/examples/LCD_1in14_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/LCD_1in14_test.c -------------------------------------------------------------------------------- /c/examples/LCD_1in3_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/LCD_1in3_test.c -------------------------------------------------------------------------------- /c/examples/LCD_1in44_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/LCD_1in44_test.c -------------------------------------------------------------------------------- /c/examples/LCD_1in8_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/LCD_1in8_test.c -------------------------------------------------------------------------------- /c/examples/LCD_2in_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/LCD_2in_test.c -------------------------------------------------------------------------------- /c/examples/OLED_1in3_C_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/OLED_1in3_C_test.c -------------------------------------------------------------------------------- /c/examples/OLED_2in23_test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/examples/OLED_2in23_test.c -------------------------------------------------------------------------------- /c/lib/.LCD.c.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/lib/.LCD.c.swp -------------------------------------------------------------------------------- /c/lib/Config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_Config_SRCS 变量 3 | aux_source_directory(. DIR_Config_SRCS) 4 | 5 | # 生成链接库 6 | add_library(Config ${DIR_Config_SRCS}) 7 | target_link_libraries(Config PUBLIC pico_stdlib hardware_spi hardware_i2c hardware_pwm hardware_adc) -------------------------------------------------------------------------------- /c/lib/Config/DEV_Config.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : DEV_Config.c 3 | * | Author : 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documnetation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of theex Software, and to permit persons to whom the Software is 16 | # furished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in 19 | # all copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | # THE SOFTWARE. 28 | ******************************************************************************/ 29 | #include "DEV_Config.h" 30 | 31 | #define SPI_PORT spi1 32 | #define I2C_PORT spi1 33 | 34 | /** 35 | * GPIO 36 | **/ 37 | int EPD_RST_PIN; 38 | int EPD_DC_PIN; 39 | int EPD_CS_PIN; 40 | int EPD_BL_PIN; 41 | int EPD_CLK_PIN; 42 | int EPD_MOSI_PIN; 43 | int EPD_SCL_PIN; 44 | int EPD_SDA_PIN; 45 | 46 | 47 | uint slice_num; 48 | /** 49 | * GPIO read and write 50 | **/ 51 | void DEV_Digital_Write(UWORD Pin, UBYTE Value) 52 | { 53 | gpio_put(Pin, Value); 54 | } 55 | 56 | UBYTE DEV_Digital_Read(UWORD Pin) 57 | { 58 | return gpio_get(Pin); 59 | } 60 | 61 | /** 62 | * SPI 63 | **/ 64 | void DEV_SPI_WriteByte(uint8_t Value) 65 | { 66 | spi_write_blocking(SPI_PORT, &Value, 1); 67 | } 68 | 69 | void DEV_SPI_Write_nByte(uint8_t pData[], uint32_t Len) 70 | { 71 | spi_write_blocking(SPI_PORT, pData, Len); 72 | } 73 | 74 | 75 | 76 | /** 77 | * I2C 78 | **/ 79 | 80 | void DEV_I2C_Write(uint8_t addr, uint8_t reg, uint8_t Value) 81 | { 82 | uint8_t data[2] = {reg, Value}; 83 | i2c_write_blocking(i2c1, addr, data, 2, false); 84 | } 85 | 86 | void DEV_I2C_Write_nByte(uint8_t addr, uint8_t *pData, uint32_t Len) 87 | { 88 | i2c_write_blocking(i2c1, addr, pData, Len, false); 89 | } 90 | 91 | uint8_t DEV_I2C_ReadByte(uint8_t addr, uint8_t reg) 92 | { 93 | uint8_t buf; 94 | i2c_write_blocking(i2c1,addr,®,1,true); 95 | i2c_read_blocking(i2c1,addr,&buf,1,false); 96 | return buf; 97 | } 98 | 99 | /** 100 | * GPIO Mode 101 | **/ 102 | void DEV_GPIO_Mode(UWORD Pin, UWORD Mode) 103 | { 104 | gpio_init(Pin); 105 | if(Mode == 0 || Mode == GPIO_IN) { 106 | gpio_set_dir(Pin, GPIO_IN); 107 | } else { 108 | gpio_set_dir(Pin, GPIO_OUT); 109 | } 110 | } 111 | 112 | /** 113 | * KEY Config 114 | **/ 115 | void DEV_KEY_Config(UWORD Pin) 116 | { 117 | gpio_init(Pin); 118 | gpio_pull_up(Pin); 119 | gpio_set_dir(Pin, GPIO_IN); 120 | } 121 | 122 | /** 123 | * delay x ms 124 | **/ 125 | void DEV_Delay_ms(UDOUBLE xms) 126 | { 127 | sleep_ms(xms); 128 | } 129 | 130 | void DEV_Delay_us(UDOUBLE xus) 131 | { 132 | sleep_us(xus); 133 | } 134 | 135 | 136 | 137 | void DEV_GPIO_Init(void) 138 | { 139 | DEV_GPIO_Mode(EPD_RST_PIN, 1); 140 | DEV_GPIO_Mode(EPD_DC_PIN, 1); 141 | DEV_GPIO_Mode(EPD_CS_PIN, 1); 142 | DEV_GPIO_Mode(EPD_BL_PIN, 1); 143 | 144 | 145 | DEV_GPIO_Mode(EPD_CS_PIN, 1); 146 | DEV_GPIO_Mode(EPD_BL_PIN, 1); 147 | 148 | DEV_Digital_Write(EPD_CS_PIN, 1); 149 | DEV_Digital_Write(EPD_DC_PIN, 0); 150 | DEV_Digital_Write(EPD_BL_PIN, 1); 151 | } 152 | /****************************************************************************** 153 | function: Module Initialize, the library and initialize the pins, SPI protocol 154 | parameter: 155 | Info: 156 | ******************************************************************************/ 157 | UBYTE DEV_Module_Init(void) 158 | { 159 | stdio_init_all(); 160 | 161 | //GPIO PIN 162 | EPD_RST_PIN = 12; 163 | EPD_DC_PIN = 8; 164 | EPD_BL_PIN = 13; 165 | 166 | EPD_CS_PIN = 9; 167 | EPD_CLK_PIN = 10; 168 | EPD_MOSI_PIN = 11; 169 | 170 | EPD_SCL_PIN = 7; 171 | EPD_SDA_PIN = 6; 172 | 173 | // SPI Config 174 | spi_init(SPI_PORT, 10000 * 1000); 175 | gpio_set_function(EPD_CLK_PIN, GPIO_FUNC_SPI); 176 | gpio_set_function(EPD_MOSI_PIN, GPIO_FUNC_SPI); 177 | 178 | // GPIO Config 179 | DEV_GPIO_Init(); 180 | 181 | 182 | // PWM Config 183 | gpio_set_function(EPD_BL_PIN, GPIO_FUNC_PWM); 184 | slice_num = pwm_gpio_to_slice_num(EPD_BL_PIN); 185 | pwm_set_wrap(slice_num, 100); 186 | pwm_set_chan_level(slice_num, PWM_CHAN_B, 1); 187 | pwm_set_clkdiv(slice_num,50); 188 | pwm_set_enabled(slice_num, true); 189 | 190 | 191 | //I2C Config 192 | i2c_init(i2c1,300*1000); 193 | gpio_set_function(EPD_SDA_PIN,GPIO_FUNC_I2C); 194 | gpio_set_function(EPD_SCL_PIN,GPIO_FUNC_I2C); 195 | gpio_pull_up(EPD_SDA_PIN); 196 | gpio_pull_up(EPD_SCL_PIN); 197 | 198 | printf("DEV_Module_Init OK \r\n"); 199 | return 0; 200 | } 201 | 202 | void DEV_SET_PWM(uint8_t Value){ 203 | if(Value<0 || Value >100){ 204 | printf("DEV_SET_PWM Error \r\n"); 205 | }else { 206 | pwm_set_chan_level(slice_num, PWM_CHAN_B, Value); 207 | } 208 | 209 | 210 | 211 | } 212 | 213 | /****************************************************************************** 214 | function: Module exits, closes SPI and BCM2835 library 215 | parameter: 216 | Info: 217 | ******************************************************************************/ 218 | void DEV_Module_Exit(void) 219 | { 220 | 221 | } 222 | -------------------------------------------------------------------------------- /c/lib/Config/DEV_Config.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : DEV_Config.h 3 | * | Author : 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy 12 | # of this software and associated documnetation files (the "Software"), to deal 13 | # in the Software without restriction, including without limitation the rights 14 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | # copies of theex Software, and to permit persons to whom the Software is 16 | # furished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in 19 | # all copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | # THE SOFTWARE. 28 | ******************************************************************************/ 29 | #ifndef _DEV_CONFIG_H_ 30 | #define _DEV_CONFIG_H_ 31 | 32 | #include "pico/stdlib.h" 33 | #include "hardware/spi.h" 34 | #include "stdio.h" 35 | #include "hardware/i2c.h" 36 | #include "hardware/pwm.h" 37 | 38 | /** 39 | * data 40 | **/ 41 | #define UBYTE uint8_t 42 | #define UWORD uint16_t 43 | #define UDOUBLE uint32_t 44 | 45 | /** 46 | * GPIOI config 47 | **/ 48 | extern int EPD_RST_PIN; 49 | extern int EPD_DC_PIN; 50 | extern int EPD_CS_PIN; 51 | extern int EPD_BL_PIN; 52 | extern int EPD_CLK_PIN; 53 | extern int EPD_MOSI_PIN; 54 | extern int EPD_SCL_PIN; 55 | extern int EPD_SDA_PIN; 56 | 57 | /*------------------------------------------------------------------------------------------------------*/ 58 | void DEV_Digital_Write(UWORD Pin, UBYTE Value); 59 | UBYTE DEV_Digital_Read(UWORD Pin); 60 | 61 | void DEV_GPIO_Mode(UWORD Pin, UWORD Mode); 62 | void DEV_KEY_Config(UWORD Pin); 63 | void DEV_Digital_Write(UWORD Pin, UBYTE Value); 64 | UBYTE DEV_Digital_Read(UWORD Pin); 65 | 66 | void DEV_SPI_WriteByte(UBYTE Value); 67 | void DEV_SPI_Write_nByte(uint8_t *pData, uint32_t Len); 68 | 69 | void DEV_Delay_ms(UDOUBLE xms); 70 | void DEV_Delay_us(UDOUBLE xus); 71 | 72 | 73 | void DEV_I2C_Write(uint8_t addr, uint8_t reg, uint8_t Value); 74 | void DEV_I2C_Write_nByte(uint8_t addr, uint8_t *pData, uint32_t Len); 75 | uint8_t DEV_I2C_ReadByte(uint8_t addr, uint8_t reg); 76 | 77 | void DEV_SET_PWM(uint8_t Value); 78 | 79 | UBYTE DEV_Module_Init(void); 80 | void DEV_Module_Exit(void); 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /c/lib/Config/DEV_Config.h.gch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/lib/Config/DEV_Config.h.gch -------------------------------------------------------------------------------- /c/lib/Config/Debug.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : Debug.h 3 | * | Author : 4 | * | Function : debug with printf 5 | * | Info : 6 | * Image scanning 7 | * Please use progressive scanning to generate images or fonts 8 | *---------------- 9 | * | This version: V2.0 10 | * | Date : 2018-10-30 11 | * | Info : 12 | * 1.USE_DEBUG -> DEBUG, If you need to see the debug information, 13 | * clear the execution: make DEBUG=-DDEBUG 14 | # 15 | # Permission is hereby granted, free of charge, to any person obtaining a copy 16 | # of this software and associated documnetation files (the "Software"), to deal 17 | # in the Software without restriction, including without limitation the rights 18 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | # copies of the Software, and to permit persons to whom the Software is 20 | # furished to do so, subject to the following conditions: 21 | # 22 | # The above copyright notice and this permission notice shall be included in 23 | # all copies or substantial portions of the Software. 24 | # 25 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | # THE SOFTWARE. 32 | # 33 | 34 | ******************************************************************************/ 35 | #ifndef __DEBUG_H 36 | #define __DEBUG_H 37 | 38 | #include 39 | 40 | #if DEBUG 41 | #define Debug(__info,...) printf("Debug: " __info,##__VA_ARGS__) 42 | #else 43 | #define Debug(__info,...) 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /c/lib/Fonts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_Fonts_SRCS 变量 3 | aux_source_directory(. DIR_Fonts_SRCS) 4 | 5 | # 生成链接库 6 | add_library(Fonts ${DIR_Fonts_SRCS}) -------------------------------------------------------------------------------- /c/lib/Fonts/font12CN.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/lib/Fonts/font12CN.c -------------------------------------------------------------------------------- /c/lib/Fonts/font24CN.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/lib/Fonts/font24CN.c -------------------------------------------------------------------------------- /c/lib/Fonts/fonts.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/lib/Fonts/fonts.h -------------------------------------------------------------------------------- /c/lib/GUI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_GUI_SRCS 变量 3 | aux_source_directory(. DIR_GUI_SRCS) 4 | 5 | include_directories(../Config) 6 | 7 | # 生成链接库 8 | add_library(GUI ${DIR_GUI_SRCS}) 9 | target_link_libraries(GUI PUBLIC Config) -------------------------------------------------------------------------------- /c/lib/GUI/GUI_Paint.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUI_PAINT_H 2 | #define __GUI_PAINT_H 3 | 4 | #include "DEV_Config.h" 5 | #include "../Fonts/fonts.h" 6 | 7 | /** 8 | * Image attributes 9 | **/ 10 | typedef struct { 11 | UBYTE *Image; 12 | UWORD Width; 13 | UWORD Height; 14 | UWORD WidthMemory; 15 | UWORD HeightMemory; 16 | UWORD Color; 17 | UWORD Rotate; 18 | UWORD Mirror; 19 | UWORD WidthByte; 20 | UWORD HeightByte; 21 | UWORD Scale; 22 | } PAINT; 23 | extern PAINT Paint; 24 | 25 | /** 26 | * Display rotate 27 | **/ 28 | #define ROTATE_0 0 29 | #define ROTATE_90 90 30 | #define ROTATE_180 180 31 | #define ROTATE_270 270 32 | 33 | /** 34 | * Display Flip 35 | **/ 36 | typedef enum { 37 | MIRROR_NONE = 0x00, 38 | MIRROR_HORIZONTAL = 0x01, 39 | MIRROR_VERTICAL = 0x02, 40 | MIRROR_ORIGIN = 0x03, 41 | } MIRROR_IMAGE; 42 | #define MIRROR_IMAGE_DFT MIRROR_NONE 43 | 44 | /** 45 | * image color 46 | **/ 47 | #define WHITE 0xFFFF 48 | #define BLACK 0x0000 49 | #define BLUE 0x001F 50 | #define BRED 0XF81F 51 | #define GRED 0XFFE0 52 | #define GBLUE 0X07FF 53 | #define RED 0xF800 54 | #define MAGENTA 0xF81F 55 | #define GREEN 0x07E0 56 | #define CYAN 0x7FFF 57 | #define YELLOW 0xFFE0 58 | #define BROWN 0XBC40 59 | #define BRRED 0XFC07 60 | #define GRAY 0X8430 61 | 62 | #define IMAGE_BACKGROUND WHITE 63 | #define FONT_FOREGROUND BLACK 64 | #define FONT_BACKGROUND WHITE 65 | 66 | /** 67 | * The size of the point 68 | **/ 69 | typedef enum { 70 | DOT_PIXEL_1X1 = 1, // 1 x 1 71 | DOT_PIXEL_2X2 , // 2 X 2 72 | DOT_PIXEL_3X3 , // 3 X 3 73 | DOT_PIXEL_4X4 , // 4 X 4 74 | DOT_PIXEL_5X5 , // 5 X 5 75 | DOT_PIXEL_6X6 , // 6 X 6 76 | DOT_PIXEL_7X7 , // 7 X 7 77 | DOT_PIXEL_8X8 , // 8 X 8 78 | } DOT_PIXEL; 79 | #define DOT_PIXEL_DFT DOT_PIXEL_1X1 //Default dot pilex 80 | 81 | /** 82 | * Point size fill style 83 | **/ 84 | typedef enum { 85 | DOT_FILL_AROUND = 1, // dot pixel 1 x 1 86 | DOT_FILL_RIGHTUP , // dot pixel 2 X 2 87 | } DOT_STYLE; 88 | #define DOT_STYLE_DFT DOT_FILL_AROUND //Default dot pilex 89 | 90 | /** 91 | * Line style, solid or dashed 92 | **/ 93 | typedef enum { 94 | LINE_STYLE_SOLID = 0, 95 | LINE_STYLE_DOTTED, 96 | } LINE_STYLE; 97 | 98 | /** 99 | * Whether the graphic is filled 100 | **/ 101 | typedef enum { 102 | DRAW_FILL_EMPTY = 0, 103 | DRAW_FILL_FULL, 104 | } DRAW_FILL; 105 | 106 | /** 107 | * Custom structure of a time attribute 108 | **/ 109 | typedef struct { 110 | UWORD Year; //0000 111 | UBYTE Month; //1 - 12 112 | UBYTE Day; //1 - 30 113 | UBYTE Hour; //0 - 23 114 | UBYTE Min; //0 - 59 115 | UBYTE Sec; //0 - 59 116 | } PAINT_TIME; 117 | extern PAINT_TIME sPaint_time; 118 | 119 | //init and Clear 120 | void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color); 121 | void Paint_SelectImage(UBYTE *image); 122 | void Paint_SetRotate(UWORD Rotate); 123 | void Paint_SetMirroring(UBYTE mirror); 124 | void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color); 125 | void Paint_SetScale(UBYTE scale); 126 | 127 | void Paint_Clear(UWORD Color); 128 | void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color); 129 | 130 | //Drawing 131 | void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_FillWay); 132 | void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style); 133 | void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill); 134 | void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill); 135 | 136 | //Display string 137 | void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Acsii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background); 138 | void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background); 139 | void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background); 140 | void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Font, UWORD Digit,UWORD Color_Foreground, UWORD Color_Background); 141 | void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background); 142 | 143 | //pic 144 | void Paint_DrawBitMap(const unsigned char* image_buffer); 145 | void Paint_DrawBitMap_Block(const unsigned char* image_buffer, UBYTE Region); 146 | 147 | void Paint_DrawImage(const unsigned char *image, UWORD xStart, UWORD yStart, UWORD W_Image, UWORD H_Image) ; 148 | void Paint_DrawImage1(const unsigned char *image, UWORD xStart, UWORD yStart, UWORD W_Image, UWORD H_Image); 149 | void Paint_BmpWindows(unsigned char x,unsigned char y,const unsigned char *pBmp,\ 150 | unsigned char chWidth,unsigned char chHeight); 151 | 152 | 153 | #endif 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /c/lib/Icm20948/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_Icm20948_SRCS 变量 3 | aux_source_directory(. DIR_Icm20948_SRCS) 4 | 5 | include_directories(../Config) 6 | 7 | # 生成链接库 8 | add_library(Icm20948 ${DIR_Icm20948_SRCS}) 9 | target_link_libraries(Icm20948 PUBLIC Config) -------------------------------------------------------------------------------- /c/lib/Icm20948/icm20948.h: -------------------------------------------------------------------------------- 1 | #ifndef __ICM20948__H 2 | #define __ICM20948__H 3 | #include 4 | #include 5 | 6 | 7 | #include "DEV_Config.h" 8 | 9 | //typedef uint8_t bool; 10 | #define true 1 11 | #define false 0 12 | /* define ICM-20948 Device I2C address*/ 13 | #define I2C_ADD_ICM20948 0x68 14 | #define I2C_ADD_ICM20948_AK09916 0x0C 15 | #define I2C_ADD_ICM20948_AK09916_READ 0x80 16 | #define I2C_ADD_ICM20948_AK09916_WRITE 0x00 17 | /* define ICM-20948 Register */ 18 | /* user bank 0 register */ 19 | #define REG_ADD_WIA 0x00 20 | #define REG_VAL_WIA 0xEA 21 | #define REG_ADD_USER_CTRL 0x03 22 | #define REG_VAL_BIT_DMP_EN 0x80 23 | #define REG_VAL_BIT_FIFO_EN 0x40 24 | #define REG_VAL_BIT_I2C_MST_EN 0x20 25 | #define REG_VAL_BIT_I2C_IF_DIS 0x10 26 | #define REG_VAL_BIT_DMP_RST 0x08 27 | #define REG_VAL_BIT_DIAMOND_DMP_RST 0x04 28 | #define REG_ADD_PWR_MIGMT_1 0x06 29 | #define REG_VAL_ALL_RGE_RESET 0x80 30 | #define REG_VAL_RUN_MODE 0x01 //Non low-power mode 31 | #define REG_ADD_LP_CONFIG 0x05 32 | #define REG_ADD_PWR_MGMT_1 0x06 33 | #define REG_ADD_PWR_MGMT_2 0x07 34 | #define REG_ADD_ACCEL_XOUT_H 0x2D 35 | #define REG_ADD_ACCEL_XOUT_L 0x2E 36 | #define REG_ADD_ACCEL_YOUT_H 0x2F 37 | #define REG_ADD_ACCEL_YOUT_L 0x30 38 | #define REG_ADD_ACCEL_ZOUT_H 0x31 39 | #define REG_ADD_ACCEL_ZOUT_L 0x32 40 | #define REG_ADD_GYRO_XOUT_H 0x33 41 | #define REG_ADD_GYRO_XOUT_L 0x34 42 | #define REG_ADD_GYRO_YOUT_H 0x35 43 | #define REG_ADD_GYRO_YOUT_L 0x36 44 | #define REG_ADD_GYRO_ZOUT_H 0x37 45 | #define REG_ADD_GYRO_ZOUT_L 0x38 46 | #define REG_ADD_EXT_SENS_DATA_00 0x3B 47 | #define REG_ADD_REG_BANK_SEL 0x7F 48 | #define REG_VAL_REG_BANK_0 0x00 49 | #define REG_VAL_REG_BANK_1 0x10 50 | #define REG_VAL_REG_BANK_2 0x20 51 | #define REG_VAL_REG_BANK_3 0x30 52 | 53 | /* user bank 1 register */ 54 | /* user bank 2 register */ 55 | #define REG_ADD_GYRO_SMPLRT_DIV 0x00 56 | #define REG_ADD_GYRO_CONFIG_1 0x01 57 | #define REG_VAL_BIT_GYRO_DLPCFG_2 0x10 /* bit[5:3] */ 58 | #define REG_VAL_BIT_GYRO_DLPCFG_4 0x20 /* bit[5:3] */ 59 | #define REG_VAL_BIT_GYRO_DLPCFG_6 0x30 /* bit[5:3] */ 60 | #define REG_VAL_BIT_GYRO_FS_250DPS 0x00 /* bit[2:1] */ 61 | #define REG_VAL_BIT_GYRO_FS_500DPS 0x02 /* bit[2:1] */ 62 | #define REG_VAL_BIT_GYRO_FS_1000DPS 0x04 /* bit[2:1] */ 63 | #define REG_VAL_BIT_GYRO_FS_2000DPS 0x06 /* bit[2:1] */ 64 | #define REG_VAL_BIT_GYRO_DLPF 0x01 /* bit[0] */ 65 | #define REG_ADD_ACCEL_SMPLRT_DIV_2 0x11 66 | #define REG_ADD_ACCEL_CONFIG 0x14 67 | #define REG_VAL_BIT_ACCEL_DLPCFG_2 0x10 /* bit[5:3] */ 68 | #define REG_VAL_BIT_ACCEL_DLPCFG_4 0x20 /* bit[5:3] */ 69 | #define REG_VAL_BIT_ACCEL_DLPCFG_6 0x30 /* bit[5:3] */ 70 | #define REG_VAL_BIT_ACCEL_FS_2g 0x00 /* bit[2:1] */ 71 | #define REG_VAL_BIT_ACCEL_FS_4g 0x02 /* bit[2:1] */ 72 | #define REG_VAL_BIT_ACCEL_FS_8g 0x04 /* bit[2:1] */ 73 | #define REG_VAL_BIT_ACCEL_FS_16g 0x06 /* bit[2:1] */ 74 | #define REG_VAL_BIT_ACCEL_DLPF 0x01 /* bit[0] */ 75 | 76 | /* user bank 3 register */ 77 | #define REG_ADD_I2C_SLV0_ADDR 0x03 78 | #define REG_ADD_I2C_SLV0_REG 0x04 79 | #define REG_ADD_I2C_SLV0_CTRL 0x05 80 | #define REG_VAL_BIT_SLV0_EN 0x80 81 | #define REG_VAL_BIT_MASK_LEN 0x07 82 | #define REG_ADD_I2C_SLV0_DO 0x06 83 | #define REG_ADD_I2C_SLV1_ADDR 0x07 84 | #define REG_ADD_I2C_SLV1_REG 0x08 85 | #define REG_ADD_I2C_SLV1_CTRL 0x09 86 | #define REG_ADD_I2C_SLV1_DO 0x0A 87 | 88 | /* define ICM-20948 Register end */ 89 | 90 | /* define ICM-20948 MAG Register */ 91 | #define REG_ADD_MAG_WIA1 0x00 92 | #define REG_VAL_MAG_WIA1 0x48 93 | #define REG_ADD_MAG_WIA2 0x01 94 | #define REG_VAL_MAG_WIA2 0x09 95 | #define REG_ADD_MAG_ST2 0x10 96 | #define REG_ADD_MAG_DATA 0x11 97 | #define REG_ADD_MAG_CNTL2 0x31 98 | #define REG_VAL_MAG_MODE_PD 0x00 99 | #define REG_VAL_MAG_MODE_SM 0x01 100 | #define REG_VAL_MAG_MODE_10HZ 0x02 101 | #define REG_VAL_MAG_MODE_20HZ 0x04 102 | #define REG_VAL_MAG_MODE_50HZ 0x05 103 | #define REG_VAL_MAG_MODE_100HZ 0x08 104 | #define REG_VAL_MAG_MODE_ST 0x10 105 | /* define ICM-20948 MAG Register end */ 106 | 107 | #define MAG_DATA_LEN 6 108 | 109 | #ifdef __cplusplus 110 | extern "C" { 111 | #endif 112 | 113 | typedef enum 114 | { 115 | IMU_EN_SENSOR_TYPE_NULL = 0, 116 | IMU_EN_SENSOR_TYPE_ICM20948, 117 | IMU_EN_SENSOR_TYPE_MAX 118 | }IMU_EN_SENSOR_TYPE; 119 | 120 | typedef struct imu_st_angles_data_tag 121 | { 122 | float fYaw; 123 | float fPitch; 124 | float fRoll; 125 | }IMU_ST_ANGLES_DATA; 126 | 127 | typedef struct imu_st_sensor_data_tag 128 | { 129 | int16_t s16X; 130 | int16_t s16Y; 131 | int16_t s16Z; 132 | }IMU_ST_SENSOR_DATA; 133 | 134 | typedef struct icm20948_st_avg_data_tag 135 | { 136 | uint8_t u8Index; 137 | int16_t s16AvgBuffer[8]; 138 | }ICM20948_ST_AVG_DATA; 139 | 140 | void imuInit(IMU_EN_SENSOR_TYPE *penMotionSensorType); 141 | void imuDataGet(IMU_ST_ANGLES_DATA *pstAngles, 142 | IMU_ST_SENSOR_DATA *pstGyroRawData, 143 | IMU_ST_SENSOR_DATA *pstAccelRawData, 144 | IMU_ST_SENSOR_DATA *pstMagnRawData); 145 | char I2C_ReadOneByte(char reg); 146 | void I2C_WriteOneByte(char reg, char val); 147 | 148 | #ifdef __cplusplus 149 | } 150 | #endif 151 | 152 | #endif 153 | 154 | -------------------------------------------------------------------------------- /c/lib/Infrared/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_Infrared_SRCS 变量 3 | aux_source_directory(. DIR_Infrared_SRCS) 4 | 5 | include_directories(../Config) 6 | 7 | # 生成链接库 8 | add_library(Infrared ${DIR_Infrared_SRCS}) 9 | target_link_libraries(Infrared PUBLIC Config) -------------------------------------------------------------------------------- /c/lib/Infrared/Infrared.c: -------------------------------------------------------------------------------- 1 | #include "Infrared.h" 2 | 3 | int Infrared_PIN; 4 | 5 | void SET_Infrared_PIN(uint8_t PIN) 6 | { 7 | Infrared_PIN = PIN; 8 | DEV_GPIO_Mode(Infrared_PIN, 0); 9 | gpio_pull_up(Infrared_PIN);//Need to pull up 10 | } 11 | 12 | int Read_Infrared_Value(void) 13 | { 14 | uint8_t i,idx,cnt; 15 | uint8_t count; 16 | uint8_t data[4]; 17 | data[0]=0; 18 | data[1]=0; 19 | data[2]=0; 20 | data[3]=0; 21 | if(DEV_Digital_Read(Infrared_PIN) == 0){ 22 | count = 0; 23 | while(DEV_Digital_Read(Infrared_PIN) == 0 && count++ < 200) //9ms 24 | sleep_us(60); 25 | 26 | count = 0; 27 | while(DEV_Digital_Read(Infrared_PIN) == 1 && count++ < 80) //4.5ms 28 | sleep_us(60); 29 | 30 | idx = 0; 31 | cnt = 0; 32 | data[0]=0; 33 | data[1]=0; 34 | data[2]=0; 35 | data[3]=0; 36 | for(i =0;i<32;i++) 37 | { 38 | count = 0; 39 | while(DEV_Digital_Read(Infrared_PIN) == 0 && count++ < 15) //0.56ms 40 | sleep_us(60); 41 | 42 | count = 0; 43 | while(DEV_Digital_Read(Infrared_PIN) == 1 && count++ < 40) //0: 0.56ms; 1: 1.69ms 44 | sleep_us(60); 45 | 46 | if (count > 25)data[idx] |= (1< //itoa() 18 | #include 19 | 20 | LCD_0IN96_ATTRIBUTES LCD_0IN96; 21 | 22 | 23 | /****************************************************************************** 24 | function : Hardware reset 25 | parameter: 26 | ******************************************************************************/ 27 | static void LCD_0IN96_Reset(void) 28 | { 29 | DEV_Digital_Write(EPD_RST_PIN, 1); 30 | DEV_Delay_ms(200); 31 | DEV_Digital_Write(EPD_RST_PIN, 0); 32 | DEV_Delay_ms(200); 33 | DEV_Digital_Write(EPD_RST_PIN, 1); 34 | DEV_Delay_ms(200); 35 | } 36 | 37 | /****************************************************************************** 38 | function : send command 39 | parameter: 40 | Reg : Command register 41 | ******************************************************************************/ 42 | static void LCD_0IN96_SendCommand(UBYTE Reg) 43 | { 44 | DEV_Digital_Write(EPD_DC_PIN, 0); 45 | DEV_Digital_Write(EPD_CS_PIN, 0); 46 | DEV_SPI_WriteByte(Reg); 47 | //DEV_Digital_Write(EPD_CS_PIN, 1); 48 | } 49 | 50 | /****************************************************************************** 51 | function : send data 52 | parameter: 53 | Data : Write data 54 | ******************************************************************************/ 55 | static void LCD_0IN96_SendData_8Bit(UBYTE Data) 56 | { 57 | DEV_Digital_Write(EPD_DC_PIN, 1); 58 | DEV_Digital_Write(EPD_CS_PIN, 0); 59 | DEV_SPI_WriteByte(Data); 60 | DEV_Digital_Write(EPD_CS_PIN, 1); 61 | } 62 | 63 | /****************************************************************************** 64 | function : send data 65 | parameter: 66 | Data : Write data 67 | ******************************************************************************/ 68 | static void LCD_0IN96_SendData_16Bit(UWORD Data) 69 | { 70 | DEV_Digital_Write(EPD_DC_PIN, 1); 71 | DEV_Digital_Write(EPD_CS_PIN, 0); 72 | DEV_SPI_WriteByte((Data >> 8) & 0xFF); 73 | DEV_SPI_WriteByte(Data); 74 | DEV_Digital_Write(EPD_CS_PIN, 1); 75 | } 76 | 77 | /****************************************************************************** 78 | function : Initialize the lcd register 79 | parameter: 80 | ******************************************************************************/ 81 | static void LCD_0IN96_InitReg(void) 82 | { 83 | LCD_0IN96_SendCommand(0x11);//Sleep exit 84 | DEV_Delay_ms (120); 85 | LCD_0IN96_SendCommand(0x21); 86 | LCD_0IN96_SendCommand(0x21); 87 | 88 | LCD_0IN96_SendCommand(0xB1); 89 | LCD_0IN96_SendData_8Bit(0x05); 90 | LCD_0IN96_SendData_8Bit(0x3A); 91 | LCD_0IN96_SendData_8Bit(0x3A); 92 | 93 | LCD_0IN96_SendCommand(0xB2); 94 | LCD_0IN96_SendData_8Bit(0x05); 95 | LCD_0IN96_SendData_8Bit(0x3A); 96 | LCD_0IN96_SendData_8Bit(0x3A); 97 | 98 | LCD_0IN96_SendCommand(0xB3); 99 | LCD_0IN96_SendData_8Bit(0x05); 100 | LCD_0IN96_SendData_8Bit(0x3A); 101 | LCD_0IN96_SendData_8Bit(0x3A); 102 | LCD_0IN96_SendData_8Bit(0x05); 103 | LCD_0IN96_SendData_8Bit(0x3A); 104 | LCD_0IN96_SendData_8Bit(0x3A); 105 | 106 | LCD_0IN96_SendCommand(0xB4); 107 | LCD_0IN96_SendData_8Bit(0x03); 108 | 109 | LCD_0IN96_SendCommand(0xC0); 110 | LCD_0IN96_SendData_8Bit(0x62); 111 | LCD_0IN96_SendData_8Bit(0x02); 112 | LCD_0IN96_SendData_8Bit(0x04); 113 | 114 | LCD_0IN96_SendCommand(0xC1); 115 | LCD_0IN96_SendData_8Bit(0xC0); 116 | 117 | LCD_0IN96_SendCommand(0xC2); 118 | LCD_0IN96_SendData_8Bit(0x0D); 119 | LCD_0IN96_SendData_8Bit(0x00); 120 | 121 | LCD_0IN96_SendCommand(0xC3); 122 | LCD_0IN96_SendData_8Bit(0x8D); 123 | LCD_0IN96_SendData_8Bit(0x6A); 124 | 125 | LCD_0IN96_SendCommand(0xC4); 126 | LCD_0IN96_SendData_8Bit(0x8D); 127 | LCD_0IN96_SendData_8Bit(0xEE); 128 | 129 | LCD_0IN96_SendCommand(0xC5); /*VCOM*/ 130 | LCD_0IN96_SendData_8Bit(0x0E); 131 | 132 | LCD_0IN96_SendCommand(0xE0); 133 | LCD_0IN96_SendData_8Bit(0x10); 134 | LCD_0IN96_SendData_8Bit(0x0E); 135 | LCD_0IN96_SendData_8Bit(0x02); 136 | LCD_0IN96_SendData_8Bit(0x03); 137 | LCD_0IN96_SendData_8Bit(0x0E); 138 | LCD_0IN96_SendData_8Bit(0x07); 139 | LCD_0IN96_SendData_8Bit(0x02); 140 | LCD_0IN96_SendData_8Bit(0x07); 141 | LCD_0IN96_SendData_8Bit(0x0A); 142 | LCD_0IN96_SendData_8Bit(0x12); 143 | LCD_0IN96_SendData_8Bit(0x27); 144 | LCD_0IN96_SendData_8Bit(0x37); 145 | LCD_0IN96_SendData_8Bit(0x00); 146 | LCD_0IN96_SendData_8Bit(0x0D); 147 | LCD_0IN96_SendData_8Bit(0x0E); 148 | LCD_0IN96_SendData_8Bit(0x10); 149 | 150 | LCD_0IN96_SendCommand(0xE1); 151 | LCD_0IN96_SendData_8Bit(0x10); 152 | LCD_0IN96_SendData_8Bit(0x0E); 153 | LCD_0IN96_SendData_8Bit(0x03); 154 | LCD_0IN96_SendData_8Bit(0x03); 155 | LCD_0IN96_SendData_8Bit(0x0F); 156 | LCD_0IN96_SendData_8Bit(0x06); 157 | LCD_0IN96_SendData_8Bit(0x02); 158 | LCD_0IN96_SendData_8Bit(0x08); 159 | LCD_0IN96_SendData_8Bit(0x0A); 160 | LCD_0IN96_SendData_8Bit(0x13); 161 | LCD_0IN96_SendData_8Bit(0x26); 162 | LCD_0IN96_SendData_8Bit(0x36); 163 | LCD_0IN96_SendData_8Bit(0x00); 164 | LCD_0IN96_SendData_8Bit(0x0D); 165 | LCD_0IN96_SendData_8Bit(0x0E); 166 | LCD_0IN96_SendData_8Bit(0x10); 167 | 168 | LCD_0IN96_SendCommand(0x3A); 169 | LCD_0IN96_SendData_8Bit(0x05); 170 | 171 | LCD_0IN96_SendCommand(0x36); 172 | LCD_0IN96_SendData_8Bit(0xA8); 173 | 174 | LCD_0IN96_SendCommand(0x29); 175 | } 176 | 177 | 178 | /******************************************************************************** 179 | function : Initialize the lcd 180 | parameter: 181 | ********************************************************************************/ 182 | void LCD_0IN96_Init(UBYTE Scan_dir) 183 | { 184 | DEV_SET_PWM(90); 185 | LCD_0IN96_Reset(); 186 | 187 | LCD_0IN96.HEIGHT = LCD_0IN96_HEIGHT; 188 | LCD_0IN96.WIDTH = LCD_0IN96_WIDTH; 189 | 190 | //Set the initialization register 191 | LCD_0IN96_InitReg(); 192 | 193 | } 194 | 195 | /******************************************************************************** 196 | function: Sets the start position and size of the display area 197 | parameter: 198 | Xstart : X direction Start coordinates 199 | Ystart : Y direction Start coordinates 200 | Xend : X direction end coordinates 201 | Yend : Y direction end coordinates 202 | ********************************************************************************/ 203 | void LCD_0IN96_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend) 204 | { 205 | Xstart = Xstart + 1; 206 | Xend = Xend + 1; 207 | Ystart = Ystart + 26; 208 | Yend = Yend+26; 209 | 210 | LCD_0IN96_SendCommand(0x2a); 211 | LCD_0IN96_SendData_8Bit(Xstart >> 8); 212 | LCD_0IN96_SendData_8Bit(Xstart); 213 | LCD_0IN96_SendData_8Bit(Xend >> 8); 214 | LCD_0IN96_SendData_8Bit(Xend ); 215 | 216 | LCD_0IN96_SendCommand(0x2b); 217 | LCD_0IN96_SendData_8Bit(Ystart >> 8); 218 | LCD_0IN96_SendData_8Bit(Ystart); 219 | LCD_0IN96_SendData_8Bit(Yend >> 8); 220 | LCD_0IN96_SendData_8Bit(Yend); 221 | 222 | LCD_0IN96_SendCommand(0x2C); 223 | } 224 | 225 | /****************************************************************************** 226 | function : Clear screen 227 | parameter: 228 | ******************************************************************************/ 229 | void LCD_0IN96_Clear(UWORD Color) 230 | { 231 | UWORD j,i; 232 | UWORD Image[LCD_0IN96.WIDTH*LCD_0IN96.HEIGHT]; 233 | 234 | Color = ((Color<<8)&0xff00)|(Color>>8); 235 | 236 | for (j = 0; j < LCD_0IN96.HEIGHT*LCD_0IN96.WIDTH; j++) { 237 | Image[j] = Color; 238 | } 239 | 240 | LCD_0IN96_SetWindows(0, 0, LCD_0IN96.WIDTH-1, LCD_0IN96.HEIGHT-1); 241 | DEV_Digital_Write(EPD_DC_PIN, 1); 242 | DEV_Digital_Write(EPD_CS_PIN, 0); 243 | 244 | // for(j = 0; j < LCD_0IN96.WIDTH*LCD_0IN96.HEIGHT; j++){ 245 | // LCD_0IN96_SendData_16Bit(Image[j]); 246 | 247 | for(j = 0; j < LCD_0IN96.HEIGHT; j++){ 248 | DEV_SPI_Write_nByte((uint8_t *)&Image[j*LCD_0IN96.WIDTH], LCD_0IN96.WIDTH*2); 249 | } 250 | DEV_Digital_Write(EPD_CS_PIN, 1); 251 | } 252 | 253 | /****************************************************************************** 254 | function : Sends the image buffer in RAM to displays 255 | parameter: 256 | ******************************************************************************/ 257 | void LCD_0IN96_Display(UWORD *Image) 258 | { 259 | UWORD j; 260 | LCD_0IN96_SetWindows(0, 0, LCD_0IN96.WIDTH-1, LCD_0IN96.HEIGHT-1); 261 | DEV_Digital_Write(EPD_DC_PIN, 1); 262 | // DEV_Digital_Write(EPD_CS_PIN, 0); 263 | 264 | for (j = 0; j < LCD_0IN96.HEIGHT; j++) { 265 | DEV_SPI_Write_nByte((uint8_t *)&Image[j*LCD_0IN96.WIDTH], LCD_0IN96.WIDTH*2); 266 | 267 | // for(j = 0; j < LCD_0IN96.WIDTH*LCD_0IN96.HEIGHT; j++){ 268 | // LCD_0IN96_SendData_16Bit(Image[j]); 269 | } 270 | // DEV_Digital_Write(EPD_CS_PIN, 1); 271 | //LCD_0IN96_SendCommand(0x29); 272 | } 273 | 274 | void LCD_0IN96_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image) 275 | { 276 | // display 277 | UDOUBLE Addr = 0; 278 | 279 | UWORD j; 280 | LCD_0IN96_SetWindows(Xstart, Ystart, Xend , Yend); 281 | DEV_Digital_Write(EPD_DC_PIN, 1); 282 | DEV_Digital_Write(EPD_CS_PIN, 0); 283 | for (j = Ystart; j < Yend - 1; j++) { 284 | Addr = Xstart + j * LCD_0IN96.WIDTH ; 285 | DEV_SPI_Write_nByte((uint8_t *)&Image[Addr], (Xend-Xstart)*2); 286 | } 287 | DEV_Digital_Write(EPD_CS_PIN, 1); 288 | } 289 | 290 | void LCD_0IN96_DisplayPoint(UWORD X, UWORD Y, UWORD Color) 291 | { 292 | LCD_0IN96_SetWindows(X,Y,X,Y); 293 | LCD_0IN96_SendData_16Bit(Color); 294 | } 295 | 296 | void Handler_0IN96_LCD(int signo) 297 | { 298 | //System Exit 299 | printf("\r\nHandler:Program stop\r\n"); 300 | DEV_Module_Exit(); 301 | exit(0); 302 | } 303 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_0in96.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : LCD_0in96.h 3 | * | Author : Waveshare team 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | * Used to shield the underlying layers of each master 7 | * and enhance portability 8 | *---------------- 9 | * | This version: V1.0 10 | * | Date : 2021-03-11 11 | * | Info : Basic version 12 | * 13 | ******************************************************************************/ 14 | #ifndef __LCD_0IN96_H 15 | #define __LCD_0IN96_H 16 | 17 | #include "DEV_Config.h" 18 | #include 19 | 20 | #include //itoa() 21 | #include 22 | 23 | 24 | #define LCD_0IN96_HEIGHT 80 25 | #define LCD_0IN96_WIDTH 160 26 | 27 | 28 | #define HORIZONTAL 0 29 | #define VERTICAL 1 30 | 31 | #define LCD_0IN96_SetBacklight(Value) ; 32 | 33 | 34 | typedef struct{ 35 | UWORD WIDTH; 36 | UWORD HEIGHT; 37 | UBYTE SCAN_DIR; 38 | }LCD_0IN96_ATTRIBUTES; 39 | extern LCD_0IN96_ATTRIBUTES LCD_0IN96; 40 | 41 | /******************************************************************************** 42 | function: 43 | Macro definition variable name 44 | ********************************************************************************/ 45 | void LCD_0IN96_Init(UBYTE Scan_dir); 46 | void LCD_0IN96_Clear(UWORD Color); 47 | void LCD_0IN96_Display(UWORD *Image); 48 | void LCD_0IN96_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 49 | void LCD_0IN96_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 50 | 51 | void Handler_0IN96_LCD(int signo); 52 | #endif 53 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in14.c: -------------------------------------------------------------------------------- 1 | #include "LCD_1in14.h" 2 | #include "DEV_Config.h" 3 | 4 | #include //itoa() 5 | #include 6 | 7 | LCD_1IN14_ATTRIBUTES LCD_1IN14; 8 | 9 | 10 | /****************************************************************************** 11 | function : Hardware reset 12 | parameter: 13 | ******************************************************************************/ 14 | static void LCD_1IN14_Reset(void) 15 | { 16 | DEV_Digital_Write(EPD_RST_PIN, 1); 17 | DEV_Delay_ms(100); 18 | DEV_Digital_Write(EPD_RST_PIN, 0); 19 | DEV_Delay_ms(100); 20 | DEV_Digital_Write(EPD_RST_PIN, 1); 21 | DEV_Delay_ms(100); 22 | } 23 | 24 | /****************************************************************************** 25 | function : send command 26 | parameter: 27 | Reg : Command register 28 | ******************************************************************************/ 29 | static void LCD_1IN14_SendCommand(UBYTE Reg) 30 | { 31 | DEV_Digital_Write(EPD_DC_PIN, 0); 32 | DEV_Digital_Write(EPD_CS_PIN, 0); 33 | DEV_SPI_WriteByte(Reg); 34 | DEV_Digital_Write(EPD_CS_PIN, 1); 35 | } 36 | 37 | /****************************************************************************** 38 | function : send data 39 | parameter: 40 | Data : Write data 41 | ******************************************************************************/ 42 | static void LCD_1IN14_SendData_8Bit(UBYTE Data) 43 | { 44 | DEV_Digital_Write(EPD_DC_PIN, 1); 45 | DEV_Digital_Write(EPD_CS_PIN, 0); 46 | DEV_SPI_WriteByte(Data); 47 | DEV_Digital_Write(EPD_CS_PIN, 1); 48 | } 49 | 50 | /****************************************************************************** 51 | function : send data 52 | parameter: 53 | Data : Write data 54 | ******************************************************************************/ 55 | static void LCD_1IN14_SendData_16Bit(UWORD Data) 56 | { 57 | DEV_Digital_Write(EPD_DC_PIN, 1); 58 | DEV_Digital_Write(EPD_CS_PIN, 0); 59 | DEV_SPI_WriteByte((Data >> 8) & 0xFF); 60 | DEV_SPI_WriteByte(Data & 0xFF); 61 | DEV_Digital_Write(EPD_CS_PIN, 1); 62 | } 63 | 64 | /****************************************************************************** 65 | function : Initialize the lcd register 66 | parameter: 67 | ******************************************************************************/ 68 | static void LCD_1IN14_InitReg(void) 69 | { 70 | LCD_1IN14_SendCommand(0x3A); 71 | LCD_1IN14_SendData_8Bit(0x05); 72 | 73 | LCD_1IN14_SendCommand(0xB2); 74 | LCD_1IN14_SendData_8Bit(0x0C); 75 | LCD_1IN14_SendData_8Bit(0x0C); 76 | LCD_1IN14_SendData_8Bit(0x00); 77 | LCD_1IN14_SendData_8Bit(0x33); 78 | LCD_1IN14_SendData_8Bit(0x33); 79 | 80 | LCD_1IN14_SendCommand(0xB7); //Gate Control 81 | LCD_1IN14_SendData_8Bit(0x35); 82 | 83 | LCD_1IN14_SendCommand(0xBB); //VCOM Setting 84 | LCD_1IN14_SendData_8Bit(0x19); 85 | 86 | LCD_1IN14_SendCommand(0xC0); //LCM Control 87 | LCD_1IN14_SendData_8Bit(0x2C); 88 | 89 | LCD_1IN14_SendCommand(0xC2); //VDV and VRH Command Enable 90 | LCD_1IN14_SendData_8Bit(0x01); 91 | LCD_1IN14_SendCommand(0xC3); //VRH Set 92 | LCD_1IN14_SendData_8Bit(0x12); 93 | LCD_1IN14_SendCommand(0xC4); //VDV Set 94 | LCD_1IN14_SendData_8Bit(0x20); 95 | 96 | LCD_1IN14_SendCommand(0xC6); //Frame Rate Control in Normal Mode 97 | LCD_1IN14_SendData_8Bit(0x0F); 98 | 99 | LCD_1IN14_SendCommand(0xD0); // Power Control 1 100 | LCD_1IN14_SendData_8Bit(0xA4); 101 | LCD_1IN14_SendData_8Bit(0xA1); 102 | 103 | LCD_1IN14_SendCommand(0xE0); //Positive Voltage Gamma Control 104 | LCD_1IN14_SendData_8Bit(0xD0); 105 | LCD_1IN14_SendData_8Bit(0x04); 106 | LCD_1IN14_SendData_8Bit(0x0D); 107 | LCD_1IN14_SendData_8Bit(0x11); 108 | LCD_1IN14_SendData_8Bit(0x13); 109 | LCD_1IN14_SendData_8Bit(0x2B); 110 | LCD_1IN14_SendData_8Bit(0x3F); 111 | LCD_1IN14_SendData_8Bit(0x54); 112 | LCD_1IN14_SendData_8Bit(0x4C); 113 | LCD_1IN14_SendData_8Bit(0x18); 114 | LCD_1IN14_SendData_8Bit(0x0D); 115 | LCD_1IN14_SendData_8Bit(0x0B); 116 | LCD_1IN14_SendData_8Bit(0x1F); 117 | LCD_1IN14_SendData_8Bit(0x23); 118 | 119 | LCD_1IN14_SendCommand(0xE1); //Negative Voltage Gamma Control 120 | LCD_1IN14_SendData_8Bit(0xD0); 121 | LCD_1IN14_SendData_8Bit(0x04); 122 | LCD_1IN14_SendData_8Bit(0x0C); 123 | LCD_1IN14_SendData_8Bit(0x11); 124 | LCD_1IN14_SendData_8Bit(0x13); 125 | LCD_1IN14_SendData_8Bit(0x2C); 126 | LCD_1IN14_SendData_8Bit(0x3F); 127 | LCD_1IN14_SendData_8Bit(0x44); 128 | LCD_1IN14_SendData_8Bit(0x51); 129 | LCD_1IN14_SendData_8Bit(0x2F); 130 | LCD_1IN14_SendData_8Bit(0x1F); 131 | LCD_1IN14_SendData_8Bit(0x1F); 132 | LCD_1IN14_SendData_8Bit(0x20); 133 | LCD_1IN14_SendData_8Bit(0x23); 134 | 135 | LCD_1IN14_SendCommand(0x21); //Display Inversion On 136 | 137 | LCD_1IN14_SendCommand(0x11); //Sleep Out 138 | 139 | LCD_1IN14_SendCommand(0x29); //Display On 140 | } 141 | 142 | /******************************************************************************** 143 | function: Set the resolution and scanning method of the screen 144 | parameter: 145 | Scan_dir: Scan direction 146 | ********************************************************************************/ 147 | static void LCD_1IN14_SetAttributes(UBYTE Scan_dir) 148 | { 149 | //Get the screen scan direction 150 | LCD_1IN14.SCAN_DIR = Scan_dir; 151 | UBYTE MemoryAccessReg = 0x00; 152 | 153 | //Get GRAM and LCD width and height 154 | if(Scan_dir == HORIZONTAL) { 155 | LCD_1IN14.HEIGHT = LCD_1IN14_WIDTH; 156 | LCD_1IN14.WIDTH = LCD_1IN14_HEIGHT; 157 | MemoryAccessReg = 0X70; 158 | } else { 159 | LCD_1IN14.HEIGHT = LCD_1IN14_HEIGHT; 160 | LCD_1IN14.WIDTH = LCD_1IN14_WIDTH; 161 | MemoryAccessReg = 0X00; 162 | } 163 | 164 | // Set the read / write scan direction of the frame memory 165 | LCD_1IN14_SendCommand(0x36); //MX, MY, RGB mode 166 | LCD_1IN14_SendData_8Bit(MemoryAccessReg); //0x08 set RGB 167 | } 168 | 169 | /******************************************************************************** 170 | function : Initialize the lcd 171 | parameter: 172 | ********************************************************************************/ 173 | void LCD_1IN14_Init(UBYTE Scan_dir) 174 | { 175 | DEV_SET_PWM(90); 176 | //Hardware reset 177 | LCD_1IN14_Reset(); 178 | 179 | //Set the resolution and scanning method of the screen 180 | LCD_1IN14_SetAttributes(Scan_dir); 181 | 182 | //Set the initialization register 183 | LCD_1IN14_InitReg(); 184 | } 185 | 186 | /******************************************************************************** 187 | function: Sets the start position and size of the display area 188 | parameter: 189 | Xstart : X direction Start coordinates 190 | Ystart : Y direction Start coordinates 191 | Xend : X direction end coordinates 192 | Yend : Y direction end coordinates 193 | ********************************************************************************/ 194 | void LCD_1IN14_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend) 195 | { 196 | UBYTE x,y; 197 | if(LCD_1IN14.SCAN_DIR == HORIZONTAL){x=40;y=53;} 198 | else{ x=52; y=40; } 199 | //set the X coordinates 200 | LCD_1IN14_SendCommand(0x2A); 201 | 202 | 203 | LCD_1IN14_SendData_16Bit(Xstart +x); 204 | LCD_1IN14_SendData_16Bit(Xend-1 +x); 205 | //set the Y coordinates 206 | LCD_1IN14_SendCommand(0x2B); 207 | LCD_1IN14_SendData_16Bit(Ystart +y); 208 | LCD_1IN14_SendData_16Bit(Yend-1 +y); 209 | 210 | LCD_1IN14_SendCommand(0X2C); 211 | // printf("%d %d\r\n",x,y); 212 | } 213 | 214 | /****************************************************************************** 215 | function : Clear screen 216 | parameter: 217 | ******************************************************************************/ 218 | void LCD_1IN14_Clear(UWORD Color) 219 | { 220 | UWORD j,i; 221 | UWORD Image[LCD_1IN14.WIDTH*LCD_1IN14.HEIGHT]; 222 | 223 | Color = ((Color<<8)&0xff00)|(Color>>8); 224 | 225 | for (j = 0; j < LCD_1IN14.HEIGHT*LCD_1IN14.WIDTH; j++) { 226 | Image[j] = Color; 227 | } 228 | 229 | LCD_1IN14_SetWindows(0, 0, LCD_1IN14.WIDTH, LCD_1IN14.HEIGHT); 230 | DEV_Digital_Write(EPD_DC_PIN, 1); 231 | DEV_Digital_Write(EPD_CS_PIN, 0); 232 | // printf("HEIGHT %d, WIDTH %d\r\n",LCD_1IN14.HEIGHT,LCD_1IN14.WIDTH); 233 | for(j = 0; j < LCD_1IN14.HEIGHT; j++){ 234 | DEV_SPI_Write_nByte((uint8_t *)&Image[j*LCD_1IN14.WIDTH], LCD_1IN14.WIDTH*2); 235 | } 236 | DEV_Digital_Write(EPD_CS_PIN, 1); 237 | } 238 | 239 | /****************************************************************************** 240 | function : Sends the image buffer in RAM to displays 241 | parameter: 242 | ******************************************************************************/ 243 | void LCD_1IN14_Display(UWORD *Image) 244 | { 245 | UWORD j; 246 | LCD_1IN14_SetWindows(0, 0, LCD_1IN14.WIDTH, LCD_1IN14.HEIGHT); 247 | DEV_Digital_Write(EPD_DC_PIN, 1); 248 | DEV_Digital_Write(EPD_CS_PIN, 0); 249 | for (j = 0; j < LCD_1IN14.HEIGHT; j++) { 250 | DEV_SPI_Write_nByte((uint8_t *)&Image[j*LCD_1IN14.WIDTH], LCD_1IN14.WIDTH*2); 251 | } 252 | DEV_Digital_Write(EPD_CS_PIN, 1); 253 | LCD_1IN14_SendCommand(0x29); 254 | } 255 | 256 | void LCD_1IN14_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image) 257 | { 258 | // display 259 | UDOUBLE Addr = 0; 260 | 261 | UWORD j; 262 | LCD_1IN14_SetWindows(Xstart, Ystart, Xend , Yend); 263 | DEV_Digital_Write(EPD_DC_PIN, 1); 264 | DEV_Digital_Write(EPD_CS_PIN, 0); 265 | for (j = Ystart; j < Yend - 1; j++) { 266 | Addr = Xstart + j * LCD_1IN14.WIDTH ; 267 | DEV_SPI_Write_nByte((uint8_t *)&Image[Addr], (Xend-Xstart)*2); 268 | } 269 | DEV_Digital_Write(EPD_CS_PIN, 1); 270 | } 271 | 272 | void LCD_1IN14_DisplayPoint(UWORD X, UWORD Y, UWORD Color) 273 | { 274 | LCD_1IN14_SetWindows(X,Y,X,Y); 275 | LCD_1IN14_SendData_16Bit(Color); 276 | } 277 | 278 | void Handler_1IN14_LCD(int signo) 279 | { 280 | //System Exit 281 | printf("\r\nHandler:Program stop\r\n"); 282 | DEV_Module_Exit(); 283 | exit(0); 284 | } 285 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in14.h: -------------------------------------------------------------------------------- 1 | #ifndef __LCD_1IN14_H 2 | #define __LCD_1IN14_H 3 | 4 | #include "DEV_Config.h" 5 | #include 6 | 7 | #include //itoa() 8 | #include 9 | 10 | 11 | #define LCD_1IN14_HEIGHT 240 12 | #define LCD_1IN14_WIDTH 135 13 | 14 | 15 | #define HORIZONTAL 0 16 | #define VERTICAL 1 17 | 18 | #define LCD_1IN14_SetBacklight(Value) ; 19 | 20 | 21 | typedef struct{ 22 | UWORD WIDTH; 23 | UWORD HEIGHT; 24 | UBYTE SCAN_DIR; 25 | }LCD_1IN14_ATTRIBUTES; 26 | extern LCD_1IN14_ATTRIBUTES LCD_1IN14; 27 | 28 | /******************************************************************************** 29 | function: 30 | Macro definition variable name 31 | ********************************************************************************/ 32 | void LCD_1IN14_Init(UBYTE Scan_dir); 33 | void LCD_1IN14_Clear(UWORD Color); 34 | void LCD_1IN14_Display(UWORD *Image); 35 | void LCD_1IN14_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 36 | void LCD_1IN14_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 37 | 38 | void Handler_1IN14_LCD(int signo); 39 | #endif 40 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in3.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : LCD_1in54.c 3 | * | Author : Waveshare team 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | * Used to shield the underlying layers of each master 7 | * and enhance portability 8 | *---------------- 9 | * | This version: V1.0 10 | * | Date : 2020-05-20 11 | * | Info : Basic version 12 | * 13 | ******************************************************************************/ 14 | #ifndef __LCD_1IN3_H 15 | #define __LCD_1IN3_H 16 | 17 | #include "DEV_Config.h" 18 | #include 19 | 20 | #include //itoa() 21 | #include 22 | 23 | 24 | #define LCD_1IN3_HEIGHT 240 25 | #define LCD_1IN3_WIDTH 240 26 | 27 | 28 | #define HORIZONTAL 0 29 | #define VERTICAL 1 30 | 31 | #define LCD_1IN3_SetBacklight(Value) ; 32 | 33 | 34 | typedef struct{ 35 | UWORD WIDTH; 36 | UWORD HEIGHT; 37 | UBYTE SCAN_DIR; 38 | }LCD_1IN3_ATTRIBUTES; 39 | extern LCD_1IN3_ATTRIBUTES LCD_1IN3; 40 | 41 | /******************************************************************************** 42 | function: 43 | Macro definition variable name 44 | ********************************************************************************/ 45 | void LCD_1IN3_Init(UBYTE Scan_dir); 46 | void LCD_1IN3_Clear(UWORD Color); 47 | void LCD_1IN3_Display(UWORD *Image); 48 | void LCD_1IN3_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 49 | void LCD_1IN3_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 50 | 51 | void Handler_1IN3_LCD(int signo); 52 | #endif 53 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in44.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : LCD_1in54.c 3 | * | Author : Waveshare team 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | * Used to shield the underlying layers of each master 7 | * and enhance portability 8 | *---------------- 9 | * | This version: V1.0 10 | * | Date : 2020-05-20 11 | * | Info : Basic version 12 | * 13 | ******************************************************************************/ 14 | #ifndef __LCD_1IN44_H 15 | #define __LCD_1IN44_H 16 | 17 | #include "DEV_Config.h" 18 | #include 19 | 20 | #include //itoa() 21 | #include 22 | 23 | 24 | #define LCD_1IN44_HEIGHT 128 25 | #define LCD_1IN44_WIDTH 128 26 | 27 | 28 | #define HORIZONTAL 0 29 | #define VERTICAL 1 30 | 31 | #define LCD_1IN44_SetBacklight(Value) ; 32 | 33 | 34 | typedef struct{ 35 | UWORD WIDTH; 36 | UWORD HEIGHT; 37 | UBYTE SCAN_DIR; 38 | }LCD_1IN44_ATTRIBUTES; 39 | extern LCD_1IN44_ATTRIBUTES LCD_1IN44; 40 | 41 | /******************************************************************************** 42 | function: 43 | Macro definition variable name 44 | ********************************************************************************/ 45 | void LCD_1IN44_Init(UBYTE Scan_dir); 46 | void LCD_1IN44_Clear(UWORD Color); 47 | void LCD_1IN44_Display(UWORD *Image); 48 | void LCD_1IN44_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 49 | void LCD_1IN44_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 50 | void Handler_1IN44_LCD(int signo); 51 | #endif 52 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in54.c: -------------------------------------------------------------------------------- 1 | #include "LCD_1in54.h" 2 | #include "DEV_Config.h" 3 | 4 | #include //itoa() 5 | #include 6 | 7 | LCD_1IN54_ATTRIBUTES LCD_1IN54; 8 | 9 | 10 | /****************************************************************************** 11 | function : Hardware reset 12 | parameter: 13 | ******************************************************************************/ 14 | static void LCD_1IN54_Reset(void) 15 | { 16 | DEV_Digital_Write(EPD_RST_PIN, 1); 17 | DEV_Delay_ms(100); 18 | DEV_Digital_Write(EPD_RST_PIN, 0); 19 | DEV_Delay_ms(100); 20 | DEV_Digital_Write(EPD_RST_PIN, 1); 21 | DEV_Delay_ms(100); 22 | } 23 | 24 | /****************************************************************************** 25 | function : send command 26 | parameter: 27 | Reg : Command register 28 | ******************************************************************************/ 29 | static void LCD_1IN54_SendCommand(UBYTE Reg) 30 | { 31 | DEV_Digital_Write(EPD_DC_PIN, 0); 32 | DEV_Digital_Write(EPD_CS_PIN, 0); 33 | DEV_SPI_WriteByte(Reg); 34 | DEV_Digital_Write(EPD_CS_PIN, 1); 35 | } 36 | 37 | /****************************************************************************** 38 | function : send data 39 | parameter: 40 | Data : Write data 41 | ******************************************************************************/ 42 | static void LCD_1IN54_SendData_8Bit(UBYTE Data) 43 | { 44 | DEV_Digital_Write(EPD_DC_PIN, 1); 45 | DEV_Digital_Write(EPD_CS_PIN, 0); 46 | DEV_SPI_WriteByte(Data); 47 | DEV_Digital_Write(EPD_CS_PIN, 1); 48 | } 49 | 50 | /****************************************************************************** 51 | function : send data 52 | parameter: 53 | Data : Write data 54 | ******************************************************************************/ 55 | static void LCD_1IN54_SendData_16Bit(UWORD Data) 56 | { 57 | DEV_Digital_Write(EPD_DC_PIN, 1); 58 | DEV_Digital_Write(EPD_CS_PIN, 0); 59 | DEV_SPI_WriteByte((Data >> 8) & 0xFF); 60 | DEV_SPI_WriteByte(Data & 0xFF); 61 | DEV_Digital_Write(EPD_CS_PIN, 1); 62 | } 63 | 64 | /****************************************************************************** 65 | function : Initialize the lcd register 66 | parameter: 67 | ******************************************************************************/ 68 | static void LCD_1IN54_InitReg(void) 69 | { 70 | LCD_1IN54_SendCommand(0x3A); 71 | LCD_1IN54_SendData_8Bit(0x05); 72 | 73 | LCD_1IN54_SendCommand(0xB2); 74 | LCD_1IN54_SendData_8Bit(0x0C); 75 | LCD_1IN54_SendData_8Bit(0x0C); 76 | LCD_1IN54_SendData_8Bit(0x00); 77 | LCD_1IN54_SendData_8Bit(0x33); 78 | LCD_1IN54_SendData_8Bit(0x33); 79 | 80 | LCD_1IN54_SendCommand(0xB7); //Gate Control 81 | LCD_1IN54_SendData_8Bit(0x35); 82 | 83 | LCD_1IN54_SendCommand(0xBB); //VCOM Setting 84 | LCD_1IN54_SendData_8Bit(0x19); 85 | 86 | LCD_1IN54_SendCommand(0xC0); //LCM Control 87 | LCD_1IN54_SendData_8Bit(0x2C); 88 | 89 | LCD_1IN54_SendCommand(0xC2); //VDV and VRH Command Enable 90 | LCD_1IN54_SendData_8Bit(0x01); 91 | LCD_1IN54_SendCommand(0xC3); //VRH Set 92 | LCD_1IN54_SendData_8Bit(0x12); 93 | LCD_1IN54_SendCommand(0xC4); //VDV Set 94 | LCD_1IN54_SendData_8Bit(0x20); 95 | 96 | LCD_1IN54_SendCommand(0xC6); //Frame Rate Control in Normal Mode 97 | LCD_1IN54_SendData_8Bit(0x0F); 98 | 99 | LCD_1IN54_SendCommand(0xD0); // Power Control 1 100 | LCD_1IN54_SendData_8Bit(0xA4); 101 | LCD_1IN54_SendData_8Bit(0xA1); 102 | 103 | LCD_1IN54_SendCommand(0xE0); //Positive Voltage Gamma Control 104 | LCD_1IN54_SendData_8Bit(0xD0); 105 | LCD_1IN54_SendData_8Bit(0x04); 106 | LCD_1IN54_SendData_8Bit(0x0D); 107 | LCD_1IN54_SendData_8Bit(0x11); 108 | LCD_1IN54_SendData_8Bit(0x13); 109 | LCD_1IN54_SendData_8Bit(0x2B); 110 | LCD_1IN54_SendData_8Bit(0x3F); 111 | LCD_1IN54_SendData_8Bit(0x54); 112 | LCD_1IN54_SendData_8Bit(0x4C); 113 | LCD_1IN54_SendData_8Bit(0x18); 114 | LCD_1IN54_SendData_8Bit(0x0D); 115 | LCD_1IN54_SendData_8Bit(0x0B); 116 | LCD_1IN54_SendData_8Bit(0x1F); 117 | LCD_1IN54_SendData_8Bit(0x23); 118 | 119 | LCD_1IN54_SendCommand(0xE1); //Negative Voltage Gamma Control 120 | LCD_1IN54_SendData_8Bit(0xD0); 121 | LCD_1IN54_SendData_8Bit(0x04); 122 | LCD_1IN54_SendData_8Bit(0x0C); 123 | LCD_1IN54_SendData_8Bit(0x11); 124 | LCD_1IN54_SendData_8Bit(0x13); 125 | LCD_1IN54_SendData_8Bit(0x2C); 126 | LCD_1IN54_SendData_8Bit(0x3F); 127 | LCD_1IN54_SendData_8Bit(0x44); 128 | LCD_1IN54_SendData_8Bit(0x51); 129 | LCD_1IN54_SendData_8Bit(0x2F); 130 | LCD_1IN54_SendData_8Bit(0x1F); 131 | LCD_1IN54_SendData_8Bit(0x1F); 132 | LCD_1IN54_SendData_8Bit(0x20); 133 | LCD_1IN54_SendData_8Bit(0x23); 134 | 135 | LCD_1IN54_SendCommand(0x21); //Display Inversion On 136 | 137 | LCD_1IN54_SendCommand(0x11); //Sleep Out 138 | 139 | LCD_1IN54_SendCommand(0x29); //Display On 140 | } 141 | 142 | /******************************************************************************** 143 | function: Set the resolution and scanning method of the screen 144 | parameter: 145 | Scan_dir: Scan direction 146 | ********************************************************************************/ 147 | static void LCD_1IN54_SetAttributes(UBYTE Scan_dir) 148 | { 149 | //Get the screen scan direction 150 | LCD_1IN54.SCAN_DIR = Scan_dir; 151 | UBYTE MemoryAccessReg = 0x00; 152 | 153 | //Get GRAM and LCD width and height 154 | if(Scan_dir == HORIZONTAL) { 155 | LCD_1IN54.HEIGHT = LCD_1IN54_HEIGHT; 156 | LCD_1IN54.WIDTH = LCD_1IN54_WIDTH; 157 | MemoryAccessReg = 0X70; 158 | } else { 159 | LCD_1IN54.HEIGHT = LCD_1IN54_WIDTH; 160 | LCD_1IN54.WIDTH = LCD_1IN54_HEIGHT; 161 | MemoryAccessReg = 0X00; 162 | } 163 | 164 | // Set the read / write scan direction of the frame memory 165 | LCD_1IN54_SendCommand(0x36); //MX, MY, RGB mode 166 | LCD_1IN54_SendData_8Bit(MemoryAccessReg); //0x08 set RGB 167 | } 168 | 169 | /******************************************************************************** 170 | function : Initialize the lcd 171 | parameter: 172 | ********************************************************************************/ 173 | void LCD_1IN54_Init(UBYTE Scan_dir) 174 | { 175 | //Turn on the backlight 176 | // LCD_1IN54_BL_1; 177 | 178 | //Hardware reset 179 | LCD_1IN54_Reset(); 180 | 181 | //Set the resolution and scanning method of the screen 182 | LCD_1IN54_SetAttributes(Scan_dir); 183 | 184 | //Set the initialization register 185 | LCD_1IN54_InitReg(); 186 | } 187 | 188 | /******************************************************************************** 189 | function: Sets the start position and size of the display area 190 | parameter: 191 | Xstart : X direction Start coordinates 192 | Ystart : Y direction Start coordinates 193 | Xend : X direction end coordinates 194 | Yend : Y direction end coordinates 195 | ********************************************************************************/ 196 | void LCD_1IN54_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend) 197 | { 198 | //set the X coordinates 199 | LCD_1IN54_SendCommand(0x2A); 200 | LCD_1IN54_SendData_8Bit((Xstart >> 8) & 0xFF); 201 | LCD_1IN54_SendData_8Bit(Xstart & 0xFF); 202 | LCD_1IN54_SendData_8Bit(((Xend - 1) >> 8) & 0xFF); 203 | LCD_1IN54_SendData_8Bit((Xend - 1) & 0xFF); 204 | 205 | //set the Y coordinates 206 | LCD_1IN54_SendCommand(0x2B); 207 | LCD_1IN54_SendData_8Bit((Ystart >> 8) & 0xFF); 208 | LCD_1IN54_SendData_8Bit(Ystart & 0xFF); 209 | LCD_1IN54_SendData_8Bit(((Yend - 1) >> 8) & 0xFF); 210 | LCD_1IN54_SendData_8Bit((Yend - 1) & 0xFF); 211 | 212 | LCD_1IN54_SendCommand(0X2C); 213 | } 214 | 215 | /****************************************************************************** 216 | function : Clear screen 217 | parameter: 218 | ******************************************************************************/ 219 | void LCD_1IN54_Clear(UWORD Color) 220 | { 221 | UWORD j; 222 | UWORD Image[LCD_1IN54_WIDTH*LCD_1IN54_HEIGHT]; 223 | 224 | Color = ((Color<<8)&0xff00)|(Color>>8); 225 | 226 | for (j = 0; j < LCD_1IN54_HEIGHT*LCD_1IN54_WIDTH; j++) { 227 | Image[j] = Color; 228 | } 229 | 230 | LCD_1IN54_SetWindows(0, 0, LCD_1IN54_WIDTH, LCD_1IN54_HEIGHT); 231 | DEV_Digital_Write(EPD_DC_PIN, 1); 232 | DEV_Digital_Write(EPD_CS_PIN, 0); 233 | for(j = 0; j < LCD_1IN54_HEIGHT; j++){ 234 | DEV_SPI_Write_nByte((uint8_t *)&Image[j*LCD_1IN54_WIDTH], LCD_1IN54_WIDTH*2); 235 | } 236 | DEV_Digital_Write(EPD_CS_PIN, 1); 237 | } 238 | 239 | /****************************************************************************** 240 | function : Sends the image buffer in RAM to displays 241 | parameter: 242 | ******************************************************************************/ 243 | void LCD_1IN54_Display(UWORD *Image) 244 | { 245 | UWORD j; 246 | LCD_1IN54_SetWindows(0, 0, LCD_1IN54_WIDTH, LCD_1IN54_HEIGHT); 247 | DEV_Digital_Write(EPD_DC_PIN, 1); 248 | DEV_Digital_Write(EPD_CS_PIN, 0); 249 | for (j = 0; j < LCD_1IN54_HEIGHT; j++) { 250 | DEV_SPI_Write_nByte((uint8_t *)&Image[j*LCD_1IN54_WIDTH], LCD_1IN54_WIDTH*2); 251 | } 252 | DEV_Digital_Write(EPD_CS_PIN, 1); 253 | } 254 | 255 | void LCD_1IN54_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image) 256 | { 257 | // display 258 | UDOUBLE Addr = 0; 259 | 260 | UWORD j; 261 | LCD_1IN54_SetWindows(Xstart, Ystart, Xend , Yend); 262 | DEV_Digital_Write(EPD_DC_PIN, 1); 263 | DEV_Digital_Write(EPD_CS_PIN, 0); 264 | for (j = Ystart; j < Yend - 1; j++) { 265 | Addr = Xstart + j * LCD_1IN54_WIDTH ; 266 | DEV_SPI_Write_nByte((uint8_t *)&Image[Addr], (Xend-Xstart)*2); 267 | } 268 | DEV_Digital_Write(EPD_CS_PIN, 1); 269 | } 270 | 271 | void LCD_1IN54_DisplayPoint(UWORD X, UWORD Y, UWORD Color) 272 | { 273 | LCD_1IN54_SetWindows(X,Y,X,Y); 274 | LCD_1IN54_SendData_16Bit(Color); 275 | } 276 | 277 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in54.h: -------------------------------------------------------------------------------- 1 | #ifndef __LCD_1IN54_H 2 | #define __LCD_1IN54_H 3 | 4 | #include "DEV_Config.h" 5 | 6 | #define LCD_1IN54_HEIGHT 240 7 | #define LCD_1IN54_WIDTH 240 8 | 9 | #define LCD_1IN54_WIDTH_Byte 240 10 | 11 | #define HORIZONTAL 0 12 | #define VERTICAL 1 13 | 14 | 15 | 16 | typedef struct{ 17 | UWORD WIDTH; 18 | UWORD HEIGHT; 19 | UBYTE SCAN_DIR; 20 | }LCD_1IN54_ATTRIBUTES; 21 | extern LCD_1IN54_ATTRIBUTES LCD_1IN54; 22 | 23 | /******************************************************************************** 24 | function: 25 | Macro definition variable name 26 | ********************************************************************************/ 27 | void LCD_1IN54_Init(UBYTE Scan_dir); 28 | void LCD_1IN54_Clear(UWORD Color); 29 | void LCD_1IN54_Display(UWORD *Image); 30 | void LCD_1IN54_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 31 | void LCD_1IN54_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 32 | 33 | void Handler_1IN54_LCD(int signo); 34 | #endif 35 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_1in8.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : LCD_1in54.c 3 | * | Author : Waveshare team 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | * Used to shield the underlying layers of each master 7 | * and enhance portability 8 | *---------------- 9 | * | This version: V1.0 10 | * | Date : 2020-05-20 11 | * | Info : Basic version 12 | * 13 | ******************************************************************************/ 14 | #ifndef __LCD_1IN8_H 15 | #define __LCD_1IN8_H 16 | 17 | #include "DEV_Config.h" 18 | #include 19 | 20 | #include //itoa() 21 | #include 22 | 23 | 24 | #define LCD_1IN8_HEIGHT 160 25 | #define LCD_1IN8_WIDTH 130 26 | 27 | 28 | #define HORIZONTAL 0 29 | #define VERTICAL 1 30 | 31 | #define LCD_1IN8_SetBacklight(Value) ; 32 | 33 | 34 | typedef struct{ 35 | UWORD WIDTH; 36 | UWORD HEIGHT; 37 | UBYTE SCAN_DIR; 38 | }LCD_1IN8_ATTRIBUTES; 39 | extern LCD_1IN8_ATTRIBUTES LCD_1IN8; 40 | 41 | /******************************************************************************** 42 | function: 43 | Macro definition variable name 44 | ********************************************************************************/ 45 | void LCD_1IN8_Init(UBYTE Scan_dir); 46 | void LCD_1IN8_Clear(UWORD Color); 47 | void LCD_1IN8_Display(UWORD *Image); 48 | void LCD_1IN8_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 49 | void LCD_1IN8_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 50 | 51 | void Handler_1IN8_LCD(int signo); 52 | #endif 53 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_2in.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : LCD_1in14.c 3 | * | Author : Waveshare team 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | * Used to shield the underlying layers of each master 7 | * and enhance portability 8 | *---------------- 9 | * | This version: V1.0 10 | * | Date : 2020-05-20 11 | * | Info : Basic version 12 | * 13 | ******************************************************************************/ 14 | #include "LCD_2IN.h" 15 | #include "DEV_Config.h" 16 | 17 | #include //itoa() 18 | #include 19 | 20 | LCD_2IN_ATTRIBUTES LCD_2IN; 21 | 22 | 23 | /****************************************************************************** 24 | function : Hardware reset 25 | parameter: 26 | ******************************************************************************/ 27 | static void LCD_2IN_Reset(void) 28 | { 29 | DEV_Digital_Write(EPD_RST_PIN, 1); 30 | DEV_Delay_ms(100); 31 | DEV_Digital_Write(EPD_RST_PIN, 0); 32 | DEV_Delay_ms(100); 33 | DEV_Digital_Write(EPD_RST_PIN, 1); 34 | DEV_Delay_ms(100); 35 | } 36 | 37 | /****************************************************************************** 38 | function : send command 39 | parameter: 40 | Reg : Command register 41 | ******************************************************************************/ 42 | static void LCD_2IN_SendCommand(UBYTE Reg) 43 | { 44 | DEV_Digital_Write(EPD_DC_PIN, 0); 45 | DEV_Digital_Write(EPD_CS_PIN, 0); 46 | DEV_SPI_WriteByte(Reg); 47 | DEV_Digital_Write(EPD_CS_PIN, 1); 48 | } 49 | 50 | /****************************************************************************** 51 | function : send data 52 | parameter: 53 | Data : Write data 54 | ******************************************************************************/ 55 | static void LCD_2IN_SendData_8Bit(UBYTE Data) 56 | { 57 | DEV_Digital_Write(EPD_DC_PIN, 1); 58 | DEV_Digital_Write(EPD_CS_PIN, 0); 59 | DEV_SPI_WriteByte(Data); 60 | DEV_Digital_Write(EPD_CS_PIN, 1); 61 | } 62 | 63 | /****************************************************************************** 64 | function : send data 65 | parameter: 66 | Data : Write data 67 | ******************************************************************************/ 68 | static void LCD_2IN_SendData_16Bit(UWORD Data) 69 | { 70 | DEV_Digital_Write(EPD_DC_PIN, 1); 71 | DEV_Digital_Write(EPD_CS_PIN, 0); 72 | DEV_SPI_WriteByte((Data >> 8) & 0xFF); 73 | DEV_SPI_WriteByte(Data & 0xFF); 74 | DEV_Digital_Write(EPD_CS_PIN, 1); 75 | } 76 | 77 | /****************************************************************************** 78 | function : Initialize the lcd register 79 | parameter: 80 | ******************************************************************************/ 81 | static void LCD_2IN_InitReg(void) 82 | { 83 | LCD_2IN_SendCommand(0x36); 84 | LCD_2IN_SendData_8Bit(0x00); 85 | 86 | LCD_2IN_SendCommand(0x3A); 87 | LCD_2IN_SendData_8Bit(0x05); 88 | 89 | LCD_2IN_SendCommand(0x21); 90 | 91 | LCD_2IN_SendCommand(0x2A); 92 | LCD_2IN_SendData_8Bit(0x00); 93 | LCD_2IN_SendData_8Bit(0x00); 94 | LCD_2IN_SendData_8Bit(0x01); 95 | LCD_2IN_SendData_8Bit(0x3F); 96 | 97 | LCD_2IN_SendCommand(0x2B); 98 | LCD_2IN_SendData_8Bit(0x00); 99 | LCD_2IN_SendData_8Bit(0x00); 100 | LCD_2IN_SendData_8Bit(0x00); 101 | LCD_2IN_SendData_8Bit(0xEF); 102 | 103 | LCD_2IN_SendCommand(0xB2); 104 | LCD_2IN_SendData_8Bit(0x0C); 105 | LCD_2IN_SendData_8Bit(0x0C); 106 | LCD_2IN_SendData_8Bit(0x00); 107 | LCD_2IN_SendData_8Bit(0x33); 108 | LCD_2IN_SendData_8Bit(0x33); 109 | 110 | LCD_2IN_SendCommand(0xB7); 111 | LCD_2IN_SendData_8Bit(0x35); 112 | 113 | LCD_2IN_SendCommand(0xBB); 114 | LCD_2IN_SendData_8Bit(0x1F); 115 | 116 | LCD_2IN_SendCommand(0xC0); 117 | LCD_2IN_SendData_8Bit(0x2C); 118 | 119 | LCD_2IN_SendCommand(0xC2); 120 | LCD_2IN_SendData_8Bit(0x01); 121 | 122 | LCD_2IN_SendCommand(0xC3); 123 | LCD_2IN_SendData_8Bit(0x12); 124 | 125 | LCD_2IN_SendCommand(0xC4); 126 | LCD_2IN_SendData_8Bit(0x20); 127 | 128 | LCD_2IN_SendCommand(0xC6); 129 | LCD_2IN_SendData_8Bit(0x0F); 130 | 131 | LCD_2IN_SendCommand(0xD0); 132 | LCD_2IN_SendData_8Bit(0xA4); 133 | LCD_2IN_SendData_8Bit(0xA1); 134 | 135 | LCD_2IN_SendCommand(0xE0); 136 | LCD_2IN_SendData_8Bit(0xD0); 137 | LCD_2IN_SendData_8Bit(0x08); 138 | LCD_2IN_SendData_8Bit(0x11); 139 | LCD_2IN_SendData_8Bit(0x08); 140 | LCD_2IN_SendData_8Bit(0x0C); 141 | LCD_2IN_SendData_8Bit(0x15); 142 | LCD_2IN_SendData_8Bit(0x39); 143 | LCD_2IN_SendData_8Bit(0x33); 144 | LCD_2IN_SendData_8Bit(0x50); 145 | LCD_2IN_SendData_8Bit(0x36); 146 | LCD_2IN_SendData_8Bit(0x13); 147 | LCD_2IN_SendData_8Bit(0x14); 148 | LCD_2IN_SendData_8Bit(0x29); 149 | LCD_2IN_SendData_8Bit(0x2D); 150 | 151 | LCD_2IN_SendCommand(0xE1); 152 | LCD_2IN_SendData_8Bit(0xD0); 153 | LCD_2IN_SendData_8Bit(0x08); 154 | LCD_2IN_SendData_8Bit(0x10); 155 | LCD_2IN_SendData_8Bit(0x08); 156 | LCD_2IN_SendData_8Bit(0x06); 157 | LCD_2IN_SendData_8Bit(0x06); 158 | LCD_2IN_SendData_8Bit(0x39); 159 | LCD_2IN_SendData_8Bit(0x44); 160 | LCD_2IN_SendData_8Bit(0x51); 161 | LCD_2IN_SendData_8Bit(0x0B); 162 | LCD_2IN_SendData_8Bit(0x16); 163 | LCD_2IN_SendData_8Bit(0x14); 164 | LCD_2IN_SendData_8Bit(0x2F); 165 | LCD_2IN_SendData_8Bit(0x31); 166 | LCD_2IN_SendCommand(0x21); 167 | 168 | LCD_2IN_SendCommand(0x11); 169 | 170 | LCD_2IN_SendCommand(0x29); 171 | } 172 | 173 | /******************************************************************************** 174 | function: Set the resolution and scanning method of the screen 175 | parameter: 176 | Scan_dir: Scan direction 177 | ********************************************************************************/ 178 | static void LCD_2IN_SetAttributes(UBYTE Scan_dir) 179 | { 180 | //Get the screen scan direction 181 | LCD_2IN.SCAN_DIR = Scan_dir; 182 | UBYTE MemoryAccessReg = 0x00; 183 | 184 | //Get GRAM and LCD width and height 185 | if(Scan_dir == HORIZONTAL) { 186 | LCD_2IN.HEIGHT = LCD_2IN_WIDTH; 187 | LCD_2IN.WIDTH = LCD_2IN_HEIGHT; 188 | MemoryAccessReg = 0X70; 189 | } else { 190 | LCD_2IN.HEIGHT = LCD_2IN_HEIGHT; 191 | LCD_2IN.WIDTH = LCD_2IN_WIDTH; 192 | MemoryAccessReg = 0X00; 193 | } 194 | 195 | // Set the read / write scan direction of the frame memory 196 | LCD_2IN_SendCommand(0x36); //MX, MY, RGB mode 197 | LCD_2IN_SendData_8Bit(MemoryAccessReg); //0x08 set RGB 198 | } 199 | 200 | /******************************************************************************** 201 | function : Initialize the lcd 202 | parameter: 203 | ********************************************************************************/ 204 | void LCD_2IN_Init(UBYTE Scan_dir) 205 | { 206 | DEV_SET_PWM(90); 207 | //Hardware reset 208 | LCD_2IN_Reset(); 209 | 210 | //Set the resolution and scanning method of the screen 211 | LCD_2IN_SetAttributes(Scan_dir); 212 | 213 | //Set the initialization register 214 | LCD_2IN_InitReg(); 215 | } 216 | 217 | /******************************************************************************** 218 | function: Sets the start position and size of the display area 219 | parameter: 220 | Xstart : X direction Start coordinates 221 | Ystart : Y direction Start coordinates 222 | Xend : X direction end coordinates 223 | Yend : Y direction end coordinates 224 | ********************************************************************************/ 225 | void LCD_2IN_SetWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend) 226 | { 227 | //set the X coordinates 228 | LCD_2IN_SendCommand(0x2A); 229 | LCD_2IN_SendData_8Bit(Xstart >>8); 230 | LCD_2IN_SendData_8Bit(Xstart & 0xff); 231 | LCD_2IN_SendData_8Bit((Xend - 1) >> 8); 232 | LCD_2IN_SendData_8Bit((Xend-1) & 0xFF); 233 | 234 | //set the Y coordinates 235 | LCD_2IN_SendCommand(0x2B); 236 | LCD_2IN_SendData_8Bit(Ystart >>8); 237 | LCD_2IN_SendData_8Bit(Ystart & 0xff); 238 | LCD_2IN_SendData_8Bit((Yend - 1) >> 8); 239 | LCD_2IN_SendData_8Bit((Yend - 1) & 0xff); 240 | 241 | LCD_2IN_SendCommand(0X2C); 242 | // printf("%d %d\r\n",x,y); 243 | } 244 | 245 | /****************************************************************************** 246 | function : Clear screen 247 | parameter: 248 | ******************************************************************************/ 249 | void LCD_2IN_Clear(UWORD Color) 250 | { 251 | UWORD i; 252 | UWORD image[LCD_2IN_HEIGHT]; 253 | for(i=0;i>8 | (Color&0xff)<<8; 255 | } 256 | UBYTE *p = (UBYTE *)(image); 257 | LCD_2IN_SetWindows(0, 0, LCD_2IN_HEIGHT,LCD_2IN_WIDTH); 258 | DEV_Digital_Write(EPD_DC_PIN, 1); 259 | DEV_Digital_Write(EPD_CS_PIN, 0); 260 | for(i = 0; i < LCD_2IN_WIDTH; i++){ 261 | DEV_SPI_Write_nByte(p,LCD_2IN_HEIGHT*2); 262 | } 263 | DEV_Digital_Write(EPD_CS_PIN, 1); 264 | } 265 | 266 | /****************************************************************************** 267 | function : Sends the image buffer in RAM to displays 268 | parameter: 269 | ******************************************************************************/ 270 | void LCD_2IN_Display(UBYTE *Image) 271 | { 272 | UWORD j; 273 | LCD_2IN_SetWindows(0, 0,LCD_2IN.WIDTH,LCD_2IN.HEIGHT ); 274 | DEV_Digital_Write(EPD_DC_PIN, 1); 275 | DEV_Digital_Write(EPD_CS_PIN, 0); 276 | for (j = 0; j < LCD_2IN.WIDTH; j++) { 277 | DEV_SPI_Write_nByte((UBYTE *)Image+LCD_2IN.HEIGHT*2*j,LCD_2IN.HEIGHT*2); 278 | } 279 | DEV_Digital_Write(EPD_CS_PIN, 1); 280 | LCD_2IN_SendCommand(0x29); 281 | } 282 | 283 | void LCD_2IN_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image) 284 | { 285 | // display 286 | UDOUBLE Addr = 0; 287 | 288 | UWORD j; 289 | LCD_2IN_SetWindows(Xstart, Ystart, Xend , Yend); 290 | DEV_Digital_Write(EPD_DC_PIN, 1); 291 | DEV_Digital_Write(EPD_CS_PIN, 0); 292 | for (j = Ystart; j < Yend - 1; j++) { 293 | Addr = Xstart + j * LCD_2IN.WIDTH ; 294 | DEV_SPI_Write_nByte((uint8_t *)&Image[Addr], (Xend-Xstart)*2); 295 | } 296 | DEV_Digital_Write(EPD_CS_PIN, 1); 297 | } 298 | 299 | void LCD_2IN_DisplayPoint(UWORD X, UWORD Y, UWORD Color) 300 | { 301 | LCD_2IN_SetWindows(X,Y,X,Y); 302 | LCD_2IN_SendData_16Bit(Color); 303 | } 304 | 305 | void Handler_2IN_LCD(int signo) 306 | { 307 | //System Exit 308 | printf("\r\nHandler:Program stop\r\n"); 309 | DEV_Module_Exit(); 310 | exit(0); 311 | } 312 | -------------------------------------------------------------------------------- /c/lib/LCD/LCD_2in.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : LCD_1in54.c 3 | * | Author : Waveshare team 4 | * | Function : Hardware underlying interface 5 | * | Info : 6 | * Used to shield the underlying layers of each master 7 | * and enhance portability 8 | *---------------- 9 | * | This version: V1.0 10 | * | Date : 2020-05-20 11 | * | Info : Basic version 12 | * 13 | ******************************************************************************/ 14 | #ifndef __LCD_2IN_H 15 | #define __LCD_2IN_H 16 | 17 | #include "DEV_Config.h" 18 | #include 19 | 20 | #include //itoa() 21 | #include 22 | 23 | 24 | #define LCD_2IN_HEIGHT 240 25 | #define LCD_2IN_WIDTH 320 26 | 27 | 28 | #define HORIZONTAL 0 29 | #define VERTICAL 1 30 | 31 | #define LCD_2IN_SetBacklight(Value) ; 32 | 33 | 34 | typedef struct{ 35 | UWORD WIDTH; 36 | UWORD HEIGHT; 37 | UBYTE SCAN_DIR; 38 | }LCD_2IN_ATTRIBUTES; 39 | extern LCD_2IN_ATTRIBUTES LCD_2IN; 40 | 41 | /******************************************************************************** 42 | function: 43 | Macro definition variable name 44 | ********************************************************************************/ 45 | void LCD_2IN_Init(UBYTE Scan_dir); 46 | void LCD_2IN_Clear(UWORD Color); 47 | void LCD_2IN_Display(UBYTE *Image); 48 | void LCD_2IN_DisplayWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD *Image); 49 | void LCD_2IN_DisplayPoint(UWORD X, UWORD Y, UWORD Color); 50 | 51 | void Handler_2IN_LCD(int signo); 52 | #endif 53 | -------------------------------------------------------------------------------- /c/lib/OLED/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 查找当前目录下的所有源文件 2 | # 并将名称保存到 DIR_ePaper_SRCS 变量 3 | aux_source_directory(. DIR_OLED_SRCS) 4 | 5 | include_directories(../Config) 6 | 7 | # 生成链接库 8 | add_library(OLED ${DIR_OLED_SRCS}) 9 | target_link_libraries(OLED PUBLIC Config) -------------------------------------------------------------------------------- /c/lib/OLED/OLED_1in3_c.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : OLED_1in3_c.c 3 | * | Author : 4 | * | Function : 1.3inch OLED Drive function 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | * ----------------------------------------------------------------------------- 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documnetation files (the "Software"), to deal 14 | # in the Software without restriction, including without limitation the rights 15 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | # copies of the Software, and to permit persons to whom the Software is 17 | # furished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | # THE SOFTWARE. 29 | ******************************************************************************/ 30 | #include "OLED_1in3_c.h" 31 | #include "stdio.h" 32 | 33 | /******************************************************************************* 34 | function: 35 | Hardware reset 36 | *******************************************************************************/ 37 | static void I2C_Write_Byte( uint8_t Value,uint8_t reg) 38 | { 39 | DEV_I2C_Write(0x3c, reg, Value); 40 | } 41 | 42 | static void OLED_Reset(void) 43 | { 44 | OLED_RST_1; 45 | DEV_Delay_ms(100); 46 | OLED_RST_0; 47 | DEV_Delay_ms(100); 48 | OLED_RST_1; 49 | DEV_Delay_ms(100); 50 | } 51 | 52 | /******************************************************************************* 53 | function: 54 | Write register address and data 55 | *******************************************************************************/ 56 | static void OLED_WriteReg(uint8_t Reg) 57 | { 58 | #if USE_SPI 59 | OLED_DC_0; 60 | OLED_CS_0; 61 | DEV_SPI_WriteByte(Reg); 62 | OLED_CS_1; 63 | #elif USE_IIC 64 | I2C_Write_Byte(Reg,IIC_CMD); 65 | #endif 66 | } 67 | 68 | static void OLED_WriteData(uint8_t Data) 69 | { 70 | #if USE_SPI 71 | OLED_DC_1; 72 | OLED_CS_0; 73 | DEV_SPI_WriteByte(Data); 74 | OLED_CS_1; 75 | #elif USE_IIC 76 | I2C_Write_Byte(Data,IIC_RAM); 77 | #endif 78 | } 79 | 80 | /******************************************************************************* 81 | function: 82 | Common register initialization 83 | *******************************************************************************/ 84 | static void OLED_InitReg(void) 85 | { 86 | OLED_WriteReg(0xae); /*turn off OLED display*/ 87 | 88 | OLED_WriteReg(0x00); /*set lower column address*/ 89 | OLED_WriteReg(0x10); /*set higher column address*/ 90 | 91 | OLED_WriteReg(0xB0); /*set page address*/ 92 | 93 | OLED_WriteReg(0xdc); /*set display start line*/ 94 | OLED_WriteReg(0x00); 95 | 96 | OLED_WriteReg(0x81); /*contract control*/ 97 | OLED_WriteReg(0x6f); /*128*/ 98 | OLED_WriteReg(0x21); /* Set Memory addressing mode (0x20/0x21) */ 99 | 100 | OLED_WriteReg(0xa0); /*set segment remap*/ 101 | OLED_WriteReg(0xc0); /*Com scan direction*/ 102 | OLED_WriteReg(0xa4); /*Disable Entire Display On (0xA4/0xA5)*/ 103 | 104 | OLED_WriteReg(0xa6); /*normal / reverse*/ 105 | OLED_WriteReg(0xa8); /*multiplex ratio*/ 106 | OLED_WriteReg(0x3f); /*duty = 1/64*/ 107 | 108 | OLED_WriteReg(0xd3); /*set display offset*/ 109 | OLED_WriteReg(0x60); 110 | 111 | OLED_WriteReg(0xd5); /*set osc division*/ 112 | OLED_WriteReg(0x41); 113 | 114 | OLED_WriteReg(0xd9); /*set pre-charge period*/ 115 | OLED_WriteReg(0x22); 116 | 117 | OLED_WriteReg(0xdb); /*set vcomh*/ 118 | OLED_WriteReg(0x35); 119 | 120 | OLED_WriteReg(0xad); /*set charge pump enable*/ 121 | OLED_WriteReg(0x8a); /*Set DC-DC enable (a=0:disable; a=1:enable) */ 122 | } 123 | 124 | 125 | /******************************************************************************** 126 | function: 127 | initialization 128 | ********************************************************************************/ 129 | void OLED_1in3_C_Init() 130 | { 131 | //Hardware reset 132 | OLED_Reset(); 133 | 134 | //Set the initialization register 135 | OLED_InitReg(); 136 | DEV_Delay_ms(200); 137 | 138 | //Turn on the OLED display 139 | OLED_WriteReg(0xaf); 140 | } 141 | 142 | 143 | /******************************************************************************** 144 | function: 145 | Clear screen 146 | ********************************************************************************/ 147 | void OLED_1in3_C_Clear() 148 | { 149 | UWORD Width, Height, column; 150 | Width = (OLED_1in3_C_WIDTH % 8 == 0)? (OLED_1in3_C_WIDTH / 8 ): (OLED_1in3_C_WIDTH / 8 + 1); 151 | Height = OLED_1in3_C_HEIGHT; 152 | OLED_WriteReg(0xb0); //Set the row start address 153 | for (UWORD j = 0; j < Height; j++) { 154 | column = 63 - j; 155 | OLED_WriteReg(0x00 + (column & 0x0f)); //Set column low start address 156 | OLED_WriteReg(0x10 + (column >> 4)); //Set column higt start address 157 | for (UWORD i = 0; i < Width; i++) { 158 | OLED_WriteData(0x00); 159 | } 160 | } 161 | } 162 | 163 | /******************************************************************************** 164 | function: 165 | reverse a byte data 166 | ********************************************************************************/ 167 | static UBYTE reverse(UBYTE temp) 168 | { 169 | temp = ((temp & 0x55) << 1) | ((temp & 0xaa) >> 1); 170 | temp = ((temp & 0x33) << 2) | ((temp & 0xcc) >> 2); 171 | temp = ((temp & 0x0f) << 4) | ((temp & 0xf0) >> 4); 172 | return temp; 173 | } 174 | 175 | /******************************************************************************** 176 | function: 177 | Update all memory to OLED 178 | ********************************************************************************/ 179 | void OLED_1in3_C_Display(const UBYTE *Image) 180 | { 181 | UWORD Width, Height, column, temp; 182 | Width = (OLED_1in3_C_WIDTH % 8 == 0)? (OLED_1in3_C_WIDTH / 8 ): (OLED_1in3_C_WIDTH / 8 + 1); 183 | Height = OLED_1in3_C_HEIGHT; 184 | OLED_WriteReg(0xb0); //Set the row start address 185 | for (UWORD j = 0; j < Height; j++) { 186 | column = 63 - j; 187 | OLED_WriteReg(0x00 + (column & 0x0f)); //Set column low start address 188 | OLED_WriteReg(0x10 + (column >> 4)); //Set column higt start address 189 | for (UWORD i = 0; i < Width; i++) { 190 | temp = Image[i + j * Width]; 191 | // printf("0x%x \r\n",temp); 192 | temp = reverse(temp); //reverse the buffer 193 | OLED_WriteData(temp); 194 | } 195 | } 196 | } 197 | 198 | 199 | -------------------------------------------------------------------------------- /c/lib/OLED/OLED_1in3_c.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : OLED_1in3_c.h 3 | * | Author : 4 | * | Function : 1.3inch OLEDDrive function 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | * ----------------------------------------------------------------------------- 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documnetation files (the "Software"), to deal 14 | # in the Software without restriction, including without limitation the rights 15 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | # copies of the Software, and to permit persons to whom the Software is 17 | # furished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | # THE SOFTWARE. 29 | ******************************************************************************/ 30 | #ifndef __OLED_1IN3_C_H 31 | #define __OLED_1IN3_C_H 32 | 33 | #include "DEV_Config.h" 34 | 35 | /******************************************************************************** 36 | function: 37 | Define the full screen height length of the display 38 | ********************************************************************************/ 39 | #define USE_SPI 1 40 | #define USE_IIC 0 41 | 42 | #define IIC_CMD 0X00 43 | #define IIC_RAM 0X40 44 | 45 | 46 | #define OLED_1in3_C_WIDTH 128//OLED width 47 | #define OLED_1in3_C_HEIGHT 64 //OLED height 48 | 49 | #define OLED_CS_0 DEV_Digital_Write(EPD_CS_PIN,0) 50 | #define OLED_CS_1 DEV_Digital_Write(EPD_CS_PIN,1) 51 | 52 | #define OLED_RST_0 DEV_Digital_Write(EPD_RST_PIN,0) 53 | #define OLED_RST_1 DEV_Digital_Write(EPD_RST_PIN,1) 54 | 55 | #define OLED_DC_0 DEV_Digital_Write(EPD_DC_PIN,0) 56 | #define OLED_DC_1 DEV_Digital_Write(EPD_DC_PIN,1) 57 | 58 | 59 | void OLED_1in3_C_Init(void); 60 | void OLED_1in3_C_Clear(void); 61 | void OLED_1in3_C_Display(const UBYTE *Image); 62 | 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /c/lib/OLED/OLED_2in23.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : OLED_2in23_c.c 3 | * | Author : 4 | * | Function : 2.23inch OLED Drive function 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | * ----------------------------------------------------------------------------- 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documnetation files (the "Software"), to deal 14 | # in the Software without restriction, including without limitation the rights 15 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | # copies of the Software, and to permit persons to whom the Software is 17 | # furished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | # THE SOFTWARE. 29 | ******************************************************************************/ 30 | #include "OLED_2in23.h" 31 | #include "stdio.h" 32 | 33 | static uint8_t s_chDispalyBuffer[128][4]; 34 | 35 | /******************************************************************************* 36 | function: 37 | Hardware reset 38 | *******************************************************************************/ 39 | static void I2C_Write_Byte( uint8_t Value,uint8_t reg) 40 | { 41 | DEV_I2C_Write(0x3c, reg, Value); 42 | } 43 | 44 | static void OLED_Reset(void) 45 | { 46 | OLED_RST_1; 47 | DEV_Delay_ms(100); 48 | OLED_RST_0; 49 | DEV_Delay_ms(100); 50 | OLED_CS_1; 51 | OLED_DC_0; 52 | OLED_RST_1; 53 | DEV_Delay_ms(100); 54 | } 55 | 56 | /******************************************************************************* 57 | function: 58 | Write register address and data 59 | *******************************************************************************/ 60 | static void OLED_WriteReg(uint8_t Reg) 61 | { 62 | #if USE_SPI 63 | OLED_DC_0; 64 | OLED_CS_0; 65 | DEV_SPI_WriteByte(Reg); 66 | OLED_CS_1; 67 | #elif USE_IIC 68 | I2C_Write_Byte(Reg,IIC_CMD); 69 | #endif 70 | } 71 | 72 | static void OLED_WriteData(uint8_t Data) 73 | { 74 | #if USE_SPI 75 | OLED_DC_1; 76 | OLED_CS_0; 77 | DEV_SPI_WriteByte(Data); 78 | OLED_CS_1; 79 | #elif USE_IIC 80 | I2C_Write_Byte(Data,IIC_RAM); 81 | #endif 82 | } 83 | 84 | /******************************************************************************* 85 | function: 86 | Common register initialization 87 | *******************************************************************************/ 88 | static void OLED_InitReg(void) 89 | { 90 | OLED_WriteReg(0xAE); /*turn off OLED display*/ 91 | 92 | OLED_WriteReg(0x04); /*turn off OLED display*/ 93 | 94 | OLED_WriteReg(0x10); /*turn off OLED display*/ 95 | 96 | OLED_WriteReg(0x40); /*set lower column address*/ 97 | OLED_WriteReg(0x81); /*set higher column address*/ 98 | OLED_WriteReg(0x80); //--set start line address Set Mapping RAM Display Start Line (0x00~0x3F, SSD1305_CMD) 99 | OLED_WriteReg(0xA1); //--set contrast control register 100 | OLED_WriteReg(0xA6); // Set SEG Output Current Brightness ��ת 101 | OLED_WriteReg(0xA8); //--Set SEG/Column Mapping 102 | OLED_WriteReg(0x1F); //Set COM/Row Scan Direction 103 | OLED_WriteReg(0xC0); //--set normal display ����ɨ�跴�� 104 | OLED_WriteReg(0xD3); //--set multiplex ratio(1 to 64) 105 | OLED_WriteReg(0x00); //--1/64 duty 106 | OLED_WriteReg(0xD5); //-set display offset Shift Mapping RAM Counter (0x00~0x3F) 107 | OLED_WriteReg(0xF0); //-not offset 108 | OLED_WriteReg(0xD8); //--set display clock divide ratio/oscillator frequency 109 | OLED_WriteReg(0x05); //--set divide ratio, Set Clock as 100 Frames/Sec 110 | OLED_WriteReg(0xD9); //--set pre-charge period 111 | OLED_WriteReg(0xC2); //Set Pre-Charge as 15 Clocks & Discharge as 1 Clock 112 | OLED_WriteReg(0xDA); //--set com pins hardware configuration 113 | OLED_WriteReg(0x12); 114 | OLED_WriteReg(0xDB); /*set vcomh*/ 115 | OLED_WriteReg(0x08); //Set VCOM Deselect Level 116 | 117 | OLED_WriteReg(0xAF); //-Set Page Addressing Mode (0x00/0x01/0x02) 118 | OLED_2in23_Clear(0x00); 119 | 120 | } 121 | 122 | 123 | /******************************************************************************** 124 | function: 125 | initialization 126 | ********************************************************************************/ 127 | void OLED_2in23_Init() 128 | { 129 | //Hardware reset 130 | OLED_Reset(); 131 | 132 | //Set the initialization register 133 | OLED_InitReg(); 134 | DEV_Delay_ms(200); 135 | 136 | //Turn on the OLED display 137 | OLED_WriteReg(0xAF); 138 | } 139 | 140 | 141 | /******************************************************************************** 142 | function: 143 | Clear screen 144 | ********************************************************************************/ 145 | void OLED_2in23_refresh_gram() 146 | { 147 | UWORD i, j; 148 | 149 | for (i = 0; i < 4; i ++) { 150 | OLED_WriteReg(0xB0 + i); 151 | OLED_WriteReg(0x04); 152 | OLED_WriteReg(0x10); 153 | for (j = 0; j < 128; j ++) { 154 | 155 | OLED_WriteData(s_chDispalyBuffer[j][i]); 156 | } 157 | } 158 | } 159 | 160 | 161 | 162 | 163 | void OLED_2in23_Clear(uint8_t chFill) 164 | { 165 | uint8_t i, j; 166 | 167 | for (i = 0; i < 4; i ++) { 168 | OLED_WriteReg(0xB0 + i); 169 | OLED_WriteReg(0x04); 170 | OLED_WriteReg(0x10); 171 | for (j = 0; j < 128; j ++) { 172 | s_chDispalyBuffer[j][i] = chFill; 173 | } 174 | } 175 | 176 | OLED_2in23_refresh_gram(); 177 | } 178 | 179 | /******************************************************************************** 180 | function: 181 | Update all memory to OLED 182 | ********************************************************************************/ 183 | 184 | void OLED_2in23_draw_point(uint8_t chXpos, uint8_t chYpos, uint8_t chPoint) 185 | { 186 | uint8_t chPos, chBx, chTemp = 0; 187 | 188 | if (chXpos > 127 || chYpos > 31) { 189 | return; 190 | } 191 | chPos = 7 - chYpos / 8; // 192 | chBx = chYpos % 8; 193 | chTemp = 1 << (7 - chBx); 194 | 195 | if (chPoint) { 196 | s_chDispalyBuffer[chXpos][chPos] |= chTemp; 197 | 198 | } else { 199 | s_chDispalyBuffer[chXpos][chPos] &= ~chTemp; 200 | } 201 | 202 | } 203 | 204 | 205 | void OLED_2in23_draw_bitmap(unsigned char x,unsigned char y,const unsigned char *pBmp, 206 | unsigned char chWidth,unsigned char chHeight) 207 | { 208 | uint16_t i, j, byteWidth = (chWidth + 7)/8; 209 | for(j = 0; j < chHeight; j ++){ 210 | for(i = 0; i < chWidth; i ++ ) { 211 | if(*(pBmp + j * byteWidth + i / 8) & (128 >> (i & 7))) { 212 | OLED_2in23_draw_point(x+i, y+j, 1); 213 | }else { 214 | OLED_2in23_draw_point(x+i, y+j, 0); 215 | } 216 | } 217 | } 218 | OLED_2in23_refresh_gram(); 219 | } 220 | 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /c/lib/OLED/OLED_2in23.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * | File : OLED_1in3_c.h 3 | * | Author : 4 | * | Function : 1.3inch OLEDDrive function 5 | * | Info : 6 | *---------------- 7 | * | This version: V1.0 8 | * | Date : 2021-03-16 9 | * | Info : 10 | * ----------------------------------------------------------------------------- 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documnetation files (the "Software"), to deal 14 | # in the Software without restriction, including without limitation the rights 15 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | # copies of the Software, and to permit persons to whom the Software is 17 | # furished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | # THE SOFTWARE. 29 | ******************************************************************************/ 30 | #ifndef __OLED_2IN23_C_H 31 | #define __OLED_2IN23_C_H 32 | 33 | #include "DEV_Config.h" 34 | 35 | /******************************************************************************** 36 | function: 37 | Define the full screen height length of the display 38 | ********************************************************************************/ 39 | #define USE_SPI 1 40 | #define USE_IIC 0 41 | 42 | #define IIC_CMD 0X00 43 | #define IIC_RAM 0X40 44 | 45 | 46 | #define OLED_2in23_WIDTH 128//OLED width 47 | #define OLED_2in23_HEIGHT 32 //OLED height 48 | 49 | #define OLED_CS_0 DEV_Digital_Write(EPD_CS_PIN,0) 50 | #define OLED_CS_1 DEV_Digital_Write(EPD_CS_PIN,1) 51 | 52 | #define OLED_RST_0 DEV_Digital_Write(EPD_RST_PIN,0) 53 | #define OLED_RST_1 DEV_Digital_Write(EPD_RST_PIN,1) 54 | 55 | #define OLED_DC_0 DEV_Digital_Write(EPD_DC_PIN,0) 56 | #define OLED_DC_1 DEV_Digital_Write(EPD_DC_PIN,1) 57 | 58 | 59 | 60 | void OLED_2in23_Init(void); 61 | void OLED_2in23_Clear(uint8_t chFill); 62 | void OLED_2in23_draw_point(uint8_t chXpos, uint8_t chYpos, uint8_t chPoint); 63 | void OLED_2in23_draw_bitmap(unsigned char x,unsigned char y,const unsigned char *pBmp, 64 | unsigned char chWidth,unsigned char chHeight); 65 | void OLED_2in23_refresh_gram(void); 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /c/main.c: -------------------------------------------------------------------------------- 1 | #include "EPD_Test.h" //Examples 2 | 3 | int main(void) 4 | { 5 | //OLED 6 | //OLED_1in3_C_test(); 7 | //OLED_2in23_test(); 8 | 9 | 10 | //LCD 11 | //LCD_0in96_test(); 12 | //LCD_1in14_test(); 13 | //LCD_1in3_test(); 14 | //LCD_1in44_test(); 15 | //LCD_1in8_test(); 16 | LCD_2in_test(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /c/pico_sdk_import.cmake: -------------------------------------------------------------------------------- 1 | # This is a copy of /external/pico_sdk_import.cmake 2 | 3 | # This can be dropped into an external project to help locate this SDK 4 | # It should be include()ed prior to project() 5 | 6 | if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH)) 7 | set(PICO_SDK_PATH $ENV{PICO_SDK_PATH}) 8 | message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')") 9 | endif () 10 | 11 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT)) 12 | set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT}) 13 | message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')") 14 | endif () 15 | 16 | if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH)) 17 | set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH}) 18 | message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") 19 | endif () 20 | 21 | set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the PICO SDK") 22 | set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO SDK from git if not otherwise locatable") 23 | set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") 24 | 25 | if (NOT PICO_SDK_PATH) 26 | if (PICO_SDK_FETCH_FROM_GIT) 27 | include(FetchContent) 28 | set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR}) 29 | if (PICO_SDK_FETCH_FROM_GIT_PATH) 30 | get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") 31 | endif () 32 | FetchContent_Declare( 33 | pico_sdk 34 | GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk 35 | GIT_TAG master 36 | ) 37 | if (NOT pico_sdk) 38 | message("Downloading PICO SDK") 39 | FetchContent_Populate(pico_sdk) 40 | set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR}) 41 | endif () 42 | set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) 43 | else () 44 | message(FATAL_ERROR 45 | "PICO SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git. \r\nexport PICO_SDK_PATH=../../pico-sdk" 46 | ) 47 | endif () 48 | endif () 49 | 50 | get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") 51 | if (NOT EXISTS ${PICO_SDK_PATH}) 52 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found") 53 | endif () 54 | 55 | set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake) 56 | if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE}) 57 | message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the PICO SDK") 58 | endif () 59 | 60 | set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the PICO SDK" FORCE) 61 | 62 | include(${PICO_SDK_INIT_CMAKE_FILE}) 63 | -------------------------------------------------------------------------------- /c/uf2/LCD_1in14_test.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/LCD_1in14_test.uf2 -------------------------------------------------------------------------------- /c/uf2/LCD_1in3.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/LCD_1in3.uf2 -------------------------------------------------------------------------------- /c/uf2/LCD_1in44_test.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/LCD_1in44_test.uf2 -------------------------------------------------------------------------------- /c/uf2/LCD_1in8_test.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/LCD_1in8_test.uf2 -------------------------------------------------------------------------------- /c/uf2/LCD_2in_test.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/LCD_2in_test.uf2 -------------------------------------------------------------------------------- /c/uf2/OLED_1in3_C_test_I2C.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/OLED_1in3_C_test_I2C.uf2 -------------------------------------------------------------------------------- /c/uf2/OLED_1in3_C_test_SPI.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/OLED_1in3_C_test_SPI.uf2 -------------------------------------------------------------------------------- /c/uf2/OLED_2in23_test_I2C.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/OLED_2in23_test_I2C.uf2 -------------------------------------------------------------------------------- /c/uf2/OLED_2in23_test_SPI .uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/c/uf2/OLED_2in23_test_SPI .uf2 -------------------------------------------------------------------------------- /waveshare_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/waveshare/Pico_code/c50bc57040a33ee9540e993a2bbe99bf6e621fbd/waveshare_logo.png --------------------------------------------------------------------------------