Fix TM1637 driver selection

Fix TM1637 driver selection (#11358)
This commit is contained in:
Theo Arends 2021-03-17 16:26:04 +01:00
parent 50948545d1
commit b427267e2b
6 changed files with 46 additions and 33 deletions

View File

@ -17,7 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#if defined(USE_I2C) || defined(USE_SPI)
#ifdef USE_DISPLAY #ifdef USE_DISPLAY
#define XDRV_13 13 #define XDRV_13 13
@ -1600,7 +1599,9 @@ void DisplayInitDriver(void)
Display_Text_From_File("/display.ini"); Display_Text_From_File("/display.ini");
#endif #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); // 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 #ifdef USE_TOUCH_BUTTONS
// very limited path size, so, add .jpg // 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) { 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); Draw_RGB_Bitmap(ppath, xp, yp, inverted);
} }
#endif #endif // USE_TOUCH_BUTTONS
#ifdef ESP32 #ifdef ESP32
@ -2173,6 +2175,10 @@ void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
} }
#endif // USE_UFILESYS #endif // USE_UFILESYS
/*********************************************************************************************\
* AWatch
\*********************************************************************************************/
#ifdef USE_AWATCH #ifdef USE_AWATCH
#define MINUTE_REDUCT 4 #define MINUTE_REDUCT 4
@ -2210,6 +2216,9 @@ void DrawAClock(uint16_t rad) {
} }
#endif // USE_AWATCH #endif // USE_AWATCH
/*********************************************************************************************\
* Graphics
\*********************************************************************************************/
#ifdef USE_GRAPH #ifdef USE_GRAPH
@ -2250,7 +2259,6 @@ struct GRAPH {
GFLAGS flags; GFLAGS flags;
}; };
struct GRAPH *graph[NUM_GRAPHS]; struct GRAPH *graph[NUM_GRAPHS];
#define TICKLEN 4 #define TICKLEN 4
@ -2447,6 +2455,7 @@ void Save_graph(uint8_t num, char *path) {
fp.print("\n"); fp.print("\n");
fp.close(); fp.close();
} }
void Restore_graph(uint8_t num, char *path) { void Restore_graph(uint8_t num, char *path) {
if (!renderer) return; if (!renderer) return;
uint16_t index=num%NUM_GRAPHS; uint16_t index=num%NUM_GRAPHS;
@ -2558,7 +2567,6 @@ void AddGraph(uint8_t num,uint8_t val) {
} }
} }
// add next value // add next value
void AddValue(uint8_t num,float fval) { void AddValue(uint8_t num,float fval) {
// not yet defined ??? // not yet defined ???
@ -2593,7 +2601,12 @@ void AddValue(uint8_t num,float fval) {
} }
#endif // USE_GRAPH #endif // USE_GRAPH
/*********************************************************************************************\
* Touch panel control
\*********************************************************************************************/
#if defined(USE_FT5206) || defined(USE_XPT2046) #if defined(USE_FT5206) || defined(USE_XPT2046)
#ifdef USE_FT5206 #ifdef USE_FT5206
#include <FT5206.h> #include <FT5206.h>
@ -2630,7 +2643,7 @@ uint32_t Touch_Status(uint32_t sel) {
return 0; return 0;
} }
} }
#endif #endif // USE_FT5206
#if defined(USE_XPT2046) && defined(USE_DISPLAY_ILI9341) #if defined(USE_XPT2046) && defined(USE_DISPLAY_ILI9341)
#include <XPT2046_Touchscreen.h> #include <XPT2046_Touchscreen.h>
@ -2664,7 +2677,7 @@ uint32_t Touch_Status(uint32_t sel) {
} }
} }
#endif #endif // USE_XPT2046 && USE_DISPLAY_ILI9341
#ifdef USE_TOUCH_BUTTONS #ifdef USE_TOUCH_BUTTONS
void Touch_MQTT(uint8_t index, const char *cp, uint32_t val) { 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); ResponseTime_P(PSTR(",\"FT5206\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
#elif defined(USE_XPT2046) #elif defined(USE_XPT2046)
ResponseTime_P(PSTR(",\"XPT2046\":{\"%s%d\":\"%d\"}}"), cp, index+1, val); ResponseTime_P(PSTR(",\"XPT2046\":{\"%s%d\":\"%d\"}}"), cp, index+1, val);
#endif #endif // USE_XPT2046
MqttPublishTeleSensor(); MqttPublishTeleSensor();
} }
@ -2688,18 +2701,17 @@ uint8_t tbstate[3];
// check digitizer hit // check digitizer hit
void Touch_Check(void(*rotconvert)(int16_t *x, int16_t *y)) { void Touch_Check(void(*rotconvert)(int16_t *x, int16_t *y)) {
uint16_t temp; uint16_t temp;
uint8_t rbutt=0; uint8_t rbutt=0;
uint8_t vbutt=0; uint8_t vbutt=0;
if (touchp->touched()) {
if (touchp->touched()) {
// did find a hit // did find a hit
#if defined(USE_FT5206) #if defined(USE_FT5206)
pLoc = touchp->getPoint(0); pLoc = touchp->getPoint(0);
#elif defined(USE_XPT2046) #elif defined(USE_XPT2046)
pLoc = touchp->getPoint(); pLoc = touchp->getPoint();
#endif #endif // USE_XPT2046
if (renderer) { if (renderer) {
#ifdef USE_M5STACK_CORE2 #ifdef USE_M5STACK_CORE2
@ -2720,7 +2732,7 @@ uint8_t vbutt=0;
} }
xcenter += 100; xcenter += 100;
} }
#endif #endif // USE_M5STACK_CORE2
rotconvert(&pLoc.x, &pLoc.y); rotconvert(&pLoc.x, &pLoc.y);
@ -2784,7 +2796,7 @@ uint8_t vbutt=0;
//AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut); //AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut);
} }
} }
#endif #endif // USE_M5STACK_CORE2
for (uint8_t count = 0; count < MAX_TOUCH_BUTTONS; count++) { for (uint8_t count = 0; count < MAX_TOUCH_BUTTONS; count++) {
if (buttons[count]) { if (buttons[count]) {
if (!buttons[count]->vpower.slider) { if (!buttons[count]->vpower.slider) {
@ -2817,7 +2829,7 @@ uint8_t vbutt=0;
} }
#endif // USE_TOUCH_BUTTONS #endif // USE_TOUCH_BUTTONS
#endif // USE_FT5206 #endif // USE_FT5206 || USE_XPT2046
/*********************************************************************************************\ /*********************************************************************************************\
* Interface * Interface
@ -2827,13 +2839,10 @@ bool Xdrv13(uint8_t function)
{ {
bool result = false; bool result = false;
if ((TasmotaGlobal.i2c_enabled || TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled) && XdspPresent()) { if (XdspPresent()) {
switch (function) { switch (function) {
case FUNC_PRE_INIT: case FUNC_PRE_INIT:
DisplayInitDriver(); DisplayInitDriver();
#ifdef USE_GRAPH
for (uint8_t count = 0; count < NUM_GRAPHS; count++) { graph[count] = 0; }
#endif
break; break;
case FUNC_EVERY_50_MSECOND: case FUNC_EVERY_50_MSECOND:
if (Settings.display_model) { XdspCall(FUNC_DISPLAY_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_DISPLAY
#endif // USE_I2C or USE_SPI

View File

@ -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 (!Settings.display_model) {
if (I2cSetDevice(LCD_ADDRESS1)) { if (I2cSetDevice(LCD_ADDRESS1)) {
Settings.display_address[0] = LCD_ADDRESS1; Settings.display_address[0] = LCD_ADDRESS1;

View File

@ -47,8 +47,9 @@ extern uint8_t *buffer;
/*********************************************************************************************/ /*********************************************************************************************/
void SSD1306InitDriver(void) void SSD1306InitDriver(void) {
{ if (!TasmotaGlobal.i2c_enabled) { return; }
if (!Settings.display_model) { if (!Settings.display_model) {
if (I2cSetDevice(OLED_ADDRESS1)) { if (I2cSetDevice(OLED_ADDRESS1)) {
Settings.display_address[0] = OLED_ADDRESS1; Settings.display_address[0] = OLED_ADDRESS1;

View File

@ -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)); mtx_buffer = (char*)(malloc(MTX_MAX_SCREEN_BUFFER));
if (mtx_buffer != nullptr) { if (mtx_buffer != nullptr) {
if (!Settings.display_model) { if (!Settings.display_model) {

View File

@ -48,8 +48,9 @@ Adafruit_SH1106 *oled1106;
/*********************************************************************************************/ /*********************************************************************************************/
void SH1106InitDriver() void SH1106InitDriver() {
{ if (!TasmotaGlobal.i2c_enabled) { return; }
if (!Settings.display_model) { if (!Settings.display_model) {
if (I2cSetDevice(OLED_ADDRESS1)) { if (I2cSetDevice(OLED_ADDRESS1)) {
Settings.display_address[0] = OLED_ADDRESS1; Settings.display_address[0] = OLED_ADDRESS1;

View File

@ -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 (!Settings.display_model) {
if (I2cSetDevice(Settings.display_address[0])) { if (I2cSetDevice(Settings.display_address[0])) {
Settings.display_model = XDSP_11; Settings.display_model = XDSP_11;