M5 display support (experimental)

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

View File

@ -34,8 +34,6 @@
// settings for TFT display library
#elif (HAS_DISPLAY == 2)
#define ESP32
#define MY_FONT_SMALL 1
#define MY_FONT_NORMAL 2
#define MY_FONT_LARGE 4

View File

@ -63,7 +63,7 @@ lib_deps_display =
https://github.com/bitbank2/ss_oled.git
BitBang_I2C@2.0.1
QRCode@>=0.0.1
TFT_eSPI
TFT_eSPI@>=2.1.9
lib_deps_matrix_display =
Ultrathin_LED_Matrix@>=1.0.0
lib_deps_rgbled =
@ -98,7 +98,7 @@ build_flags_basic =
'-DCORE_DEBUG_LEVEL=${common.debug_level}'
'-DLOG_LOCAL_LEVEL=${common.debug_level}'
'-DPROGVERSION="${common.release_version}"'
'-DUSER_SETUP_LOADED=1'
'-DUSER_SETUP_LOADED=1' ; needed for TFT_eSPI library
build_flags_sensors =
-Llib/Bosch-BSEC/src/esp32/

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
}

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

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