From b427267e2b831cbd972b4ff76ea8ca8669f178eb Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Wed, 17 Mar 2021 16:26:04 +0100
Subject: [PATCH] Fix TM1637 driver selection
Fix TM1637 driver selection (#11358)
---
tasmota/xdrv_13_display.ino | 54 +++++++++++++++++++++---------------
tasmota/xdsp_01_lcd.ino | 5 ++--
tasmota/xdsp_02_ssd1306.ino | 5 ++--
tasmota/xdsp_03_matrix.ino | 5 ++--
tasmota/xdsp_07_sh1106.ino | 5 ++--
tasmota/xdsp_11_sevenseg.ino | 5 ++--
6 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino
index 1d319750b..e73b611e4 100755
--- a/tasmota/xdrv_13_display.ino
+++ b/tasmota/xdrv_13_display.ino
@@ -17,7 +17,6 @@
along with this program. If not, see .
*/
-#if defined(USE_I2C) || defined(USE_SPI)
#ifdef USE_DISPLAY
#define XDRV_13 13
@@ -1600,7 +1599,9 @@ void DisplayInitDriver(void)
Display_Text_From_File("/display.ini");
#endif
-
+#ifdef USE_GRAPH
+ for (uint8_t count = 0; count < NUM_GRAPHS; count++) { graph[count] = 0; }
+#endif
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
@@ -2037,8 +2038,9 @@ void CmndDisplayRows(void)
}
/*********************************************************************************************\
- * optional drivers
+ * Optional drivers
\*********************************************************************************************/
+
#ifdef USE_TOUCH_BUTTONS
// very limited path size, so, add .jpg
void draw_picture(char *path, uint32_t xp, uint32_t yp, uint32_t xs, uint32_t ys, uint32_t ocol, bool inverted) {
@@ -2059,7 +2061,7 @@ char ppath[16];
}
Draw_RGB_Bitmap(ppath, xp, yp, inverted);
}
-#endif
+#endif // USE_TOUCH_BUTTONS
#ifdef ESP32
@@ -2173,6 +2175,10 @@ void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
}
#endif // USE_UFILESYS
+/*********************************************************************************************\
+ * AWatch
+\*********************************************************************************************/
+
#ifdef USE_AWATCH
#define MINUTE_REDUCT 4
@@ -2210,6 +2216,9 @@ void DrawAClock(uint16_t rad) {
}
#endif // USE_AWATCH
+/*********************************************************************************************\
+ * Graphics
+\*********************************************************************************************/
#ifdef USE_GRAPH
@@ -2250,7 +2259,6 @@ struct GRAPH {
GFLAGS flags;
};
-
struct GRAPH *graph[NUM_GRAPHS];
#define TICKLEN 4
@@ -2447,6 +2455,7 @@ void Save_graph(uint8_t num, char *path) {
fp.print("\n");
fp.close();
}
+
void Restore_graph(uint8_t num, char *path) {
if (!renderer) return;
uint16_t index=num%NUM_GRAPHS;
@@ -2558,7 +2567,6 @@ void AddGraph(uint8_t num,uint8_t val) {
}
}
-
// add next value
void AddValue(uint8_t num,float fval) {
// not yet defined ???
@@ -2593,7 +2601,12 @@ void AddValue(uint8_t num,float fval) {
}
#endif // USE_GRAPH
+/*********************************************************************************************\
+ * Touch panel control
+\*********************************************************************************************/
+
#if defined(USE_FT5206) || defined(USE_XPT2046)
+
#ifdef USE_FT5206
#include
@@ -2630,7 +2643,7 @@ uint32_t Touch_Status(uint32_t sel) {
return 0;
}
}
-#endif
+#endif // USE_FT5206
#if defined(USE_XPT2046) && defined(USE_DISPLAY_ILI9341)
#include
@@ -2664,7 +2677,7 @@ uint32_t Touch_Status(uint32_t sel) {
}
}
-#endif
+#endif // USE_XPT2046 && USE_DISPLAY_ILI9341
#ifdef USE_TOUCH_BUTTONS
void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) {
@@ -2672,7 +2685,7 @@ void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) {
ResponseTime_P(PSTR(",\"FT5206\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
#elif defined(USE_XPT2046)
ResponseTime_P(PSTR(",\"XPT2046\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
-#endif
+#endif // USE_XPT2046
MqttPublishTeleSensor();
}
@@ -2688,18 +2701,17 @@ uint8_t tbstate[3];
// check digitizer hit
void Touch_Check(void(*rotconvert)(int16_t *x, int16_t *y)) {
-uint16_t temp;
-uint8_t rbutt=0;
-uint8_t vbutt=0;
+ uint16_t temp;
+ uint8_t rbutt=0;
+ uint8_t vbutt=0;
-
- if (touchp->touched()) {
+ if (touchp->touched()) {
// did find a hit
#if defined(USE_FT5206)
pLoc = touchp->getPoint(0);
#elif defined(USE_XPT2046)
pLoc = touchp->getPoint();
-#endif
+#endif // USE_XPT2046
if (renderer) {
#ifdef USE_M5STACK_CORE2
@@ -2720,7 +2732,7 @@ uint8_t vbutt=0;
}
xcenter += 100;
}
-#endif
+#endif // USE_M5STACK_CORE2
rotconvert(&pLoc.x, &pLoc.y);
@@ -2784,7 +2796,7 @@ uint8_t vbutt=0;
//AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut);
}
}
-#endif
+#endif // USE_M5STACK_CORE2
for (uint8_t count = 0; count < MAX_TOUCH_BUTTONS; count++) {
if (buttons[count]) {
if (!buttons[count]->vpower.slider) {
@@ -2817,7 +2829,7 @@ uint8_t vbutt=0;
}
#endif // USE_TOUCH_BUTTONS
-#endif // USE_FT5206
+#endif // USE_FT5206 || USE_XPT2046
/*********************************************************************************************\
* Interface
@@ -2827,13 +2839,10 @@ bool Xdrv13(uint8_t function)
{
bool result = false;
- if ((TasmotaGlobal.i2c_enabled || TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled) && XdspPresent()) {
+ if (XdspPresent()) {
switch (function) {
case FUNC_PRE_INIT:
DisplayInitDriver();
-#ifdef USE_GRAPH
- for (uint8_t count = 0; count < NUM_GRAPHS; count++) { graph[count] = 0; }
-#endif
break;
case FUNC_EVERY_50_MSECOND:
if (Settings.display_model) { XdspCall(FUNC_DISPLAY_EVERY_50_MSECOND); }
@@ -2875,4 +2884,3 @@ bool Xdrv13(uint8_t function)
}
#endif // USE_DISPLAY
-#endif // USE_I2C or USE_SPI
diff --git a/tasmota/xdsp_01_lcd.ino b/tasmota/xdsp_01_lcd.ino
index 8f3a9a779..efb3b542c 100644
--- a/tasmota/xdsp_01_lcd.ino
+++ b/tasmota/xdsp_01_lcd.ino
@@ -55,8 +55,9 @@ void LcdInit(uint8_t mode)
}
}
-void LcdInitDriver(void)
-{
+void LcdInitDriver(void) {
+ if (!TasmotaGlobal.i2c_enabled) { return; }
+
if (!Settings.display_model) {
if (I2cSetDevice(LCD_ADDRESS1)) {
Settings.display_address[0] = LCD_ADDRESS1;
diff --git a/tasmota/xdsp_02_ssd1306.ino b/tasmota/xdsp_02_ssd1306.ino
index 1698f00f6..03bea26b6 100644
--- a/tasmota/xdsp_02_ssd1306.ino
+++ b/tasmota/xdsp_02_ssd1306.ino
@@ -47,8 +47,9 @@ extern uint8_t *buffer;
/*********************************************************************************************/
-void SSD1306InitDriver(void)
-{
+void SSD1306InitDriver(void) {
+ if (!TasmotaGlobal.i2c_enabled) { return; }
+
if (!Settings.display_model) {
if (I2cSetDevice(OLED_ADDRESS1)) {
Settings.display_address[0] = OLED_ADDRESS1;
diff --git a/tasmota/xdsp_03_matrix.ino b/tasmota/xdsp_03_matrix.ino
index 3b0155a8f..6d20efeec 100644
--- a/tasmota/xdsp_03_matrix.ino
+++ b/tasmota/xdsp_03_matrix.ino
@@ -194,8 +194,9 @@ void MatrixInit(uint8_t mode)
}
}
-void MatrixInitDriver(void)
-{
+void MatrixInitDriver(void) {
+ if (!TasmotaGlobal.i2c_enabled) { return; }
+
mtx_buffer = (char*)(malloc(MTX_MAX_SCREEN_BUFFER));
if (mtx_buffer != nullptr) {
if (!Settings.display_model) {
diff --git a/tasmota/xdsp_07_sh1106.ino b/tasmota/xdsp_07_sh1106.ino
index 3ca925932..a4fa94509 100644
--- a/tasmota/xdsp_07_sh1106.ino
+++ b/tasmota/xdsp_07_sh1106.ino
@@ -48,8 +48,9 @@ Adafruit_SH1106 *oled1106;
/*********************************************************************************************/
-void SH1106InitDriver()
-{
+void SH1106InitDriver() {
+ if (!TasmotaGlobal.i2c_enabled) { return; }
+
if (!Settings.display_model) {
if (I2cSetDevice(OLED_ADDRESS1)) {
Settings.display_address[0] = OLED_ADDRESS1;
diff --git a/tasmota/xdsp_11_sevenseg.ino b/tasmota/xdsp_11_sevenseg.ino
index b3bde3149..69342cbbf 100644
--- a/tasmota/xdsp_11_sevenseg.ino
+++ b/tasmota/xdsp_11_sevenseg.ino
@@ -147,8 +147,9 @@ void SevensegInit(uint8_t mode)
}
}
-void SevensegInitDriver(void)
-{
+void SevensegInitDriver(void) {
+ if (!TasmotaGlobal.i2c_enabled) { return; }
+
if (!Settings.display_model) {
if (I2cSetDevice(Settings.display_address[0])) {
Settings.display_model = XDSP_11;