mirror of https://github.com/arendst/Tasmota.git
MCP230xx: Prevent inadvertent pinmode change
We've added support for sensor29 pin,0/1 for OFF/ON but the current code would allow the pinmode to be changed without specifying a default state e.g. sensor29 pin,3 would cause the pinmode to be changed to input even if it was previously configured for output (pinmode 5/6) This change prevents these instances by enforcing the configuration rules as outlined in the wiki e.g. sensor29 pin,pinmode,pullup/default state (if used for output)
This commit is contained in:
parent
d7d0316769
commit
dea255db26
|
@ -655,9 +655,9 @@ bool MCP230xx_Command(void) {
|
||||||
intmode = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
|
intmode = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
|
||||||
}
|
}
|
||||||
#ifdef USE_MCP230xx_OUTPUT
|
#ifdef USE_MCP230xx_OUTPUT
|
||||||
if ((pin < mcp230xx_pincount) && (pinmode > 0) && (pinmode < 7) && (pullup < 2)) {
|
if ((pin < mcp230xx_pincount) && (pinmode > 0) && (pinmode < 7) && (pullup < 2) && (paramcount > 2)) {
|
||||||
#else // not use OUTPUT
|
#else // not use OUTPUT
|
||||||
if ((pin < mcp230xx_pincount) && (pinmode > 0) && (pinmode < 5) && (pullup < 2)) {
|
if ((pin < mcp230xx_pincount) && (pinmode > 0) && (pinmode < 5) && (pullup < 2) && (paramcount > 2)) {
|
||||||
#endif // USE_MCP230xx_OUTPUT
|
#endif // USE_MCP230xx_OUTPUT
|
||||||
Settings.mcp230xx_config[pin].pinmode=pinmode;
|
Settings.mcp230xx_config[pin].pinmode=pinmode;
|
||||||
Settings.mcp230xx_config[pin].pullup=pullup;
|
Settings.mcp230xx_config[pin].pullup=pullup;
|
||||||
|
|
Loading…
Reference in New Issue