显示屏参数:1.6寸130×130分辨率,驱动为 SSD1283A,TFT显示屏。
显示屏官方说明:
主控板:ESP8266或ESP32、或ESP12等
我使用的主控板是NodeMCU ESP12F,接线图定义如下:
1 2 3 4 5 6 7 |
#define MODEL SSD1283A #define CS D8 #define CD D3 // marked A0 on the SSD1283A breakout #define RST D4 #define LED -1 LCDWIKI_SPI mylcd(MODEL,CS,CD,RST,LED); |
该定义主要是把CS CD RST LED进行端口指定,VCC和GND都是通用的,接线图如下(忽略掉BH1750的接线):
然后下载库文件,放在“我的文档”中的“Arduino\Library”文件夹里,下载地址:lcdwiki (github.com)
如图:
然后载入案例进行测试。
案例一:显示文字和简单图形:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
// wemos_130x130_TFT_SSD1283A_graphic_functions // Floris Wouterlood // 29 february 2020 // see: https://github.com/gitcnd/LCDWIKI_GUI/blob/master/Document/LCDWIKI%20GUI%20lib%20Manual.pdf // demo of several functions suppied by the LCDWIKI.GUI // public domain #include <LCDWIKI_GUI.h> //Core graphics library #include <LCDWIKI_SPI.h> //Hardware-specific library // for ESP8266 NodeMCU and Wemos D1 Mini D1 #define MODEL SSD1283A #define CS D8 #define CD D3 // marked A0 on the SSD1283A breakout #define RST D4 #define LED -1 LCDWIKI_SPI mylcd(MODEL,CS,CD,RST,LED); #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF void setup() { mylcd.Init_LCD(); mylcd.Fill_Screen(BLACK); } void loop() { mylcd.Set_Text_Mode(0); mylcd.Fill_Screen(0x0000); mylcd.Set_Text_colour(RED); mylcd.Set_Text_Back_colour(BLACK); mylcd.Set_Text_Size(2); mylcd.Print_String("TAHOLAB.COM", 0, 0); mylcd.Fill_Rect(20,20,20,20,YELLOW); mylcd.Set_Draw_color(YELLOW); mylcd.Draw_Round_Rectangle (70,70,100,100,6); mylcd.Set_Draw_color(GREEN); mylcd.Draw_Fast_VLine (80,80,30); mylcd.Draw_Fast_HLine (80,80,30); mylcd.Draw_Line (125,125,20,70); mylcd.Draw_Circle (70,40,16); mylcd.Draw_Circle (70,39,17); mylcd.Draw_Circle (105,40,16); mylcd.Draw_Circle (105,39,17); mylcd.Set_Draw_color(WHITE); mylcd.Fill_Circle (73,46,6); mylcd.Fill_Circle (102,46,6); mylcd.Set_Draw_color(CYAN); mylcd.Draw_Triangle (5,110, 15,120,50,16); mylcd.Set_Draw_color(MAGENTA); mylcd.Fill_Triangle (90,125, 20,120,50,99); mylcd.Print_String("YES!",40,70); delay(23000); } |
效果:
源代码下载:
案例二:显示图片
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
// IMPORTANT: LCDWIKI_SPI LIBRARY MUST BE SPECIFICALLY // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD. //This program is a demo of how to display scroll. //when using the BREAKOUT BOARD only and using these hardware spi lines to the LCD, //the SDA pin and SCK pin is defined by the system and can't be modified. //if you don't need to control the LED pin,you can set it to 3.3V and set the pin definition to -1. //other pins can be defined by youself,for example //pin usage as follow: // CS A0/DC RESET SDA SCK LED VCC GND //ESP8266 D1 nimi D1 D3 D2 D7 D5 D4 5V/3.3V GND //Remember to set the pins to suit your display module! /******************************************************************************** @attention THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. **********************************************************************************/ #include <LCDWIKI_GUI.h> //Core graphics library #include <LCDWIKI_SPI.h> //Hardware-specific library #include "font.h" #include "cat.h" #include "kitty.h" //#include <LCDWIKI_GUI.h> //Core graphics library //#include <LCDWIKI_SPI.h> //Hardware-specific library // for ESP8266,ESP12,ESP32 ...etc #define MODEL SSD1283A #define CS D8 #define CD D3 // marked A0 on the SSD1283A breakout #define RST D4 #define LED -1 LCDWIKI_SPI my_lcd(MODEL,CS,CD,RST,LED); //the definiens of hardware spi mode as follow: //if the IC model is known or the modules is unreadable,you can use this constructed function //LCDWIKI_SPI my_lcd(MODEL, CS, CD, RST, LED); #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF char *color_name[] = { "BLUE", "GREEN", "RED", "WHITE" , "CYAN", "MAGENTA", "YELLOW"}; uint16_t color_mask[] = { 0x001F, 0x07E0, 0xF800, 0xFFFF, 0x07FF, 0xF81F, 0xFFE0 }; // covert images // http://www.rinkydinkelectronics.com/_t_doimageconverter565.php void show_pic(void) { int i; my_lcd.Set_Addr_Window(0, 0, 129 , 129); my_lcd.Push_Any_Color((uint16_t*)kitty, 16900, 1, 1); // my_lcd.Set_Addr_Window(0, 0, 9, 9); // my_lcd.Push_Any_Color((uint8_t*)ran, 10000, 1, 1); // my_lcd.Draw_Bit_Map( 0, 0, 160, 160, cat, 1); // my_lcd.Draw_Rectangle(20, 40, 80, 80); } void setup() { Serial.begin(9600); my_lcd.Init_LCD(); my_lcd.Fill_Screen(BLACK); show_pic(); } void loop() { } |
效果图:
源代码下载:
自定义图片的网站:Rinky-Dink Electronics (rinkydinkelectronics.com)
或者用:https://lvgl.io/tools/imageconverter
上传对应分辨率的照片,生成.c格式的文件,放到你的代码目录中,更改后缀名为.h,在代码中引用即可。
我替换后的样子:
代码中显示图形有多种函数,每个函数的含义请参看文件:
载入中…