Skip to content

Commit

Permalink
Add I2C display name during startup in universal display driver
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Jul 12, 2024
1 parent f68ac43 commit 279d9e5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tasmota/tasmota_xdsp_display/xdsp_17_universal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,23 @@ int8_t cs;
return 0;
}

char display_name[16] = { 0 }; // Loosly related to dname in uDisplay.h
char *cp = strstr(ddesc, ":H,");
if (cp) {
cp += 3;
char *lp = strchr(cp, ',');
if (lp) {
uint32_t len = lp - cp +1;
if (len >= sizeof(display_name)) { len = sizeof(display_name) -1; }
strlcpy(display_name, cp, len);
}
}
if (!strlen(display_name)) {
strcpy_P(display_name, PSTR("Display"));
}

// now replace tasmota vars before passing to driver
char *cp = strstr(ddesc, "I2C");
cp = strstr(ddesc, "I2C");
if (cp) {
cp += 3;
uint8_t wire_n = 1;
Expand Down Expand Up @@ -189,16 +204,11 @@ int8_t cs;
I2c2Begin(sda, scl);
}
}
#endif // ESP32
if (I2cSetDevice(i2caddr, wire_n - 1)) {
I2cSetActiveFound(i2caddr, "DSP-I2C", wire_n - 1);
I2cSetActiveFound(i2caddr, display_name, wire_n - 1);
}
#endif // ESP32

#ifdef ESP8266
if (I2cSetDevice(i2caddr)) {
I2cSetActiveFound(i2caddr, "DSP-I2C");
}
#endif // ESP8266
//AddLog(LOG_LEVEL_INFO, PSTR("DSP: i2c %x, %d, %d, %d!"), i2caddr, wire_n, scl, sda);
}

Expand Down

0 comments on commit 279d9e5

Please sign in to comment.