mirror of https://github.com/arendst/Tasmota.git
Add extended sensor29 reset commands
This commit is contained in:
parent
538e640f12
commit
3c62263bb3
|
@ -196,25 +196,32 @@ void MCP230xx_Show(boolean json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCP230xx_Reset(uint8_t pinmode) {
|
||||||
|
uint8_t pullup = 0;
|
||||||
|
if ((pinmode > 1) && (pinmode < 5)) pullup=1;
|
||||||
|
for (uint8_t pinx=0;pinx<16;pinx++) {
|
||||||
|
Settings.mcp230xx_config[pinx].pinmode=pinmode;
|
||||||
|
Settings.mcp230xx_config[pinx].pullup=pullup;
|
||||||
|
Settings.mcp230xx_config[pinx].b4=0;
|
||||||
|
Settings.mcp230xx_config[pinx].b5=0;
|
||||||
|
Settings.mcp230xx_config[pinx].b6=0;
|
||||||
|
Settings.mcp230xx_config[pinx].b7=0;
|
||||||
|
}
|
||||||
|
MCP230xx_ApplySettings();
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_SENSOR_RESPONSE,99,pinmode,pullup,99);
|
||||||
|
}
|
||||||
|
|
||||||
bool MCP230xx_Command(void) {
|
bool MCP230xx_Command(void) {
|
||||||
boolean serviced = true;
|
boolean serviced = true;
|
||||||
uint8_t _a, _b = 0;
|
uint8_t _a, _b = 0;
|
||||||
uint8_t pin, pinmode, pullup = 0;
|
uint8_t pin, pinmode, pullup = 0;
|
||||||
String data = XdrvMailbox.data;
|
String data = XdrvMailbox.data;
|
||||||
data.toUpperCase();
|
data.toUpperCase();
|
||||||
if (data == "RESET") { // we need to reset all pins to input
|
if (data == "RESET") { MCP230xx_Reset(1); return serviced; }
|
||||||
for (uint8_t pinx=0;pinx<16;pinx++) {
|
if (data == "RESET1") { MCP230xx_Reset(1); return serviced; }
|
||||||
Settings.mcp230xx_config[pinx].pinmode=1;
|
if (data == "RESET2") { MCP230xx_Reset(2); return serviced; }
|
||||||
Settings.mcp230xx_config[pinx].pullup=0;
|
if (data == "RESET3") { MCP230xx_Reset(3); return serviced; }
|
||||||
Settings.mcp230xx_config[pinx].b4=0;
|
if (data == "RESET4") { MCP230xx_Reset(4); return serviced; }
|
||||||
Settings.mcp230xx_config[pinx].b5=0;
|
|
||||||
Settings.mcp230xx_config[pinx].b6=0;
|
|
||||||
Settings.mcp230xx_config[pinx].b7=0;
|
|
||||||
}
|
|
||||||
MCP230xx_ApplySettings();
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_SENSOR_RESPONSE,99,99,99,99);
|
|
||||||
return serviced;
|
|
||||||
}
|
|
||||||
_a = data.indexOf(",");
|
_a = data.indexOf(",");
|
||||||
pin = data.substring(0, _a).toInt();
|
pin = data.substring(0, _a).toInt();
|
||||||
if (pin < mcp230xx_pincount) {
|
if (pin < mcp230xx_pincount) {
|
||||||
|
|
Loading…
Reference in New Issue