`i2c_enabled` refactored as array (#22387)

This commit is contained in:
s-hadinger 2024-10-30 22:23:13 +01:00 committed by GitHub
parent e30d88e013
commit b89909991c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 46 additions and 46 deletions

View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
### Changed ### Changed
- ESP32 Platform from 2024.10.30 to 2024.11.30, Framework (Arduino Core) from v3.1.0.241023 to v3.1.0.241030 and IDF to 5.3.1.241024 (#22384) - ESP32 Platform from 2024.10.30 to 2024.11.30, Framework (Arduino Core) from v3.1.0.241023 to v3.1.0.241030 and IDF to 5.3.1.241024 (#22384)
- ESP32 LVGL library from v9.2.0 to v9.2.2 - ESP32 LVGL library from v9.2.0 to v9.2.2
- `i2c_enabled` refactored as array
### Fixed ### Fixed
- ESP32 Arduino Core IPv6 zones used by Matter (#22378) - ESP32 Arduino Core IPv6 zones used by Matter (#22378)

View File

@ -312,8 +312,7 @@ struct TasmotaGlobal_t {
bool stop_flash_rotate; // Allow flash configuration rotation bool stop_flash_rotate; // Allow flash configuration rotation
bool blinkstate; // LED state bool blinkstate; // LED state
bool pwm_present; // Any PWM channel configured with SetOption15 0 bool pwm_present; // Any PWM channel configured with SetOption15 0
bool i2c_enabled; // I2C configured bool i2c_enabled[MAX_I2S]; // I2C configured for all possible buses (1 or 2)
bool i2c_enabled_2; // I2C configured, second controller, Wire1
#ifdef ESP32 #ifdef ESP32
bool ota_factory; // Select safeboot binary bool ota_factory; // Select safeboot binary
#endif #endif

View File

@ -79,14 +79,14 @@ bool I2cBegin(int sda, int scl, uint32_t bus, uint32_t frequency) {
} }
TwoWire& I2cGetWire(uint8_t bus = 0) { TwoWire& I2cGetWire(uint8_t bus = 0) {
if ((0 == bus) && TasmotaGlobal.i2c_enabled) { if ((0 == bus) && TasmotaGlobal.i2c_enabled[0]) {
#ifdef USE_I2C_BUS2_ESP8266 #ifdef USE_I2C_BUS2_ESP8266
I2cSetBus(bus); I2cSetBus(bus);
#endif #endif
return Wire; return Wire;
} }
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
else if ((1 == bus) && TasmotaGlobal.i2c_enabled_2) { else if ((1 == bus) && TasmotaGlobal.i2c_enabled[1]) {
#ifdef USE_I2C_BUS2_ESP8266 #ifdef USE_I2C_BUS2_ESP8266
I2cSetBus(bus); I2cSetBus(bus);
#endif #endif

View File

@ -2752,12 +2752,12 @@ void CmndBatteryPercent(void) {
void CmndI2cScan(void) { void CmndI2cScan(void) {
// I2CScan - Scan bus1 then bus2 // I2CScan - Scan bus1 then bus2
bool jsflag = false; bool jsflag = false;
if (TasmotaGlobal.i2c_enabled) { if (TasmotaGlobal.i2c_enabled[0]) {
I2cScan(); I2cScan();
jsflag = true; jsflag = true;
} }
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
if (TasmotaGlobal.i2c_enabled_2) { if (TasmotaGlobal.i2c_enabled[1]) {
if (jsflag) { if (jsflag) {
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
} }

View File

@ -39,7 +39,7 @@ void eeprom_readBytes(uint32_t addr, uint32_t len, uint8_t *buff) {
} }
uint32_t eeprom_init(uint32_t size) { uint32_t eeprom_init(uint32_t size) {
if (TasmotaGlobal.i2c_enabled) { if (TasmotaGlobal.i2c_enabled[0]) {
if (I2cActive(EEPROM_ADDRESS) || I2cSetDevice(EEPROM_ADDRESS)) { if (I2cActive(EEPROM_ADDRESS) || I2cSetDevice(EEPROM_ADDRESS)) {
// eeprom is present // eeprom is present
I2cSetActiveFound(EEPROM_ADDRESS, "24C256"); I2cSetActiveFound(EEPROM_ADDRESS, "24C256");

View File

@ -2234,17 +2234,17 @@ void GpioInit(void)
#ifdef USE_I2C #ifdef USE_I2C
/* /*
if (PinUsed(GPIO_I2C_SCL) && PinUsed(GPIO_I2C_SDA)) { if (PinUsed(GPIO_I2C_SCL) && PinUsed(GPIO_I2C_SDA)) {
TasmotaGlobal.i2c_enabled = I2cBegin(Pin(GPIO_I2C_SDA), Pin(GPIO_I2C_SCL)); TasmotaGlobal.i2c_enabled[0] = I2cBegin(Pin(GPIO_I2C_SDA), Pin(GPIO_I2C_SCL));
#ifdef ESP32 #ifdef ESP32
if (TasmotaGlobal.i2c_enabled) { if (TasmotaGlobal.i2c_enabled[0]) {
AddLog(LOG_LEVEL_INFO, PSTR("I2C: Bus1 using GPIO%02d(SCL) and GPIO%02d(SDA)"), Pin(GPIO_I2C_SCL), Pin(GPIO_I2C_SDA)); AddLog(LOG_LEVEL_INFO, PSTR("I2C: Bus1 using GPIO%02d(SCL) and GPIO%02d(SDA)"), Pin(GPIO_I2C_SCL), Pin(GPIO_I2C_SDA));
} }
#endif #endif
} }
#ifdef ESP32 #ifdef ESP32
if (PinUsed(GPIO_I2C_SCL, 1) && PinUsed(GPIO_I2C_SDA, 1)) { if (PinUsed(GPIO_I2C_SCL, 1) && PinUsed(GPIO_I2C_SDA, 1)) {
TasmotaGlobal.i2c_enabled_2 = I2cBegin(Pin(GPIO_I2C_SDA, 1), Pin(GPIO_I2C_SCL, 1), 1); TasmotaGlobal.i2c_enabled[1] = I2cBegin(Pin(GPIO_I2C_SDA, 1), Pin(GPIO_I2C_SCL, 1), 1);
if (TasmotaGlobal.i2c_enabled_2) { if (TasmotaGlobal.i2c_enabled[1]) {
AddLog(LOG_LEVEL_INFO, PSTR("I2C: Bus2 using GPIO%02d(SCL) and GPIO%02d(SDA)"), Pin(GPIO_I2C_SCL, 1), Pin(GPIO_I2C_SDA, 1)); AddLog(LOG_LEVEL_INFO, PSTR("I2C: Bus2 using GPIO%02d(SCL) and GPIO%02d(SDA)"), Pin(GPIO_I2C_SCL, 1), Pin(GPIO_I2C_SDA, 1));
} }
} }
@ -2258,11 +2258,11 @@ void GpioInit(void)
if (PinUsed(GPIO_I2C_SCL, bus) && PinUsed(GPIO_I2C_SDA, bus)) { if (PinUsed(GPIO_I2C_SCL, bus) && PinUsed(GPIO_I2C_SDA, bus)) {
if (I2cBegin(Pin(GPIO_I2C_SDA, bus), Pin(GPIO_I2C_SCL, bus), bus)) { if (I2cBegin(Pin(GPIO_I2C_SDA, bus), Pin(GPIO_I2C_SCL, bus), bus)) {
if (0 == bus) { if (0 == bus) {
TasmotaGlobal.i2c_enabled = true; TasmotaGlobal.i2c_enabled[0] = true;
} }
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
else { else {
TasmotaGlobal.i2c_enabled_2 = true; TasmotaGlobal.i2c_enabled[1] = true;
} }
AddLog(LOG_LEVEL_INFO, PSTR("I2C: Bus%d using GPIO%02d(SCL) and GPIO%02d(SDA)"), bus +1, Pin(GPIO_I2C_SCL, bus), Pin(GPIO_I2C_SDA, bus)); AddLog(LOG_LEVEL_INFO, PSTR("I2C: Bus%d using GPIO%02d(SCL) and GPIO%02d(SDA)"), bus +1, Pin(GPIO_I2C_SCL, bus), Pin(GPIO_I2C_SDA, bus));
#endif // USE_I2C_BUS2 #endif // USE_I2C_BUS2

View File

@ -13213,7 +13213,7 @@ uint32_t script_i2c(uint8_t sel, uint16_t val, uint32_t val1) {
Wire1.end(); Wire1.end();
Wire1.begin(val & 0x7f, val1); Wire1.begin(val & 0x7f, val1);
glob_script_mem.script_i2c_wire = &Wire1; glob_script_mem.script_i2c_wire = &Wire1;
TasmotaGlobal.i2c_enabled_2 = true; TasmotaGlobal.i2c_enabled[1] = true;
if (val & 128) { if (val & 128) {
XsnsCall(FUNC_INIT); XsnsCall(FUNC_INIT);
} }

View File

@ -667,7 +667,7 @@ void CmndFlashDump(void)
void CmndI2cWrite(void) void CmndI2cWrite(void)
{ {
// I2cWrite <address>,<data>.. // I2cWrite <address>,<data>..
if (TasmotaGlobal.i2c_enabled) { if (TasmotaGlobal.i2c_enabled[0]) {
char* parms = XdrvMailbox.data; char* parms = XdrvMailbox.data;
uint8_t buffer[100]; uint8_t buffer[100];
uint32_t index = 0; uint32_t index = 0;
@ -696,7 +696,7 @@ void CmndI2cWrite(void)
void CmndI2cRead(void) void CmndI2cRead(void)
{ {
// I2cRead <address>,<size> // I2cRead <address>,<size>
if (TasmotaGlobal.i2c_enabled) { if (TasmotaGlobal.i2c_enabled[0]) {
char* parms = XdrvMailbox.data; char* parms = XdrvMailbox.data;
uint8_t buffer[100]; uint8_t buffer[100];
uint32_t index = 0; uint32_t index = 0;
@ -729,7 +729,7 @@ void CmndI2cRead(void)
void CmndI2cStretch(void) void CmndI2cStretch(void)
{ {
#ifdef ESP8266 #ifdef ESP8266
if (TasmotaGlobal.i2c_enabled && (XdrvMailbox.payload > 0)) { if (TasmotaGlobal.i2c_enabled[0] && (XdrvMailbox.payload > 0)) {
Wire.setClockStretchLimit(XdrvMailbox.payload); Wire.setClockStretchLimit(XdrvMailbox.payload);
} }
ResponseCmndDone(); ResponseCmndDone();
@ -738,7 +738,7 @@ void CmndI2cStretch(void)
void CmndI2cClock(void) void CmndI2cClock(void)
{ {
if (TasmotaGlobal.i2c_enabled && (XdrvMailbox.payload > 0)) { if (TasmotaGlobal.i2c_enabled[0] && (XdrvMailbox.payload > 0)) {
Wire.setClock(XdrvMailbox.payload); Wire.setClock(XdrvMailbox.payload);
} }
ResponseCmndDone(); ResponseCmndDone();

View File

@ -117,7 +117,7 @@ void ZigbeeInit(void)
#ifdef USE_ZIGBEE_EZSP #ifdef USE_ZIGBEE_EZSP
// Check the I2C EEprom // Check the I2C EEprom
if (TasmotaGlobal.i2c_enabled) { if (TasmotaGlobal.i2c_enabled[0]) {
Wire.beginTransmission(USE_ZIGBEE_ZBBRIDGE_EEPROM); Wire.beginTransmission(USE_ZIGBEE_ZBBRIDGE_EEPROM);
uint8_t error = Wire.endTransmission(); uint8_t error = Wire.endTransmission();
if (0 == error) { if (0 == error) {

View File

@ -124,7 +124,7 @@ uint32_t ES8311_init() {
} }
void S3boxInit(void) { void S3boxInit(void) {
if (TasmotaGlobal.i2c_enabled_2) { if (TasmotaGlobal.i2c_enabled[1]) {
// box lite // box lite
ES8156_init(); ES8156_init();
es7243e_init(); es7243e_init();
@ -143,7 +143,7 @@ void S3boxInit(void) {
#include <wm8960.h> #include <wm8960.h>
void W8960_Init1(void) { void W8960_Init1(void) {
if (TasmotaGlobal.i2c_enabled_2) { if (TasmotaGlobal.i2c_enabled[1]) {
if (I2cSetDevice(W8960_ADDR, 1)) { if (I2cSetDevice(W8960_ADDR, 1)) {
I2cSetActiveFound(W8960_ADDR, "W8960-I2C", 1); I2cSetActiveFound(W8960_ADDR, "W8960-I2C", 1);
W8960_Init(&Wire1); W8960_Init(&Wire1);

View File

@ -33,10 +33,10 @@ TwoWire & getWire(bvm *vm) {
be_getmember(vm, 1, "bus"); be_getmember(vm, 1, "bus");
int32_t bus = be_toint(vm, -1); // bus is 1 or 2 int32_t bus = be_toint(vm, -1); // bus is 1 or 2
be_pop(vm, 1); be_pop(vm, 1);
if (1 == bus && TasmotaGlobal.i2c_enabled) { if (1 == bus && TasmotaGlobal.i2c_enabled[0]) {
return Wire; return Wire;
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
} else if (2 == bus && TasmotaGlobal.i2c_enabled_2) { } else if (2 == bus && TasmotaGlobal.i2c_enabled[1]) {
return Wire1; return Wire1;
#endif // USE_I2C_BUS2 #endif // USE_I2C_BUS2
} else { } else {
@ -50,9 +50,9 @@ bool I2cEnabled(bvm *vm) {
be_getmember(vm, 1, "bus"); be_getmember(vm, 1, "bus");
int32_t bus = be_toint(vm, -1); // bus is 1 or 2 int32_t bus = be_toint(vm, -1); // bus is 1 or 2
be_pop(vm, 1); be_pop(vm, 1);
if (1 == bus && TasmotaGlobal.i2c_enabled) { if (1 == bus && TasmotaGlobal.i2c_enabled[0]) {
return true; return true;
} else if (2 == bus && TasmotaGlobal.i2c_enabled_2) { } else if (2 == bus && TasmotaGlobal.i2c_enabled[1]) {
return true; return true;
} else { } else {
return false; return false;

View File

@ -236,7 +236,7 @@ void CmndHDMIType(void) {
// The buffer must be allocated to uint8_t[256] by caller // The buffer must be allocated to uint8_t[256] by caller
// Only checksum is checked // Only checksum is checked
bool ReadEdid256(uint8_t *buf) { bool ReadEdid256(uint8_t *buf) {
if (!TasmotaGlobal.i2c_enabled) { return true; } // abort if I2C is not started if (!TasmotaGlobal.i2c_enabled[0]) { return true; } // abort if I2C is not started
if (I2cReadBuffer(HDMI_EDID_ADDRESS, 0, buf , 128)) { return true; } if (I2cReadBuffer(HDMI_EDID_ADDRESS, 0, buf , 128)) { return true; }
if (I2cReadBuffer(HDMI_EDID_ADDRESS, 128, buf + 128, 128)) { return true; } if (I2cReadBuffer(HDMI_EDID_ADDRESS, 128, buf + 128, 128)) { return true; }

View File

@ -213,11 +213,11 @@ bool WcPinUsed(void) {
// } // }
} }
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: i2c_enabled_2: %d"), TasmotaGlobal.i2c_enabled_2); AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: i2c_enabled_2: %d"), TasmotaGlobal.i2c_enabled[1]);
if (!PinUsed(GPIO_WEBCAM_XCLK) || !PinUsed(GPIO_WEBCAM_PCLK) || if (!PinUsed(GPIO_WEBCAM_XCLK) || !PinUsed(GPIO_WEBCAM_PCLK) ||
!PinUsed(GPIO_WEBCAM_VSYNC) || !PinUsed(GPIO_WEBCAM_HREF) || !PinUsed(GPIO_WEBCAM_VSYNC) || !PinUsed(GPIO_WEBCAM_HREF) ||
((!PinUsed(GPIO_WEBCAM_SIOD) || !PinUsed(GPIO_WEBCAM_SIOC)) && !TasmotaGlobal.i2c_enabled_2) // preferred option is to reuse and share I2Cbus 2 ((!PinUsed(GPIO_WEBCAM_SIOD) || !PinUsed(GPIO_WEBCAM_SIOC)) && !TasmotaGlobal.i2c_enabled[1]) // preferred option is to reuse and share I2Cbus 2
) { ) {
pin_used = false; pin_used = false;
} }
@ -383,7 +383,7 @@ uint32_t WcSetup(int32_t fsiz) {
config.pin_href = Pin(GPIO_WEBCAM_HREF); // HREF_GPIO_NUM; config.pin_href = Pin(GPIO_WEBCAM_HREF); // HREF_GPIO_NUM;
config.pin_sccb_sda = Pin(GPIO_WEBCAM_SIOD); // SIOD_GPIO_NUM; - unset to use shared I2C bus 2 config.pin_sccb_sda = Pin(GPIO_WEBCAM_SIOD); // SIOD_GPIO_NUM; - unset to use shared I2C bus 2
config.pin_sccb_scl = Pin(GPIO_WEBCAM_SIOC); // SIOC_GPIO_NUM; config.pin_sccb_scl = Pin(GPIO_WEBCAM_SIOC); // SIOC_GPIO_NUM;
if(TasmotaGlobal.i2c_enabled_2){ // configure SIOD and SIOC as SDA,2 and SCL,2 if(TasmotaGlobal.i2c_enabled[1]){ // configure SIOD and SIOC as SDA,2 and SCL,2
config.sccb_i2c_port = 1; // reuse initialized bus 2, can be shared now config.sccb_i2c_port = 1; // reuse initialized bus 2, can be shared now
if(config.pin_sccb_sda < 0){ // GPIO_WEBCAM_SIOD must not be set to really make it happen if(config.pin_sccb_sda < 0){ // GPIO_WEBCAM_SIOD must not be set to really make it happen
AddLog(LOG_LEVEL_INFO, PSTR("CAM: Use I2C bus2")); AddLog(LOG_LEVEL_INFO, PSTR("CAM: Use I2C bus2"));

View File

@ -761,12 +761,12 @@ bool WcPinUsed(void) {
} }
#ifdef WEBCAM_DEV_DEBUG #ifdef WEBCAM_DEV_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: i2c_enabled_2: %d"), TasmotaGlobal.i2c_enabled_2); AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: i2c_enabled_2: %d"), TasmotaGlobal.i2c_enabled[1]);
#endif #endif
if (!PinUsed(GPIO_WEBCAM_XCLK) || !PinUsed(GPIO_WEBCAM_PCLK) || if (!PinUsed(GPIO_WEBCAM_XCLK) || !PinUsed(GPIO_WEBCAM_PCLK) ||
!PinUsed(GPIO_WEBCAM_VSYNC) || !PinUsed(GPIO_WEBCAM_HREF) || !PinUsed(GPIO_WEBCAM_VSYNC) || !PinUsed(GPIO_WEBCAM_HREF) ||
((!PinUsed(GPIO_WEBCAM_SIOD) || !PinUsed(GPIO_WEBCAM_SIOC)) && !TasmotaGlobal.i2c_enabled_2) // preferred option is to reuse and share I2Cbus 2 ((!PinUsed(GPIO_WEBCAM_SIOD) || !PinUsed(GPIO_WEBCAM_SIOC)) && !TasmotaGlobal.i2c_enabled[1]) // preferred option is to reuse and share I2Cbus 2
) { ) {
pin_used = false; pin_used = false;
} }
@ -974,7 +974,7 @@ uint32_t WcSetup(int32_t fsiz) {
config.pin_href = Pin(GPIO_WEBCAM_HREF); // HREF_GPIO_NUM; config.pin_href = Pin(GPIO_WEBCAM_HREF); // HREF_GPIO_NUM;
config.pin_sccb_sda = Pin(GPIO_WEBCAM_SIOD); // SIOD_GPIO_NUM; - unset to use shared I2C bus 2 config.pin_sccb_sda = Pin(GPIO_WEBCAM_SIOD); // SIOD_GPIO_NUM; - unset to use shared I2C bus 2
config.pin_sccb_scl = Pin(GPIO_WEBCAM_SIOC); // SIOC_GPIO_NUM; config.pin_sccb_scl = Pin(GPIO_WEBCAM_SIOC); // SIOC_GPIO_NUM;
if(TasmotaGlobal.i2c_enabled_2){ // configure SIOD and SIOC as SDA,2 and SCL,2 if(TasmotaGlobal.i2c_enabled[1]){ // configure SIOD and SIOC as SDA,2 and SCL,2
config.sccb_i2c_port = 1; // reuse initialized bus 2, can be shared now config.sccb_i2c_port = 1; // reuse initialized bus 2, can be shared now
if(config.pin_sccb_sda < 0){ // GPIO_WEBCAM_SIOD must not be set to really make it happen if(config.pin_sccb_sda < 0){ // GPIO_WEBCAM_SIOD must not be set to really make it happen
#ifdef WEBCAM_DEV_DEBUG #ifdef WEBCAM_DEV_DEBUG

View File

@ -56,7 +56,7 @@ void LcdInit(uint8_t mode)
} }
void LcdInitDriver(void) { void LcdInitDriver(void) {
if (!TasmotaGlobal.i2c_enabled) { return; } if (!TasmotaGlobal.i2c_enabled[0]) { return; }
if (!Settings->display_model) { if (!Settings->display_model) {
if (I2cSetDevice(LCD_ADDRESS1)) { if (I2cSetDevice(LCD_ADDRESS1)) {

View File

@ -195,7 +195,7 @@ void MatrixInit(uint8_t mode)
} }
void MatrixInitDriver(void) { void MatrixInitDriver(void) {
if (!TasmotaGlobal.i2c_enabled) { return; } if (!TasmotaGlobal.i2c_enabled[0]) { 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) {

View File

@ -148,7 +148,7 @@ void SevensegInit(uint8_t mode)
} }
void SevensegInitDriver(void) { void SevensegInitDriver(void) {
if (!TasmotaGlobal.i2c_enabled) { return; } if (!TasmotaGlobal.i2c_enabled[0]) { return; }
if (!Settings->display_model) { if (!Settings->display_model) {
if (I2cSetDevice(Settings->display_address[0])) { if (I2cSetDevice(Settings->display_address[0])) {

View File

@ -176,13 +176,13 @@ Renderer *Init_uDisplay(const char *desc) {
replacepin(&cp, Pin(GPIO_OLED_RESET)); replacepin(&cp, Pin(GPIO_OLED_RESET));
if (wire_n == 0) { if (wire_n == 0) {
if (!TasmotaGlobal.i2c_enabled) { if (!TasmotaGlobal.i2c_enabled[0]) {
I2cBegin(sda, scl); I2cBegin(sda, scl);
} }
} }
#ifdef ESP32 #ifdef ESP32
if (wire_n == 1) { if (wire_n == 1) {
if (!TasmotaGlobal.i2c_enabled_2) { if (!TasmotaGlobal.i2c_enabled[1]) {
I2cBegin(sda, scl, 1); I2cBegin(sda, scl, 1);
} }
} }
@ -370,13 +370,13 @@ Renderer *Init_uDisplay(const char *desc) {
} }
if (wire_n == 0) { if (wire_n == 0) {
if (!TasmotaGlobal.i2c_enabled) { if (!TasmotaGlobal.i2c_enabled[0]) {
I2cBegin(sda, scl); I2cBegin(sda, scl);
} }
} }
#ifdef ESP32 #ifdef ESP32
if (wire_n == 1) { if (wire_n == 1) {
if (!TasmotaGlobal.i2c_enabled_2) { if (!TasmotaGlobal.i2c_enabled[1]) {
I2cBegin(sda, scl, 1, 400000); I2cBegin(sda, scl, 1, 400000);
} }
} }

View File

@ -253,7 +253,7 @@ void TM1650Init(uint8_t mode)
\*********************************************************************************************/ \*********************************************************************************************/
void TM1650InitDriver(void) void TM1650InitDriver(void)
{ {
if (!TasmotaGlobal.i2c_enabled) { if (!TasmotaGlobal.i2c_enabled[0]) {
return; return;
} }

View File

@ -559,7 +559,7 @@ void BmpShow(bool json) {
// BMP280-77 // BMP280-77
snprintf_P(name, sizeof(name), PSTR("%s%c%02X"), name, IndexSeparator(), bmp_sensors[bmp_idx].bmp_address); snprintf_P(name, sizeof(name), PSTR("%s%c%02X"), name, IndexSeparator(), bmp_sensors[bmp_idx].bmp_address);
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
if (TasmotaGlobal.i2c_enabled_2) { // Second bus enabled if (TasmotaGlobal.i2c_enabled[1]) { // Second bus enabled
uint8_t bus = bmp_sensors[0].bmp_bus; uint8_t bus = bmp_sensors[0].bmp_bus;
for (uint32_t i = 1; i < bmp_count; i++) { for (uint32_t i = 1; i < bmp_count; i++) {
if (bus != bmp_sensors[i].bmp_bus) { // Different busses if (bus != bmp_sensors[i].bmp_bus) { // Different busses

View File

@ -56,7 +56,7 @@ void sen5x_Init(void) {
#ifdef ESP32 #ifdef ESP32
if (!I2cSetDevice(SEN5X_ADDRESS, 0)) { if (!I2cSetDevice(SEN5X_ADDRESS, 0)) {
DEBUG_SENSOR_LOG(PSTR("Sensirion SEN5X not found, i2c bus 0")); DEBUG_SENSOR_LOG(PSTR("Sensirion SEN5X not found, i2c bus 0"));
if (TasmotaGlobal.i2c_enabled_2 ) { if (TasmotaGlobal.i2c_enabled[1] ) {
if(!I2cSetDevice(SEN5X_ADDRESS, 1)) { if(!I2cSetDevice(SEN5X_ADDRESS, 1)) {
DEBUG_SENSOR_LOG(PSTR("Sensirion SEN5X not found, i2c bus 1")); DEBUG_SENSOR_LOG(PSTR("Sensirion SEN5X not found, i2c bus 1"));
return; return;

View File

@ -200,7 +200,7 @@ void Ads1115Label(char* label, uint32_t maxsize, uint32_t device) {
// "ADS1115-48":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-49":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} // "ADS1115-48":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-49":{"A0":3240,"A1":3235,"A2":3269,"A3":3269}
snprintf_P(label, maxsize, PSTR("%s%c%02X"), label, IndexSeparator(), Ads1115[device].address); snprintf_P(label, maxsize, PSTR("%s%c%02X"), label, IndexSeparator(), Ads1115[device].address);
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
if (TasmotaGlobal.i2c_enabled_2) { // Second bus enabled if (TasmotaGlobal.i2c_enabled[1]) { // Second bus enabled
uint8_t bus = Ads1115[0].bus; uint8_t bus = Ads1115[0].bus;
for (uint32_t i = 1; i < ads1115_count; i++) { for (uint32_t i = 1; i < ads1115_count; i++) {
if (bus != Ads1115[i].bus) { // Different busses if (bus != Ads1115[i].bus) { // Different busses

View File

@ -192,7 +192,7 @@ void Sht3xShow(bool json) {
if (sht3x_count > 1) { if (sht3x_count > 1) {
snprintf_P(types, sizeof(types), PSTR("%s%c%02X"), types, IndexSeparator(), sht3x_sensors[idx].address); // "SHT3X-0xXX" snprintf_P(types, sizeof(types), PSTR("%s%c%02X"), types, IndexSeparator(), sht3x_sensors[idx].address); // "SHT3X-0xXX"
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
if (TasmotaGlobal.i2c_enabled_2) { if (TasmotaGlobal.i2c_enabled[1]) {
for (uint32_t i = 1; i < sht3x_count; i++) { for (uint32_t i = 1; i < sht3x_count; i++) {
if (sht3x_sensors[0].bus != sht3x_sensors[i].bus) { if (sht3x_sensors[0].bus != sht3x_sensors[i].bus) {
snprintf_P(types, sizeof(types), PSTR("%s%c%d"), types, IndexSeparator(), sht3x_sensors[idx].bus + 1); // "SHT3X-0xXX-X" snprintf_P(types, sizeof(types), PSTR("%s%c%d"), types, IndexSeparator(), sht3x_sensors[idx].bus + 1); // "SHT3X-0xXX-X"

View File

@ -413,9 +413,9 @@ const uint8_t kI2cList[] = {
/*********************************************************************************************/ /*********************************************************************************************/
bool I2cEnabled(uint32_t i2c_index) { bool I2cEnabled(uint32_t i2c_index) {
return ((TasmotaGlobal.i2c_enabled return ((TasmotaGlobal.i2c_enabled[0]
#ifdef USE_I2C_BUS2 #ifdef USE_I2C_BUS2
|| TasmotaGlobal.i2c_enabled_2 || TasmotaGlobal.i2c_enabled[1]
#endif #endif
) && bitRead(Settings->i2c_drivers[i2c_index / 32], i2c_index % 32)); ) && bitRead(Settings->i2c_drivers[i2c_index / 32], i2c_index % 32));
} }