Merge pull request #3540 from MadDoct/development

update output data report to include the pair - mcp230xx
This commit is contained in:
Theo Arends 2018-08-21 14:50:46 +02:00 committed by GitHub
commit b830e64d02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -105,7 +105,7 @@ const char* IntModeTxt(uint8_t intmo) {
break; break;
default: default:
return "UNKNOWN"; return "UNKNOWN";
break; break;
} }
} }
@ -175,7 +175,7 @@ void MCP230xx_Detect()
if (mcp230xx_type) { if (mcp230xx_type) {
return; return;
} }
uint8_t buffer; uint8_t buffer;
for (byte i = 0; i < sizeof(mcp230xx_addresses); i++) { for (byte i = 0; i < sizeof(mcp230xx_addresses); i++) {
@ -323,10 +323,17 @@ void MCP230xx_SetOutPin(uint8_t pin,uint8_t pinstate) {
I2cWrite8(mcp230xx_address, MCP230xx_GPIO + port, portpins); I2cWrite8(mcp230xx_address, MCP230xx_GPIO + port, portpins);
if (Settings.flag.save_state) { // Firmware configured to save last known state in settings if (Settings.flag.save_state) { // Firmware configured to save last known state in settings
Settings.mcp230xx_config[pin].saved_state=portpins>>(pin-(port*8))&1; Settings.mcp230xx_config[pin].saved_state=portpins>>(pin-(port*8))&1;
Settings.mcp230xx_config[pin+pinadd].saved_state=portpins>>(pin+pinadd-(port*8))&1;
} }
sprintf(cmnd,ConvertNumTxt(pinstate, pinmo)); sprintf(cmnd,ConvertNumTxt(pinstate, pinmo));
sprintf(stt,ConvertNumTxt((portpins >> (pin-(port*8))&1), pinmo)); sprintf(stt,ConvertNumTxt((portpins >> (pin-(port*8))&1), pinmo));
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_CMND_RESPONSE, pin, cmnd, stt); if (interlock && pinmo == Settings.mcp230xx_config[pin+pinadd].pinmode) {
char stt1[4];
sprintf(stt1,ConvertNumTxt((portpins >> (pin+pinadd-(port*8))&1), pinmo));
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"S29cmnd_D%i\":{\"COMMAND\":\"%s\",\"STATE\":\"%s\"},\"S29cmnd_D%i\":{\"STATE\":\"%s\"}}"),pin, cmnd, stt, pin+pinadd, stt1);
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_CMND_RESPONSE, pin, cmnd, stt);
}
} }
#endif // USE_MCP230xx_OUTPUT #endif // USE_MCP230xx_OUTPUT