驱动与屏幕尺寸适配
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
// Note that some sketches are designed for a particular TFT pixel width/height
|
// Note that some sketches are designed for a particular TFT pixel width/height
|
||||||
|
|
||||||
// User defined information reported by "Read_User_Setup" test & diagnostics example
|
// User defined information reported by "Read_User_Setup" test & diagnostics example
|
||||||
// #define USER_SETUP_INFO "User_Setup"
|
#define USER_SETUP_INFO "User_Setup"
|
||||||
|
|
||||||
// Define to disable all #warnings in library (can be put in User_Setup_Select.h)
|
// Define to disable all #warnings in library (can be put in User_Setup_Select.h)
|
||||||
//#define DISABLE_ALL_LIBRARY_WARNINGS
|
//#define DISABLE_ALL_LIBRARY_WARNINGS
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
|
// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
|
||||||
// Try ONE option at a time to find the correct colour order for your display
|
// Try ONE option at a time to find the correct colour order for your display
|
||||||
|
|
||||||
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
|
||||||
#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
|
||||||
|
|
||||||
// For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below
|
// For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below
|
||||||
@@ -83,11 +83,11 @@
|
|||||||
// For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
|
// For ST7789, ST7735, ILI9163 and GC9A01 ONLY, define the pixel width and height in portrait orientation
|
||||||
// #define TFT_WIDTH 80
|
// #define TFT_WIDTH 80
|
||||||
// #define TFT_WIDTH 128
|
// #define TFT_WIDTH 128
|
||||||
#define TFT_WIDTH 240 // ST7789 172 x 320
|
// #define TFT_WIDTH 240 // ST7789 172 x 320
|
||||||
#define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
|
#define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
|
||||||
// #define TFT_HEIGHT 160
|
// #define TFT_HEIGHT 160
|
||||||
// #define TFT_HEIGHT 128
|
// #define TFT_HEIGHT 128
|
||||||
// #define TFT_HEIGHT 240 // ST7789 240 x 240
|
#define TFT_HEIGHT 240 // ST7789 240 x 240
|
||||||
// #define TFT_HEIGHT 320 // ST7789 240 x 320
|
// #define TFT_HEIGHT 320 // ST7789 240 x 320
|
||||||
// #define TFT_HEIGHT 240 // GC9A01 240 x 240
|
// #define TFT_HEIGHT 240 // GC9A01 240 x 240
|
||||||
|
|
||||||
@@ -203,23 +203,23 @@
|
|||||||
// For ESP32 Dev board (only tested with ILI9341 display)
|
// For ESP32 Dev board (only tested with ILI9341 display)
|
||||||
// The hardware SPI can be mapped to any pins
|
// The hardware SPI can be mapped to any pins
|
||||||
|
|
||||||
#define TFT_MISO 19
|
// #define TFT_MISO 19
|
||||||
#define TFT_MOSI 23
|
// #define TFT_MOSI 23
|
||||||
#define TFT_SCLK 18
|
// #define TFT_SCLK 18
|
||||||
#define TFT_CS 27 // Chip select control pin
|
// #define TFT_CS 27 // Chip select control pin
|
||||||
#define TFT_DC 25 // Data Command control pin
|
// #define TFT_DC 25 // Data Command control pin
|
||||||
#define TFT_RST 26 // Reset pin (could connect to RST pin)
|
// #define TFT_RST 26 // Reset pin (could connect to RST pin)
|
||||||
// #define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
|
// #define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
|
||||||
|
|
||||||
// For ESP32 Dev board (only tested with GC9A01 display)
|
// For ESP32 Dev board (only tested with GC9A01 display)
|
||||||
// The hardware SPI can be mapped to any pins
|
// The hardware SPI can be mapped to any pins
|
||||||
|
|
||||||
//#define TFT_MOSI 15 // In some display driver board, it might be written as "SDA" and so on.
|
#define TFT_MOSI 19 // In some display driver board, it might be written as "SDA" and so on.
|
||||||
//#define TFT_SCLK 14
|
#define TFT_SCLK 23
|
||||||
//#define TFT_CS 5 // Chip select control pin
|
#define TFT_CS 18 // Chip select control pin
|
||||||
//#define TFT_DC 27 // Data Command control pin
|
#define TFT_DC 27 // Data Command control pin
|
||||||
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
|
#define TFT_RST 25 // Reset pin (could connect to Arduino RESET pin)
|
||||||
//#define TFT_BL 22 // LED back-light
|
#define TFT_BL 26 // LED back-light
|
||||||
|
|
||||||
//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
TFT_eSPI tft = TFT_eSPI();
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
|
|
||||||
const char *ssid = "Xiaomi_6B37_2.4G";
|
const char *ssid = "***********";
|
||||||
const char *password = "0123456789qwerdf";
|
const char *password = "*****************";
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, "ntp.aliyun.com");
|
NTPClient timeClient(ntpUDP, "ntp.aliyun.com");
|
||||||
@@ -21,8 +21,8 @@ void setup() {
|
|||||||
tft.writedata(0x20);
|
tft.writedata(0x20);
|
||||||
tft.fillScreen(TFT_WHITE);
|
tft.fillScreen(TFT_WHITE);
|
||||||
tft.setTextColor(TFT_BLACK, TFT_WHITE);
|
tft.setTextColor(TFT_BLACK, TFT_WHITE);
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(1);
|
||||||
tft.setCursor(10, 10, 1);
|
tft.setCursor(25, 25, 1);
|
||||||
tft.print("Loading...");
|
tft.print("Loading...");
|
||||||
|
|
||||||
// 休眠2s
|
// 休眠2s
|
||||||
@@ -75,7 +75,7 @@ void loop() {
|
|||||||
tft.print(minutes);
|
tft.print(minutes);
|
||||||
|
|
||||||
tft.setTextSize(2);
|
tft.setTextSize(2);
|
||||||
tft.setCursor(15, 100, 1);
|
tft.setCursor(15, 95, 1);
|
||||||
tft.print(year);
|
tft.print(year);
|
||||||
tft.print("/");
|
tft.print("/");
|
||||||
if (month < 10) {
|
if (month < 10) {
|
||||||
@@ -89,25 +89,25 @@ void loop() {
|
|||||||
tft.print(monthDay);
|
tft.print(monthDay);
|
||||||
|
|
||||||
tft.setTextSize(3);
|
tft.setTextSize(3);
|
||||||
tft.setCursor(185, 95, 1);
|
tft.setCursor(185, 90, 1);
|
||||||
if (seconds < 10) {
|
if (seconds < 10) {
|
||||||
tft.print("0");
|
tft.print("0");
|
||||||
}
|
}
|
||||||
tft.print(seconds);
|
tft.print(seconds);
|
||||||
|
|
||||||
tft.drawLine(0, 135, 240, 135, TFT_WHITE);
|
tft.drawLine(15, 125, 225, 125, TFT_WHITE);
|
||||||
|
|
||||||
tft.setSwapBytes(true);
|
tft.setSwapBytes(true);
|
||||||
tft.pushImage(0, 135, 100, 100, pics[picIndex]);
|
tft.pushImage(15, 125, 100, 100, pics[picIndex]);
|
||||||
picIndex = picIndex + 1;
|
picIndex = picIndex + 1;
|
||||||
if (picIndex >= 10) {
|
if (picIndex >= 10) {
|
||||||
picIndex = 0;
|
picIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
showCostomChar(130, 140, "猪", TFT_WHITE);
|
showCostomChar(125, 130, "猪", TFT_WHITE);
|
||||||
showCostomChar(175, 140, "猪", TFT_WHITE);
|
showCostomChar(175, 130, "猪", TFT_WHITE);
|
||||||
showCostomChar(130, 190, "专", TFT_WHITE);
|
showCostomChar(125, 175, "专", TFT_WHITE);
|
||||||
showCostomChar(175, 190, "属", TFT_WHITE);
|
showCostomChar(175, 175, "属", TFT_WHITE);
|
||||||
|
|
||||||
// 休眠1s
|
// 休眠1s
|
||||||
delay(100);
|
delay(100);
|
||||||
@@ -125,7 +125,7 @@ void wifiConnect() {
|
|||||||
wifi_wait = wifi_wait + 1;
|
wifi_wait = wifi_wait + 1;
|
||||||
temp = temp + 1;
|
temp = temp + 1;
|
||||||
|
|
||||||
tft.setCursor(10, 10, 1);
|
tft.setCursor(25, 25, 1);
|
||||||
tft.print("Wifi connecting");
|
tft.print("Wifi connecting");
|
||||||
|
|
||||||
if (wifi_wait == 1) {
|
if (wifi_wait == 1) {
|
||||||
@@ -140,7 +140,7 @@ void wifiConnect() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tft.setCursor(10, 10, 1);
|
tft.setCursor(25, 25, 1);
|
||||||
tft.println("Wifi connected ");
|
tft.println("Wifi connected ");
|
||||||
|
|
||||||
// 休眠2s
|
// 休眠2s
|
||||||
|
|||||||
Reference in New Issue
Block a user