M5 display support (experimental)

This commit is contained in:
Klaus K Wilting committed 2020-03-29 23:05:42 +02:00
1 parent e2af3e0951
commit 2f8301d36a
5 files changed
+30 -24

No files matched your search

+23 -10
View File
@@ -51,7 +51,7 @@ QRCode qrcode;
#if (HAS_DISPLAY) == 1
SSOLED ssoled;
#elif (HAS_DISPLAY) == 2
TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT); // Invoke library
TFT_eSPI tft = TFT_eSPI();
#endif
void dp_setup(int contrast) {
@@ -70,13 +70,9 @@ void dp_setup(int contrast) {
tft.init();
if (MY_DISPLAY_FLIP)
tft.setRotation(0);
else
tft.setRotation(2); // portrait
if (MY_DISPLAY_INVERT)
tft.invertDisplay(true); // Tell TFT to invert all displayed colours
tft.setRotation(MY_DISPLAY_FLIP ? true : false);
tft.invertDisplay(MY_DISPLAY_INVERT ? true : false);
tft.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
#endif
@@ -437,7 +433,24 @@ void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
#if (HAS_DISPLAY) == 1
oledWriteString(&ssoled, 0, x, y, temp, font, inv, false);
#elif (HAS_DISPLAY) == 2
tft.drawString(temp, x, y, font);
uint8_t myfont;
switch (font) {
case MY_FONT_SMALL:
myfont = 6;
break;
case MY_FONT_NORMAL:
case MY_FONT_LARGE:
myfont = 8;
break;
case MY_FONT_STRETCHED:
myfont = 16;
break;
default:
myfont = 8;
}
tft.drawString(temp, x * tft.textWidth("_", font) / myfont,
y * tft.fontHeight(font), font);
#endif
if (temp != loc_buf) {
free(temp);
@@ -456,7 +469,7 @@ void dp_clear() {
#if (HAS_DISPLAY) == 1
oledFill(&ssoled, 0, 1);
#elif (HAS_DISPLAY) == 2
tft.fillScreen(TFT_WHITE);
tft.fillScreen(MY_DISPLAY_BGCOLOR);
#endif
}
+3 -8
View File
@@ -48,6 +48,7 @@
// Display Settings
#define MY_DISPLAY_WIDTH 320
#define MY_DISPLAY_HEIGHT 240
#define MY_DISPLAY_INVERT 1
// setting for M5 display
#define ILI9341_DRIVER 1
@@ -61,10 +62,7 @@
#define TFT_RST GPIO_NUM_33 // Reset
#define TFT_BL GPIO_NUM_32 // LED back-light
//#define USE_HSPI_PORT
#define TFT_SDA_READ
#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
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
@@ -76,9 +74,6 @@
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
#define SPI_FREQUENCY 27000000
// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 5000000
#define SPI_FREQUENCY 40000000
#endif
+2 -2
View File
@@ -49,6 +49,7 @@
// Display Settings
#define MY_DISPLAY_WIDTH 320
#define MY_DISPLAY_HEIGHT 240
#define MY_DISPLAY_INVERT 1
// setting for M5 display
#define ILI9341_DRIVER 1
@@ -62,8 +63,7 @@
#define TFT_RST GPIO_NUM_33 // Reset
#define TFT_BL GPIO_NUM_32 // LED back-light
//#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
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters