M5 display support (experimental)
This commit is contained in:
		
							parent
							
								
									e2af3e0951
								
							
						
					
					
						commit
						2f8301d36a
					
				| @ -34,8 +34,6 @@ | |||||||
| // settings for TFT display library
 | // settings for TFT display library
 | ||||||
| #elif (HAS_DISPLAY == 2) | #elif (HAS_DISPLAY == 2) | ||||||
| 
 | 
 | ||||||
| #define ESP32 |  | ||||||
| 
 |  | ||||||
| #define MY_FONT_SMALL 1 | #define MY_FONT_SMALL 1 | ||||||
| #define MY_FONT_NORMAL 2 | #define MY_FONT_NORMAL 2 | ||||||
| #define MY_FONT_LARGE 4 | #define MY_FONT_LARGE 4 | ||||||
|  | |||||||
| @ -63,7 +63,7 @@ lib_deps_display = | |||||||
|     https://github.com/bitbank2/ss_oled.git |     https://github.com/bitbank2/ss_oled.git | ||||||
|     BitBang_I2C@2.0.1 |     BitBang_I2C@2.0.1 | ||||||
|     QRCode@>=0.0.1 |     QRCode@>=0.0.1 | ||||||
|     TFT_eSPI |     TFT_eSPI@>=2.1.9 | ||||||
| lib_deps_matrix_display = | lib_deps_matrix_display = | ||||||
|     Ultrathin_LED_Matrix@>=1.0.0 |     Ultrathin_LED_Matrix@>=1.0.0 | ||||||
| lib_deps_rgbled = | lib_deps_rgbled = | ||||||
| @ -98,7 +98,7 @@ build_flags_basic = | |||||||
|     '-DCORE_DEBUG_LEVEL=${common.debug_level}' |     '-DCORE_DEBUG_LEVEL=${common.debug_level}' | ||||||
|     '-DLOG_LOCAL_LEVEL=${common.debug_level}' |     '-DLOG_LOCAL_LEVEL=${common.debug_level}' | ||||||
|     '-DPROGVERSION="${common.release_version}"' |     '-DPROGVERSION="${common.release_version}"' | ||||||
|     '-DUSER_SETUP_LOADED=1' |     '-DUSER_SETUP_LOADED=1' ; needed for TFT_eSPI library | ||||||
| 
 | 
 | ||||||
| build_flags_sensors = | build_flags_sensors = | ||||||
|     -Llib/Bosch-BSEC/src/esp32/ |     -Llib/Bosch-BSEC/src/esp32/ | ||||||
|  | |||||||
| @ -51,7 +51,7 @@ QRCode qrcode; | |||||||
| #if (HAS_DISPLAY) == 1 | #if (HAS_DISPLAY) == 1 | ||||||
| SSOLED ssoled; | SSOLED ssoled; | ||||||
| #elif (HAS_DISPLAY) == 2 | #elif (HAS_DISPLAY) == 2 | ||||||
| TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT); // Invoke library
 | TFT_eSPI tft = TFT_eSPI(); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| void dp_setup(int contrast) { | void dp_setup(int contrast) { | ||||||
| @ -70,13 +70,9 @@ void dp_setup(int contrast) { | |||||||
| 
 | 
 | ||||||
|   tft.init(); |   tft.init(); | ||||||
| 
 | 
 | ||||||
|   if (MY_DISPLAY_FLIP) |   tft.setRotation(MY_DISPLAY_FLIP ? true : false); | ||||||
|     tft.setRotation(0); |   tft.invertDisplay(MY_DISPLAY_INVERT ? true : false); | ||||||
|   else |   tft.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR); | ||||||
|     tft.setRotation(2); // portrait
 |  | ||||||
| 
 |  | ||||||
|   if (MY_DISPLAY_INVERT) |  | ||||||
|     tft.invertDisplay(true); // Tell TFT to invert all displayed colours
 |  | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| @ -437,7 +433,24 @@ void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv, | |||||||
| #if (HAS_DISPLAY) == 1 | #if (HAS_DISPLAY) == 1 | ||||||
|   oledWriteString(&ssoled, 0, x, y, temp, font, inv, false); |   oledWriteString(&ssoled, 0, x, y, temp, font, inv, false); | ||||||
| #elif (HAS_DISPLAY) == 2 | #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 | #endif | ||||||
|   if (temp != loc_buf) { |   if (temp != loc_buf) { | ||||||
|     free(temp); |     free(temp); | ||||||
| @ -456,7 +469,7 @@ void dp_clear() { | |||||||
| #if (HAS_DISPLAY) == 1 | #if (HAS_DISPLAY) == 1 | ||||||
|   oledFill(&ssoled, 0, 1); |   oledFill(&ssoled, 0, 1); | ||||||
| #elif (HAS_DISPLAY) == 2 | #elif (HAS_DISPLAY) == 2 | ||||||
|   tft.fillScreen(TFT_WHITE); |   tft.fillScreen(MY_DISPLAY_BGCOLOR); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -48,6 +48,7 @@ | |||||||
| // Display Settings
 | // Display Settings
 | ||||||
| #define MY_DISPLAY_WIDTH 320 | #define MY_DISPLAY_WIDTH 320 | ||||||
| #define MY_DISPLAY_HEIGHT 240 | #define MY_DISPLAY_HEIGHT 240 | ||||||
|  | #define MY_DISPLAY_INVERT 1 | ||||||
| 
 | 
 | ||||||
| // setting for M5 display
 | // setting for M5 display
 | ||||||
| #define ILI9341_DRIVER 1 | #define ILI9341_DRIVER 1 | ||||||
| @ -61,10 +62,7 @@ | |||||||
| #define TFT_RST  GPIO_NUM_33  // Reset
 | #define TFT_RST  GPIO_NUM_33  // Reset
 | ||||||
| #define TFT_BL   GPIO_NUM_32  // LED back-light
 | #define TFT_BL   GPIO_NUM_32  // LED back-light
 | ||||||
| 
 | 
 | ||||||
| //#define USE_HSPI_PORT
 | #define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
 | ||||||
| #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 LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
 | #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
 | #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 LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
 | ||||||
| #define SMOOTH_FONT | #define SMOOTH_FONT | ||||||
| 
 | 
 | ||||||
| #define SPI_FREQUENCY  27000000 | #define SPI_FREQUENCY  40000000 | ||||||
| 
 |  | ||||||
| // Optional reduced SPI frequency for reading TFT
 |  | ||||||
| #define SPI_READ_FREQUENCY  5000000 |  | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
| @ -49,6 +49,7 @@ | |||||||
| // Display Settings
 | // Display Settings
 | ||||||
| #define MY_DISPLAY_WIDTH 320 | #define MY_DISPLAY_WIDTH 320 | ||||||
| #define MY_DISPLAY_HEIGHT 240 | #define MY_DISPLAY_HEIGHT 240 | ||||||
|  | #define MY_DISPLAY_INVERT 1 | ||||||
| 
 | 
 | ||||||
| // setting for M5 display
 | // setting for M5 display
 | ||||||
| #define ILI9341_DRIVER 1 | #define ILI9341_DRIVER 1 | ||||||
| @ -62,8 +63,7 @@ | |||||||
| #define TFT_RST  GPIO_NUM_33  // Reset
 | #define TFT_RST  GPIO_NUM_33  // Reset
 | ||||||
| #define TFT_BL   GPIO_NUM_32  // LED back-light
 | #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_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
 | #define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user