Refactor I2c drivers

This commit is contained in:
Theo Arends 2019-11-04 10:38:05 +01:00
parent 93f0f9a6f0
commit b46c6ef3e5
39 changed files with 594 additions and 682 deletions

View File

@ -1547,7 +1547,7 @@ void CmndI2cDriver(void)
}
}
Response_P(PSTR("{\"" D_CMND_I2CDRIVER "\":"));
XI2cDriverState();
I2cDriverState();
ResponseJsonEnd();
}
#endif // USE_I2C

View File

@ -179,26 +179,22 @@ void PCA9685_OutputTelemetry(bool telemetry) {
bool Xdrv15(uint8_t function)
{
if (!XI2cEnabled(XI2C_01)) { return false; }
if (!I2cEnabled(XI2C_01)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
PCA9685_Detect();
if (tele_period == 0) {
PCA9685_OutputTelemetry(true);
}
break;
case FUNC_COMMAND_DRIVER:
if (XDRV_15 == XdrvMailbox.index) {
result = PCA9685_Command();
}
break;
default:
break;
}
switch (function) {
case FUNC_EVERY_SECOND:
PCA9685_Detect();
if (tele_period == 0) {
PCA9685_OutputTelemetry(true);
}
break;
case FUNC_COMMAND_DRIVER:
if (XDRV_15 == XdrvMailbox.index) {
result = PCA9685_Command();
}
break;
}
return result;
}

View File

@ -223,27 +223,25 @@ void Pcf8574SaveSettings()
bool Xdrv28(uint8_t function)
{
if (!XI2cEnabled(XI2C_02)) { return false; }
if (!I2cEnabled(XI2C_02) || !Pcf8574.type) { return false; }
bool result = false;
if (i2c_flg && Pcf8574.type) {
switch (function) {
case FUNC_SET_POWER:
Pcf8574SwitchRelay();
break;
switch (function) {
case FUNC_SET_POWER:
Pcf8574SwitchRelay();
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_ADD_BUTTON:
WSContentSend_P(HTTP_BTN_MENU_PCF8574);
break;
case FUNC_WEB_ADD_HANDLER:
WebServer->on("/" WEB_HANDLE_PCF8574, HandlePcf8574);
break;
case FUNC_WEB_ADD_BUTTON:
WSContentSend_P(HTTP_BTN_MENU_PCF8574);
break;
case FUNC_WEB_ADD_HANDLER:
WebServer->on("/" WEB_HANDLE_PCF8574, HandlePcf8574);
break;
#endif // USE_WEBSERVER
case FUNC_PRE_INIT:
Pcf8574Init();
break;
}
case FUNC_PRE_INIT:
Pcf8574Init();
break;
}
return result;
}

View File

@ -190,28 +190,27 @@ void LcdRefresh(void) // Every second
bool Xdsp01(uint8_t function)
{
if (!XI2cEnabled(XI2C_03)) { return false; }
if (!I2cEnabled(XI2C_03)) { return false; }
bool result = false;
if (i2c_flg) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
LcdInitDriver();
}
else if (XDSP_01 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_INIT:
LcdInit(dsp_init);
break;
case FUNC_DISPLAY_POWER:
LcdDisplayOnOff(disp_power);
break;
case FUNC_DISPLAY_CLEAR:
lcd->clear();
break;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
LcdInitDriver();
}
else if (XDSP_01 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_INIT:
LcdInit(dsp_init);
break;
case FUNC_DISPLAY_POWER:
LcdDisplayOnOff(disp_power);
break;
case FUNC_DISPLAY_CLEAR:
lcd->clear();
break;
// case FUNC_DISPLAY_DRAW_HLINE:
// break;
// case FUNC_DISPLAY_DRAW_VLINE:
@ -230,20 +229,19 @@ bool Xdsp01(uint8_t function)
// break;
// case FUNC_DISPLAY_FONT_SIZE:
// break;
case FUNC_DISPLAY_DRAW_STRING:
LcdDrawStringAt();
break;
case FUNC_DISPLAY_ONOFF:
LcdDisplayOnOff(dsp_on);
break;
case FUNC_DISPLAY_DRAW_STRING:
LcdDrawStringAt();
break;
case FUNC_DISPLAY_ONOFF:
LcdDisplayOnOff(dsp_on);
break;
// case FUNC_DISPLAY_ROTATION:
// break;
#ifdef USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_EVERY_SECOND:
LcdRefresh();
break;
case FUNC_DISPLAY_EVERY_SECOND:
LcdRefresh();
break;
#endif // USE_DISPLAY_MODES1TO5
}
}
}
return result;

View File

@ -174,25 +174,23 @@ void Ssd1306Refresh(void) // Every second
bool Xdsp02(byte function)
{
if (!XI2cEnabled(XI2C_04)) { return false; }
if (!I2cEnabled(XI2C_04)) { return false; }
bool result = false;
if (i2c_flg) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
SSD1306InitDriver();
}
else if (XDSP_02 == Settings.display_model) {
switch (function) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
SSD1306InitDriver();
}
else if (XDSP_02 == Settings.display_model) {
switch (function) {
#ifdef USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_EVERY_SECOND:
Ssd1306Refresh();
break;
case FUNC_DISPLAY_EVERY_SECOND:
Ssd1306Refresh();
break;
#endif // USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_MODEL:
result = true;
break;
}
case FUNC_DISPLAY_MODEL:
result = true;
break;
}
}
return result;

