TOGGLE input re-intrrable issue fixed double toggling

This commit is contained in:
2019-08-29 01:06:07 +03:00
parent 90965aad85
commit 549bd6527c
4 changed files with 24 additions and 15 deletions

View File

@@ -435,13 +435,15 @@ void Input::contactPoll() {
if (inType & IN_PUSH_TOGGLE) {
if (currentInputState) { //react on leading edge only (change from 0 to 1)
store->logicState = !store->logicState;
store->currentValue = currentInputState;
onContactChanged(store->logicState);
}
} else {
store->logicState = currentInputState;
store->currentValue = currentInputState;
onContactChanged(currentInputState);
}
store->currentValue = currentInputState;
// store->currentValue = currentInputState;
}
} else // no change
store->bounce = SAME_STATE_ATTEMPTS;

View File

@@ -31,10 +31,11 @@ e-mail anklimov@gmail.com
#ifndef MODBUS_DISABLE
#include <ModbusMaster.h>
#endif
#include <PubSubClient.h>
#include <PubSubClient.h>
#include "modules/out_spiled.h"
//Commands
const char ON_P[] PROGMEM = "ON";
const char OFF_P[] PROGMEM = "OFF";
const char REST_P[] PROGMEM = "REST";
@@ -50,12 +51,14 @@ const char FALSE_P[] PROGMEM = "FALSE";
const char HEAT_P[] PROGMEM = "HEAT";
const char COOL_P[] PROGMEM = "COOL";
const char AUTO_P[] PROGMEM = "AUTO";
const char FAN_P[] PROGMEM = "FAN_ONLY";
const char FAN_ONLY_P[] PROGMEM = "FAN_ONLY";
const char DRY_P[] PROGMEM = "DRY";
// SubTopics
const char SET_P[] PROGMEM = "set";
const char CMD_P[] PROGMEM = "cmd";
const char MODE_P[] PROGMEM = "mode";
const char FAN_P[] PROGMEM = "fan";
/*
const char TEMP_P[] PROGMEM = "temp";
const char SETPOINT_P[] PROGMEM = "setpoint";
@@ -65,9 +68,10 @@ const char HEAT_P[] PROGMEM = "heat";
*/
const char HSV_P[] PROGMEM = "hsv";
const char RGB_P[] PROGMEM = "rgb";
/*
const char RPM_P[] PROGMEM = "rpm";
const char STATE_P[] PROGMEM = "state";
*/
short modbusBusy = 0;
extern aJsonObject *pollingItem;
extern PubSubClient mqttClient;
@@ -91,7 +95,7 @@ int txt2cmd(char *payload) {
else if (strcmp_P(payload, HEAT_P) == 0) cmd = CMD_HEAT;
else if (strcmp_P(payload, COOL_P) == 0) cmd = CMD_COOL;
else if (strcmp_P(payload, AUTO_P) == 0) cmd = CMD_AUTO;
else if (strcmp_P(payload, FAN_P) == 0) cmd = CMD_FAN;
else if (strcmp_P(payload, FAN_ONLY_P) == 0) cmd = CMD_FAN;
else if (strcmp_P(payload, DRY_P) == 0) cmd = CMD_DRY;
else if (strcmp_P(payload, TRUE_P) == 0) cmd = CMD_ON;
else if (strcmp_P(payload, FALSE_P) == 0) cmd = CMD_OFF;
@@ -111,9 +115,10 @@ int txt2subItem(char *payload) {
// Check for command
if (strcmp_P(payload, SET_P) == 0) cmd = S_SET;
else if (strcmp_P(payload, CMD_P) == 0) cmd = S_CMD;
else if (strcmp_P(payload, MODE_P) == 0) cmd = S_MODE;
// else if (strcmp_P(payload, MODE_P) == 0) cmd = S_MODE;
else if (strcmp_P(payload, HSV_P) == 0) cmd = S_HSV;
else if (strcmp_P(payload, RGB_P) == 0) cmd = S_RGB;
else if (strcmp_P(payload, FAN_P) == 0) cmd = S_FAN;
/* UnUsed now
else if (strcmp_P(payload, SETPOINT_P) == 0) cmd = S_SETPOINT;
else if (strcmp_P(payload, TEMP_P) == 0) cmd = S_TEMP;
@@ -428,7 +433,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
if (itemType == CH_GROUP && !send)
{
debugSerial<<F("Skip Grp")<<endl;
return -1;
return -1;
}
int iaddr = getArg();

View File

@@ -24,16 +24,18 @@ e-mail anklimov@gmail.com
#define S_SETnCMD 0
#define S_CMD 1
#define S_SET 2
#define S_TEMP 3
#define S_HSV 3
#define S_RGB 4
#define S_FAN 5
/*
#define S_MODE 4
#define S_RPM 11
#define S_TEMP 3
#define S_SETPOINT 5
#define S_POWER 6
#define S_VOL 7
#define S_HEAT 8
#define S_HSV 9
#define S_RGB 10
#define S_RPM 11
*/
#define CH_DIMMER 0 //DMX 1 ch
#define CH_RGBW 1 //DMX 4 ch
#define CH_RGB 2 //DMX 3 ch

View File

@@ -73,10 +73,10 @@ debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd<<endl;
switch (suffixCode)
{
case S_POWER:
case S_VOL:
// case S_POWER:
// case S_VOL:
//leds[n].setBrightness(Parameters[0]);
break;
// break;
case S_SET:
case S_HSV:
debugSerial<<F("HSV: ")<<i<<F(" :")<<Parameters[0]<<Parameters[1]<<Parameters[2]<<endl;