View File

@ -331,32 +331,30 @@ void MatrixRefresh(void) // Every second
bool Xdsp03(uint8_t function)
{
if (!XI2cEnabled(XI2C_05)) { return false; }
if (!I2cEnabled(XI2C_05)) { return false; }
bool result = false;
if (i2c_flg) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
MatrixInitDriver();
}
else if (XDSP_03 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_INIT:
MatrixInit(dsp_init);
break;
case FUNC_DISPLAY_EVERY_50_MSECOND:
MatrixRefresh();
break;
case FUNC_DISPLAY_POWER:
MatrixOnOff();
break;
case FUNC_DISPLAY_DRAW_STRING:
MatrixDrawStringAt(dsp_x, dsp_y, dsp_str, dsp_color, dsp_flag);
break;
}
if (FUNC_DISPLAY_INIT_DRIVER == function) {
MatrixInitDriver();
}
else if (XDSP_03 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_INIT:
MatrixInit(dsp_init);
break;
case FUNC_DISPLAY_EVERY_50_MSECOND:
MatrixRefresh();
break;
case FUNC_DISPLAY_POWER:
MatrixOnOff();
break;
case FUNC_DISPLAY_DRAW_STRING:
MatrixDrawStringAt(dsp_x, dsp_y, dsp_str, dsp_color, dsp_flag);
break;
}
}
return result;

View File

@ -168,26 +168,24 @@ void SH1106Refresh(void) // Every second
bool Xdsp07(uint8_t function)
{
if (!XI2cEnabled(XI2C_06)) { return false; }
if (!I2cEnabled(XI2C_06)) { return false; }
bool result = false;
if (i2c_flg) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
SH1106InitDriver();
}
else if (XDSP_07 == Settings.display_model) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
SH1106InitDriver();
}
else if (XDSP_07 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
#ifdef USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_EVERY_SECOND:
SH1106Refresh();
break;
case FUNC_DISPLAY_EVERY_SECOND:
SH1106Refresh();
break;
#endif // USE_DISPLAY_MODES1TO5
}
}
}
return result;

View File

@ -269,7 +269,7 @@ bool Ade7953Command(void)
bool Xnrg07(uint8_t function)
{
if (!XI2cEnabled(XI2C_07)) { return false; }
if (!I2cEnabled(XI2C_07)) { return false; }
bool result = false;

View File

@ -221,28 +221,26 @@ void ShtShow(bool json)
bool Xsns07(uint8_t function)
{
if (!XI2cEnabled(XI2C_08)) { return false; }
if (!I2cEnabled(XI2C_08)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
switch (function) {
// case FUNC_PREP_BEFORE_TELEPERIOD: // As this is not a real I2C device it may interfere with other sensors
case FUNC_INIT: // Move detection to restart only removing interference
ShtDetect();
break;
case FUNC_EVERY_SECOND:
ShtEverySecond();
break;
case FUNC_JSON_APPEND:
ShtShow(1);
break;
case FUNC_INIT: // Move detection to restart only removing interference
ShtDetect();
break;
case FUNC_EVERY_SECOND:
ShtEverySecond();
break;
case FUNC_JSON_APPEND:
ShtShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
ShtShow(0);
break;
case FUNC_WEB_SENSOR:
ShtShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -281,27 +281,25 @@ void HtuShow(bool json)
bool Xsns08(uint8_t function)
{
if (!XI2cEnabled(XI2C_09)) { return false; }
if (!I2cEnabled(XI2C_09)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
HtuDetect();
break;
case FUNC_EVERY_SECOND:
HtuEverySecond();
break;
case FUNC_JSON_APPEND:
HtuShow(1);
break;
switch (function) {
case FUNC_INIT:
HtuDetect();
break;
case FUNC_EVERY_SECOND:
HtuEverySecond();
break;
case FUNC_JSON_APPEND:
HtuShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
HtuShow(0);
break;
case FUNC_WEB_SENSOR:
HtuShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -624,27 +624,25 @@ void BmpShow(bool json)
bool Xsns09(uint8_t function)
{
if (!XI2cEnabled(XI2C_10)) { return false; }
if (!I2cEnabled(XI2C_10)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
BmpDetect();
break;
case FUNC_EVERY_SECOND:
BmpEverySecond();
break;
case FUNC_JSON_APPEND:
BmpShow(1);
break;
switch (function) {
case FUNC_INIT:
BmpDetect();
break;
case FUNC_EVERY_SECOND:
BmpEverySecond();
break;
case FUNC_JSON_APPEND:
BmpShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
BmpShow(0);
break;
case FUNC_WEB_SENSOR:
BmpShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -113,27 +113,25 @@ void Bh1750Show(bool json)
bool Xsns10(uint8_t function)
{
if (!XI2cEnabled(XI2C_11)) { return false; }
if (!I2cEnabled(XI2C_11)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
Bh1750Detect();
break;
case FUNC_EVERY_SECOND:
Bh1750EverySecond();
break;
case FUNC_JSON_APPEND:
Bh1750Show(1);
break;
switch (function) {
case FUNC_INIT:
Bh1750Detect();
break;
case FUNC_EVERY_SECOND:
Bh1750EverySecond();
break;
case FUNC_JSON_APPEND:
Bh1750Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Bh1750Show(0);
break;
case FUNC_WEB_SENSOR:
Bh1750Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -305,28 +305,27 @@ void Veml6070Show(bool json)
bool Xsns11(uint8_t function)
{
if (!XI2cEnabled(XI2C_12)) { return false; }
if (!I2cEnabled(XI2C_12) ||
(pin[GPIO_ADE7953_IRQ] < 99)) { return false; } // The ADE7953 uses I2C address 0x38 too but needs priority
bool result = false;
if (i2c_flg && !(pin[GPIO_ADE7953_IRQ] < 99)) { // The ADE7953 uses I2C address 0x38 too but needs priority
switch (function) {
case FUNC_INIT:
Veml6070Detect(); // 1[ms], detect and init the sensor
Veml6070UvTableInit(); // 1[ms], initalize the UV compare table only once
break;
case FUNC_EVERY_SECOND:
Veml6070EverySecond(); // 10..15[ms], tested with OLED display, do all the actions needed to get all sensor values
break;
case FUNC_JSON_APPEND:
Veml6070Show(1);
break;
switch (function) {
case FUNC_INIT:
Veml6070Detect(); // 1[ms], detect and init the sensor
Veml6070UvTableInit(); // 1[ms], initalize the UV compare table only once
break;
case FUNC_EVERY_SECOND:
Veml6070EverySecond(); // 10..15[ms], tested with OLED display, do all the actions needed to get all sensor values
break;
case FUNC_JSON_APPEND:
Veml6070Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Veml6070Show(0);
break;
case FUNC_WEB_SENSOR:
Veml6070Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -242,24 +242,22 @@ void Ads1115Show(bool json)
bool Xsns12(uint8_t function)
{
if (!XI2cEnabled(XI2C_13)) { return false; }
if (!I2cEnabled(XI2C_13)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_PREP_BEFORE_TELEPERIOD:
Ads1115Detect();
break;
case FUNC_JSON_APPEND:
Ads1115Show(1);
break;
switch (function) {
case FUNC_PREP_BEFORE_TELEPERIOD:
Ads1115Detect();
break;
case FUNC_JSON_APPEND:
Ads1115Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Ads1115Show(0);
break;
case FUNC_WEB_SENSOR:
Ads1115Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -131,24 +131,22 @@ void Ads1115Show(bool json)
bool Xsns12(uint8_t function)
{
if (!XI2cEnabled(XI2C_13)) { return false; }
if (!I2cEnabled(XI2C_13)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_PREP_BEFORE_TELEPERIOD:
Ads1115Detect();
break;
case FUNC_JSON_APPEND:
Ads1115Show(1);
break;
switch (function) {
case FUNC_PREP_BEFORE_TELEPERIOD:
Ads1115Detect();
break;
case FUNC_JSON_APPEND:
Ads1115Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Ads1115Show(0);
break;
case FUNC_WEB_SENSOR:
Ads1115Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -276,32 +276,30 @@ void Ina219Show(bool json)
bool Xsns13(uint8_t function)
{
if (!XI2cEnabled(XI2C_14)) { return false; }
if (!I2cEnabled(XI2C_14)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_COMMAND_SENSOR:
if ((XSNS_13 == XdrvMailbox.index) && (ina219_type)) {
result = Ina219CommandSensor();
}
break;
case FUNC_INIT:
Ina219Detect();
break;
case FUNC_EVERY_SECOND:
Ina219EverySecond();
break;
case FUNC_JSON_APPEND:
Ina219Show(1);
break;
switch (function) {
case FUNC_COMMAND_SENSOR:
if ((XSNS_13 == XdrvMailbox.index) && (ina219_type)) {
result = Ina219CommandSensor();
}
break;
case FUNC_INIT:
Ina219Detect();
break;
case FUNC_EVERY_SECOND:
Ina219EverySecond();
break;
case FUNC_JSON_APPEND:
Ina219Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Ina219Show(0);
break;
case FUNC_WEB_SENSOR:
Ina219Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -139,24 +139,22 @@ void Sht3xShow(bool json)
bool Xsns14(uint8_t function)
{
if (!XI2cEnabled(XI2C_15)) { return false; }
if (!I2cEnabled(XI2C_15)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
Sht3xDetect();
break;
case FUNC_JSON_APPEND:
Sht3xShow(1);
break;
switch (function) {
case FUNC_INIT:
Sht3xDetect();
break;
case FUNC_JSON_APPEND:
Sht3xShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Sht3xShow(0);
break;
case FUNC_WEB_SENSOR:
Sht3xShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -122,27 +122,25 @@ void Tsl2561Show(bool json)
bool Xsns16(uint8_t function)
{
if (!XI2cEnabled(XI2C_16)) { return false; }
if (!I2cEnabled(XI2C_16)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
Tsl2561Detect();
break;
case FUNC_EVERY_SECOND:
Tsl2561EverySecond();
break;
case FUNC_JSON_APPEND:
Tsl2561Show(1);
break;
switch (function) {
case FUNC_INIT:
Tsl2561Detect();
break;
case FUNC_EVERY_SECOND:
Tsl2561EverySecond();
break;
case FUNC_JSON_APPEND:
Tsl2561Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Tsl2561Show(0);
break;
case FUNC_WEB_SENSOR:
Tsl2561Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -93,28 +93,26 @@ void MGSShow(bool json)
bool Xsns19(uint8_t function)
{
if (!XI2cEnabled(XI2C_17)) { return false; }
if (!I2cEnabled(XI2C_17)) { return false; }
bool result = false;
static int detected = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
switch (function) {
case FUNC_INIT:
// MGSInit();
break;
case FUNC_PREP_BEFORE_TELEPERIOD:
detected = MGSPrepare();
break;
case FUNC_JSON_APPEND:
if (detected) MGSShow(1);
break;
break;
case FUNC_PREP_BEFORE_TELEPERIOD:
detected = MGSPrepare();
break;
case FUNC_JSON_APPEND:
if (detected) MGSShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
if (detected) MGSShow(0);
break;
case FUNC_WEB_SENSOR:
if (detected) MGSShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -154,27 +154,25 @@ void Sgp30Show(bool json)
bool Xsns21(uint8_t function)
{
if (!XI2cEnabled(XI2C_18)) { return false; }
if (!I2cEnabled(XI2C_18)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
sgp30_Init();
break;
case FUNC_EVERY_SECOND:
Sgp30Update();
break;
case FUNC_JSON_APPEND:
Sgp30Show(1);
break;
switch (function) {
case FUNC_INIT:
sgp30_Init();
break;
case FUNC_EVERY_SECOND:
Sgp30Update();
break;
case FUNC_JSON_APPEND:
Sgp30Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Sgp30Show(0);
break;
case FUNC_WEB_SENSOR:
Sgp30Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -351,24 +351,22 @@ void Si1145Show(bool json)
bool Xsns24(uint8_t function)
{
if (!XI2cEnabled(XI2C_19)) { return false; }
if (!I2cEnabled(XI2C_19)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
Si1145Update();
break;
case FUNC_JSON_APPEND:
Si1145Show(1);
break;
switch (function) {
case FUNC_EVERY_SECOND:
Si1145Update();
break;
case FUNC_JSON_APPEND:
Si1145Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Si1145Show(0);
break;
case FUNC_WEB_SENSOR:
Si1145Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -104,24 +104,22 @@ void LM75ADShow(bool json)
bool Xsns26(uint8_t function)
{
if (!XI2cEnabled(XI2C_20)) { return false; }
if (!I2cEnabled(XI2C_20)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
LM75ADDetect();
break;
case FUNC_JSON_APPEND:
LM75ADShow(1);
break;
switch (function) {
case FUNC_EVERY_SECOND:
LM75ADDetect();
break;
case FUNC_JSON_APPEND:
LM75ADShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
LM75ADShow(0);
break;
case FUNC_WEB_SENSOR:
LM75ADShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -2027,32 +2027,30 @@ bool APDS9960CommandSensor(void)
bool Xsns27(uint8_t function)
{
if (!XI2cEnabled(XI2C_21)) { return false; }
if (!I2cEnabled(XI2C_21)) { return false; }
bool result = false;
if (i2c_flg) {
if (FUNC_INIT == function) {
APDS9960_detect();
} else if (APDS9960type) {
switch (function) {
case FUNC_EVERY_50_MSECOND:
APDS9960_loop();
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_27 == XdrvMailbox.index) {
result = APDS9960CommandSensor();
}
break;
case FUNC_JSON_APPEND:
APDS9960_show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
APDS9960_show(0);
if (FUNC_INIT == function) {
APDS9960_detect();
} else if (APDS9960type) {
switch (function) {
case FUNC_EVERY_50_MSECOND:
APDS9960_loop();
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_27 == XdrvMailbox.index) {
result = APDS9960CommandSensor();
}
break;
case FUNC_JSON_APPEND:
APDS9960_show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
APDS9960_show(0);
break;
#endif // USE_WEBSERVER
}
}
}
return result;

View File

@ -777,60 +777,56 @@ void MCP230xx_Interrupt_Retain_Report(void) {
bool Xsns29(uint8_t function)
{
if (!XI2cEnabled(XI2C_22)) { return false; }
if (!I2cEnabled(XI2C_22)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
MCP230xx_Detect();
if (mcp230xx_int_counter_en) {
mcp230xx_int_sec_counter++;
if (mcp230xx_int_sec_counter >= Settings.mcp230xx_int_timer) { // Interrupt counter interval reached, lets report
MCP230xx_Interrupt_Counter_Report();
}
switch (function) {
case FUNC_EVERY_SECOND:
MCP230xx_Detect();
if (mcp230xx_int_counter_en) {
mcp230xx_int_sec_counter++;
if (mcp230xx_int_sec_counter >= Settings.mcp230xx_int_timer) { // Interrupt counter interval reached, lets report
MCP230xx_Interrupt_Counter_Report();
}
if (tele_period == 0) {
if (mcp230xx_int_retainer_en) { // We have pins configured for interrupt retain reporting
MCP230xx_Interrupt_Retain_Report();
}
}
if (tele_period == 0) {
if (mcp230xx_int_retainer_en) { // We have pins configured for interrupt retain reporting
MCP230xx_Interrupt_Retain_Report();
}
}
#ifdef USE_MCP230xx_OUTPUT
if (tele_period == 0) {
MCP230xx_OutputTelemetry();
}
if (tele_period == 0) {
MCP230xx_OutputTelemetry();
}
#endif // USE_MCP230xx_OUTPUT
break;
case FUNC_EVERY_50_MSECOND:
if ((mcp230xx_int_en) && (mcp230xx_type)) { // Only check for interrupts if its enabled on one of the pins
mcp230xx_int_prio_counter++;
if ((mcp230xx_int_prio_counter) >= (Settings.mcp230xx_int_prio)) {
MCP230xx_CheckForInterrupt();
mcp230xx_int_prio_counter=0;
}
break;
case FUNC_EVERY_50_MSECOND:
if ((mcp230xx_int_en) && (mcp230xx_type)) { // Only check for interrupts if its enabled on one of the pins
mcp230xx_int_prio_counter++;
if ((mcp230xx_int_prio_counter) >= (Settings.mcp230xx_int_prio)) {
MCP230xx_CheckForInterrupt();
mcp230xx_int_prio_counter=0;
}
break;
case FUNC_JSON_APPEND:
MCP230xx_Show(1);
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_29 == XdrvMailbox.index) {
result = MCP230xx_Command();
}
break;
}
break;
case FUNC_JSON_APPEND:
MCP230xx_Show(1);
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_29 == XdrvMailbox.index) {
result = MCP230xx_Command();
}
break;
#ifdef USE_WEBSERVER
#ifdef USE_MCP230xx_OUTPUT
#ifdef USE_MCP230xx_DISPLAYOUTPUT
case FUNC_WEB_SENSOR:
MCP230xx_UpdateWebData();
break;
case FUNC_WEB_SENSOR:
MCP230xx_UpdateWebData();
break;
#endif // USE_MCP230xx_DISPLAYOUTPUT
#endif // USE_MCP230xx_OUTPUT
#endif // USE_WEBSERVER
default:
break;
}
}
return result;
}

View File

@ -400,7 +400,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
*/
bool Xsns30(uint8_t function)
{
if (!XI2cEnabled(XI2C_23)) { return false; }
if (!I2cEnabled(XI2C_23)) { return false; }
// ???
bool result = false;
@ -409,31 +409,29 @@ bool Xsns30(uint8_t function)
static struct mpr121 mpr121;
// Check if I2C is enabled
if (i2c_flg) {
switch (function) {
switch (function) {
// Initialize Sensors
case FUNC_INIT:
Mpr121Init(&mpr121);
break;
// Initialize Sensors
case FUNC_INIT:
Mpr121Init(&mpr121);
break;
// Run ever 50 milliseconds (near real-time functions)
case FUNC_EVERY_50_MSECOND:
Mpr121Show(&mpr121, FUNC_EVERY_50_MSECOND);
break;
// Run ever 50 milliseconds (near real-time functions)
case FUNC_EVERY_50_MSECOND:
Mpr121Show(&mpr121, FUNC_EVERY_50_MSECOND);
break;
// Generate JSON telemetry string
case FUNC_JSON_APPEND:
Mpr121Show(&mpr121, FUNC_JSON_APPEND);
break;
// Generate JSON telemetry string
case FUNC_JSON_APPEND:
Mpr121Show(&mpr121, FUNC_JSON_APPEND);
break;
#ifdef USE_WEBSERVER
// Show sensor data on main web page
case FUNC_WEB_SENSOR:
Mpr121Show(&mpr121, FUNC_WEB_SENSOR);
break;
// Show sensor data on main web page
case FUNC_WEB_SENSOR:
Mpr121Show(&mpr121, FUNC_WEB_SENSOR);
break;
#endif // USE_WEBSERVER
}
}
// Return bool result
return result;

View File

@ -104,24 +104,22 @@ void CCS811Show(bool json)
bool Xsns31(uint8_t function)
{
if (!XI2cEnabled(XI2C_24)) { return false; }
if (!I2cEnabled(XI2C_24)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
CCS811Update();
break;
case FUNC_JSON_APPEND:
CCS811Show(1);
break;
switch (function) {
case FUNC_EVERY_SECOND:
CCS811Update();
break;
case FUNC_JSON_APPEND:
CCS811Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
CCS811Show(0);
break;
case FUNC_WEB_SENSOR:
CCS811Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -226,30 +226,28 @@ void MPU_6050Show(bool json)
bool Xsns32(uint8_t function)
{
if (!XI2cEnabled(XI2C_25)) { return false; }
if (!I2cEnabled(XI2C_25)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_PREP_BEFORE_TELEPERIOD:
MPU_6050Detect();
break;
case FUNC_EVERY_SECOND:
if (tele_period == Settings.tele_period -3) {
MPU_6050PerformReading();
}
break;
case FUNC_JSON_APPEND:
MPU_6050Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
MPU_6050Show(0);
switch (function) {
case FUNC_PREP_BEFORE_TELEPERIOD:
MPU_6050Detect();
break;
case FUNC_EVERY_SECOND:
if (tele_period == Settings.tele_period -3) {
MPU_6050PerformReading();
break;
}
break;
case FUNC_JSON_APPEND:
MPU_6050Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
MPU_6050Show(0);
MPU_6050PerformReading();
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -134,45 +134,43 @@ void SetDS3231Time (uint32_t epoch_time) {
bool Xsns33(uint8_t function)
{
if (!XI2cEnabled(XI2C_26)) { return false; }
if (!I2cEnabled(XI2C_26)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
DS3231Detect();
break;
case FUNC_EVERY_SECOND:
TIME_T tmpTime;
if (!ds3231ReadStatus && DS3231chipDetected && Rtc.utc_time < START_VALID_TIME ) { // We still did not sync with NTP (time not valid) , so, read time from DS3231
ntp_force_sync = true; //force to sync with ntp
Rtc.utc_time = ReadFromDS3231(); //we read UTC TIME from DS3231
// from this line, we just copy the function from "void RtcSecond()" at the support.ino ,line 2143 and above
// We need it to set rules etc.
BreakTime(Rtc.utc_time, tmpTime);
if (Rtc.utc_time < START_VALID_TIME ) {
ds3231ReadStatus = true; //if time in DS3231 is valid, do not update again
}
RtcTime.year = tmpTime.year + 1970;
Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
AddLog_P2(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01
rules_flag.time_init = 1;
} else {
rules_flag.time_set = 1;
}
switch (function) {
case FUNC_INIT:
DS3231Detect();
break;
case FUNC_EVERY_SECOND:
TIME_T tmpTime;
if (!ds3231ReadStatus && DS3231chipDetected && Rtc.utc_time < START_VALID_TIME ) { // We still did not sync with NTP (time not valid) , so, read time from DS3231
ntp_force_sync = true; //force to sync with ntp
Rtc.utc_time = ReadFromDS3231(); //we read UTC TIME from DS3231
// from this line, we just copy the function from "void RtcSecond()" at the support.ino ,line 2143 and above
// We need it to set rules etc.
BreakTime(Rtc.utc_time, tmpTime);
if (Rtc.utc_time < START_VALID_TIME ) {
ds3231ReadStatus = true; //if time in DS3231 is valid, do not update again
}
else if (!ds3231WriteStatus && DS3231chipDetected && Rtc.utc_time > START_VALID_TIME && abs(Rtc.utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second
AddLog_P2(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
SetDS3231Time (Rtc.utc_time); //update the DS3231 time
ds3231WriteStatus = true;
RtcTime.year = tmpTime.year + 1970;
Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
AddLog_P2(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01
rules_flag.time_init = 1;
} else {
rules_flag.time_set = 1;
}
break;
}
}
else if (!ds3231WriteStatus && DS3231chipDetected && Rtc.utc_time > START_VALID_TIME && abs(Rtc.utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second
AddLog_P2(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
SetDS3231Time (Rtc.utc_time); //update the DS3231 time
ds3231WriteStatus = true;
}
break;
}
return result;
}

View File

@ -603,33 +603,31 @@ bool MGC3130CommandSensor()
bool Xsns36(uint8_t function)
{
if (!XI2cEnabled(XI2C_27)) { return false; }
if (!I2cEnabled(XI2C_27)) { return false; }
bool result = false;
if (i2c_flg) {
if ((FUNC_INIT == function) && (pin[GPIO_MGC3130_XFER] < 99) && (pin[GPIO_MGC3130_RESET] < 99)) {
MGC3130_detect();
}
else if (MGC3130_type) {
switch (function) {
case FUNC_EVERY_50_MSECOND:
MGC3130_loop();
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_36 == XdrvMailbox.index) {
result = MGC3130CommandSensor();
}
break;
case FUNC_JSON_APPEND:
MGC3130_show(1);
break;
if ((FUNC_INIT == function) && (pin[GPIO_MGC3130_XFER] < 99) && (pin[GPIO_MGC3130_RESET] < 99)) {
MGC3130_detect();
}
else if (MGC3130_type) {
switch (function) {
case FUNC_EVERY_50_MSECOND:
MGC3130_loop();
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_36 == XdrvMailbox.index) {
result = MGC3130CommandSensor();
}
break;
case FUNC_JSON_APPEND:
MGC3130_show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
MGC3130_show(0);
break;
case FUNC_WEB_SENSOR:
MGC3130_show(0);
break;
#endif // USE_WEBSERVER
}
}
}
return result;

View File

@ -150,27 +150,25 @@ void Max4409Show(bool json)
bool Xsns41(uint8_t function)
{
if (!XI2cEnabled(XI2C_28)) { return false; }
if (!I2cEnabled(XI2C_28)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
Max4409Detect();
break;
case FUNC_EVERY_SECOND:
Max4409EverySecond();
break;
case FUNC_JSON_APPEND:
Max4409Show(1);
break;
switch (function) {
case FUNC_INIT:
Max4409Detect();
break;
case FUNC_EVERY_SECOND:
Max4409EverySecond();
break;
case FUNC_JSON_APPEND:
Max4409Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Max4409Show(0);
break;
case FUNC_WEB_SENSOR:
Max4409Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -473,27 +473,25 @@ void Scd30Show(bool json)
bool Xsns42(byte function)
{
if (!XI2cEnabled(XI2C_29)) { return false; }
if (!I2cEnabled(XI2C_29)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
Scd30Update();
break;
case FUNC_COMMAND:
result = Scd30CommandSensor();
break;
case FUNC_JSON_APPEND:
Scd30Show(1);
break;
switch (function) {
case FUNC_EVERY_SECOND:
Scd30Update();
break;
case FUNC_COMMAND:
result = Scd30CommandSensor();
break;
case FUNC_JSON_APPEND:
Scd30Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Scd30Show(0);
break;
case FUNC_WEB_SENSOR:
Scd30Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -284,32 +284,30 @@ bool SPS30_cmd(void) {
bool Xsns44(byte function)
{
if (!XI2cEnabled(XI2C_30)) { return false; }
if (!I2cEnabled(XI2C_30)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
SPS30_Detect();
break;
case FUNC_EVERY_SECOND:
SPS30_Every_Second();
break;
case FUNC_JSON_APPEND:
SPS30_Show(1);
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_44 == XdrvMailbox.index) {
result = SPS30_cmd();
}
break;
switch (function) {
case FUNC_INIT:
SPS30_Detect();
break;
case FUNC_EVERY_SECOND:
SPS30_Every_Second();
break;
case FUNC_JSON_APPEND:
SPS30_Show(1);
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_44 == XdrvMailbox.index) {
result = SPS30_cmd();
}
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
SPS30_Show(0);
break;
case FUNC_WEB_SENSOR:
SPS30_Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -136,27 +136,25 @@ void Vl53l0Show(boolean json)
bool Xsns45(byte function)
{
if (!XI2cEnabled(XI2C_31)) { return false; }
if (!I2cEnabled(XI2C_31)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
Vl53l0Detect();
break;
case FUNC_EVERY_250_MSECOND:
Vl53l0Every_250MSecond();
break;
case FUNC_JSON_APPEND:
Vl53l0Show(1);
break;
switch (function) {
case FUNC_INIT:
Vl53l0Detect();
break;
case FUNC_EVERY_250_MSECOND:
Vl53l0Every_250MSecond();
break;
case FUNC_JSON_APPEND:
Vl53l0Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Vl53l0Show(0);
break;
case FUNC_WEB_SENSOR:
Vl53l0Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -117,27 +117,25 @@ void MLX90614_Show(uint8_t json) {
bool Xsns46(byte function)
{
if (!XI2cEnabled(XI2C_32)) { return false; }
if (!I2cEnabled(XI2C_32)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
MLX90614_Init();
switch (function) {
case FUNC_INIT:
MLX90614_Init();
break;
case FUNC_EVERY_SECOND:
MLX90614_Every_Second();
break;
case FUNC_JSON_APPEND:
MLX90614_Show(1);
break;
case FUNC_EVERY_SECOND:
MLX90614_Every_Second();
break;
case FUNC_JSON_APPEND:
MLX90614_Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
MLX90614_Show(0);
break;
case FUNC_WEB_SENSOR:
MLX90614_Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -523,33 +523,31 @@ bool ChirpCmd(void) {
bool Xsns48(uint8_t function)
{
if (!XI2cEnabled(XI2C_33)) { return false; }
if (!I2cEnabled(XI2C_33)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
ChirpDetect(); // We can call CHIRPSCAN later to re-detect
break;
case FUNC_EVERY_100_MSECOND:
if(chirp_found_sensors > 0){
ChirpEvery100MSecond();
}
break;
case FUNC_COMMAND:
result = ChirpCmd();
break;
case FUNC_JSON_APPEND:
ChirpShow(1);
chirp_next_job = 14; // TELE done, now compute time for next measure cycle
break;
switch (function) {
case FUNC_INIT:
ChirpDetect(); // We can call CHIRPSCAN later to re-detect
break;
case FUNC_EVERY_100_MSECOND:
if(chirp_found_sensors > 0){
ChirpEvery100MSecond();
}
break;
case FUNC_COMMAND:
result = ChirpCmd();
break;
case FUNC_JSON_APPEND:
ChirpShow(1);
chirp_next_job = 14; // TELE done, now compute time for next measure cycle
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
ChirpShow(0);
break;
case FUNC_WEB_SENSOR:
ChirpShow(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -537,34 +537,32 @@ bool PAJ7620Cmd(void) {
bool Xsns50(uint8_t function)
{
if (!XI2cEnabled(XI2C_34)) { return false; }
if (!I2cEnabled(XI2C_34)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_INIT:
DEBUG_SENSOR_LOG(PSTR("PAJ7620: 1 second until init"));
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_50 == XdrvMailbox.index){
result = PAJ7620Cmd();
}
break;
case FUNC_EVERY_100_MSECOND:
if(PAJ7620_next_job <255) {
PAJ7620Loop();
}
break;
case FUNC_JSON_APPEND:
PAJ7620Show(1);
break;
switch (function) {
case FUNC_INIT:
DEBUG_SENSOR_LOG(PSTR("PAJ7620: 1 second until init"));
break;
case FUNC_COMMAND_SENSOR:
if (XSNS_50 == XdrvMailbox.index){
result = PAJ7620Cmd();
}
break;
case FUNC_EVERY_100_MSECOND:
if(PAJ7620_next_job <255) {
PAJ7620Loop();
}
break;
case FUNC_JSON_APPEND:
PAJ7620Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
PAJ7620Show(0);
break;
case FUNC_WEB_SENSOR:
PAJ7620Show(0);
break;
#endif // USE_WEBSERVER
}
}
return result;
}

View File

@ -532,37 +532,33 @@ void Ina226Show(bool json)
*/
bool Xsns54(byte callback_id)
{
if (!XI2cEnabled(XI2C_35)) { return false; }
if (!I2cEnabled(XI2C_35)) { return false; }
// Set return value to `false`
bool result = false;
// Check if I2C interface mode is enabled
if(i2c_flg) {
// Check which callback ID is called by Tasmota
switch (callback_id) {
case FUNC_EVERY_SECOND:
Ina226EverySecond();
break;
case FUNC_INIT:
Ina226Init();
break;
case FUNC_JSON_APPEND:
Ina226Show(1);
break;
// Check which callback ID is called by Tasmota
switch (callback_id) {
case FUNC_EVERY_SECOND:
Ina226EverySecond();
break;
case FUNC_INIT:
Ina226Init();
break;
case FUNC_JSON_APPEND:
Ina226Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Ina226Show(0);
break;
case FUNC_WEB_SENSOR:
Ina226Show(0);
break;
#endif // USE_WEBSERVER
case FUNC_COMMAND_SENSOR:
if (XSNS_54 == XdrvMailbox.index) {
result = Ina226CommandSensor();
}
break;
}
} // if(i2c_flg)
case FUNC_COMMAND_SENSOR:
if (XSNS_54 == XdrvMailbox.index) {
result = Ina226CommandSensor();
}
break;
}
// Return boolean result
return result;
}

View File

@ -135,27 +135,25 @@ void Hih6Show(bool json)
bool Xsns55(uint8_t function)
{
if (!XI2cEnabled(XI2C_36)) { return false; }
if (!I2cEnabled(XI2C_36)) { return false; }
bool result = false;
if (i2c_flg) {
switch (function) {
case FUNC_EVERY_SECOND:
Hih6EverySecond();
break;
case FUNC_JSON_APPEND:
Hih6Show(1);
break;
switch (function) {
case FUNC_EVERY_SECOND:
Hih6EverySecond();
break;
case FUNC_JSON_APPEND:
Hih6Show(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
Hih6Show(0);
break;
case FUNC_WEB_SENSOR:
Hih6Show(0);
break;
#endif // USE_WEBSERVER
case FUNC_INIT:
Hih6Detect();
break;
}
case FUNC_INIT:
Hih6Detect();
break;
}
return result;
}

View File

@ -412,23 +412,12 @@ const uint8_t kI2cList[] = {
/*********************************************************************************************/
bool XI2cEnabled(uint32_t i2c_index)
bool I2cEnabled(uint32_t i2c_index)
{
/*
if (i2c_index < sizeof(kI2cList)) {
#ifdef XFUNC_PTR_IN_ROM
uint32_t index = pgm_read_byte(kI2cList + i2c_index);
#else
uint32_t index = kI2cList[i2c_index];
#endif
return bitRead(Settings.i2c_drivers[index / 32], index % 32);
}
return true;
*/
return bitRead(Settings.i2c_drivers[i2c_index / 32], i2c_index % 32);
return (i2c_flg && bitRead(Settings.i2c_drivers[i2c_index / 32], i2c_index % 32));
}
void XI2cDriverState(void)
void I2cDriverState(void)
{
ResponseAppend_P(PSTR("\"")); // Use string for enable/disable signal
for (uint32_t i = 0; i < sizeof(kI2cList); i++) {