From e2cb9fcaa0fe73abe2a36d532e8f9355ce590f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 11 Jan 2017 13:52:51 +0100 Subject: [PATCH] Rename inching to pulse --- code/espurna/button.ino | 10 ++--- code/espurna/config/general.h | 14 +++---- code/espurna/config/hardware.h | 6 ++- code/espurna/data/index.html.gz | Bin 3250 -> 3418 bytes code/espurna/relay.ino | 66 ++++++++++++++++---------------- code/espurna/web.ino | 8 ++-- code/html/index.html | 14 +++---- 7 files changed, 61 insertions(+), 57 deletions(-) diff --git a/code/espurna/button.ino b/code/espurna/button.ino index 529dfcfe..1d39a35f 100644 --- a/code/espurna/button.ino +++ b/code/espurna/button.ino @@ -77,10 +77,10 @@ void buttonSetup() { _buttons.push_back(new DebounceEvent(BUTTON4_PIN)); #endif - #ifdef ITEAD_1CH_INCHING - pinMode(LED_INCHING, OUTPUT); - byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); - digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + #ifdef LED_PULSE + pinMode(LED_PULSE, OUTPUT); + byte relayPulseMode = getSetting("relayPulseMode", String(RELAY_PULSE_MODE)).toInt(); + digitalWrite(LED_PULSE, relayPulseMode != RELAY_PULSE_NONE); #endif DEBUG_MSG("[BUTTON] Number of buttons: %d\n", _buttons.size()); @@ -99,7 +99,7 @@ void buttonLoop() { } #ifdef ITEAD_1CH_INCHING if (i == 1) { - relayInchingToggle(); + relayPulseToggle(); continue; } #endif diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index c8d0fdad..7b23d978 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -20,12 +20,12 @@ #define RELAY_SYNC_ONE 2 #define RELAY_SYNC_SAME 3 -#define RELAY_INCHING_NONE 0 -#define RELAY_INCHING_OFF 1 -#define RELAY_INCHING_ON 2 +#define RELAY_PULSE_NONE 0 +#define RELAY_PULSE_OFF 1 +#define RELAY_PULSE_ON 2 -// Inching time in seconds -#define RELAY_INCHING_TIME 1 +// Pulse time in seconds +#define RELAY_PULSE_TIME 1 // 0 means OFF, 1 ON and 2 whatever was before #define RELAY_MODE RELAY_MODE_OFF @@ -33,8 +33,8 @@ // 0 means ANY, 1 zero or one and 2 one and only one #define RELAY_SYNC RELAY_SYNC_ANY -// 0 means no inching, 1 means normally off, 2 normally on -#define RELAY_INCHING RELAY_INCHING_NONE +// 0 means no pulses, 1 means normally off, 2 normally on +#define RELAY_PULSE_MODE RELAY_PULSE_NONE //-------------------------------------------------------------------------------- // LED diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index f5f67cf8..289bfac5 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -158,6 +158,10 @@ #elif defined(ITEAD_1CH_INCHING) + // Note: definitions for this board are based on third party data + // and have not been fully tested yet. If you have the chance to + // test them, please report back. Thank you. + #define MANUFACTURER "ITEAD" #define DEVICE "1CH_INCHING" #define BUTTON1_PIN 0 @@ -165,7 +169,7 @@ #define RELAY1_PIN 12 #define LED1_PIN 13 #define LED1_PIN_INVERSE 0 - #define LED_INCHING 14 + #define LED_PULSE 14 // ----------------------------------------------------------------------------- // Electrodragon boards diff --git a/code/espurna/data/index.html.gz b/code/espurna/data/index.html.gz index 2e18235ddda36ee699d17020c779c5483490db45..006c0967a57cc1b4832a78d2d090ab9e2adb5772 100644 GIT binary patch literal 3418 zcmV-g4W;rQiwFP!000001I=4)Z{s!+{wq8c*Cs%0C(fo=w26Tr$+pJrCb`6mz4pt2 zmS~HOB&s46$35I1yN~zFZe~cylKhhRZF>k}>xCT742Lt%4C(W~T;E*{e!0J4p^2m3 zx%(76=$#vBBGJ2fyw9_Qv*R}Wop)iDe?X@N}p$ zgRxG=7$1k^&Kr!D}ND7-k{^ z6J7)YdWaU?9LYo)$)lF`c_c1Q>O7cfBy=c*DF&k_ZC`6>*RetlRWR+H2lAQ8;KGae zROJTVa@XUVSR}be@9^p)5C?`LuC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2fcnQ2+?DNYcP!0p!{+3wO?$ zbF534YQ}inBzbT)nTxXY+NQ6ZOu%h(t%&co%`pssm=9J0^2WlDc{QnjMUG6J5zC3= zRL11wZIkqE!D%FEifIcZ9wM5RN+Wz;raDBi@2N@sxex^$HI9x7+*P62TRz*I6Czb@Qio|o_Hz0wBV39wZL=uU>^)<+{g!gSQy zn(0eoDL9s|@-PHw2wfrCXv!2R z`D5QF8EFIhaR}@#BrJZ&zFcqPip{=2%=A3>#Fj}a6L{i^Pfc*&NOI<~1!#DJA5oD^ z_)gNITuw5fW#)&b#QZ&$6v%(=wBxpqFD}W$&4AdQUt%6^VuGYZv9ys~9b^g8d0#fp zclA|wazNk%K?@T^bibLxaJJm6BL0XLH_D=sE0nreW-1QGWpjN@B-SIQTp=-RucZG7 zR-MJnXiSm8-|nspmHsulti_HQ z{ezoLHuFoS`k~$J_wmXjwg3PC diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 9e896cab..cf8eeb29 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -21,7 +21,7 @@ bool recursive = false; #ifdef SONOFF_DUAL unsigned char dualRelayStatus = 0; #endif -Ticker inching; +Ticker pulseTicker; // ----------------------------------------------------------------------------- // RELAY @@ -69,69 +69,69 @@ bool relayStatus(unsigned char id) { #endif } -void relayInchingBack(unsigned char id) { +void relayPulseBack(unsigned char id) { relayToggle(id); - inching.detach(); + pulseTicker.detach(); } -void relayInchingStart(unsigned char id) { +void relayPulseStart(unsigned char id) { - byte relayInch = getSetting("relayInch", RELAY_INCHING).toInt(); - if (relayInch == RELAY_INCHING_NONE) return; + byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt(); + if (relayPulseMode == RELAY_PULSE_NONE) return; bool status = relayStatus(id); - bool inchingStatus = (relayInch == RELAY_INCHING_ON); - if (inchingStatus == status) { - inching.detach(); + bool pulseStatus = (relayPulseMode == RELAY_PULSE_ON); + if (pulseStatus == status) { + pulseTicker.detach(); return; } - inching.attach( - getSetting("relayInchTime", RELAY_INCHING_TIME).toInt(), - relayInchingBack, + pulseTicker.attach( + getSetting("relayPulseTime", RELAY_PULSE_TIME).toInt(), + relayPulseBack, id ); } -unsigned int relayInching() { - unsigned int relayInch = getSetting("relayInch", RELAY_INCHING).toInt(); - return relayInch; +unsigned int relayPulseMode() { + unsigned int value = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt(); + return value; } -void relayInching(unsigned int relayInch, bool report) { +void relayPulseMode(unsigned int value, bool report) { - setSetting("relayInch", relayInch); + setSetting("relayPulseMode", value); /* if (report) { String mqttGetter = getSetting("mqttGetter", MQTT_USE_GETTER); char topic[strlen(MQTT_RELAY_TOPIC) + mqttGetter.length() + 10]; - sprintf(topic, "%s/inching%s", MQTT_RELAY_TOPIC, mqttGetter.c_str()); + sprintf(topic, "%s/pulse%s", MQTT_RELAY_TOPIC, mqttGetter.c_str()); char value[2]; - sprintf(value, "%d", relayInch); + sprintf(value, "%d", value); mqttSend(topic, value); } */ char message[20]; - sprintf(message, "{\"relayInch\": %d}", relayInch); + sprintf(message, "{\"relayPulseMode\": %d}", value); wsSend(message); - #ifdef LED_INCHING - digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + #ifdef LED_PULSE + digitalWrite(LED_PULSE, relayPulseMode != RELAY_PULSE_NONE); #endif } -void relayInching(unsigned int relayInch) { - relayInching(relayInch, true); +void relayPulseMode(unsigned int value) { + relayPulseMode(value, true); } -void relayInchingToggle() { - unsigned int relayInch = relayInching(); - relayInch = (relayInch == RELAY_INCHING_NONE) ? RELAY_INCHING_OFF : RELAY_INCHING_NONE; - relayInching(relayInch); +void relayPulseToggle() { + unsigned int value = relayPulseMode(); + value = (value == RELAY_PULSE_NONE) ? RELAY_PULSE_OFF : RELAY_PULSE_NONE; + relayPulseMode(value); } bool relayStatus(unsigned char id, bool status, bool report) { @@ -160,7 +160,7 @@ bool relayStatus(unsigned char id, bool status, bool report) { #endif if (!recursive) { - relayInchingStart(id); + relayPulseStart(id); relaySync(id); relaySave(); } @@ -263,7 +263,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo sprintf(buffer, "%s/+%s", MQTT_RELAY_TOPIC, mqttSetter.c_str()); mqttSubscribe(buffer); - sprintf(buffer, "%s/inching%s", MQTT_RELAY_TOPIC, mqttSetter.c_str()); + sprintf(buffer, "%s/pulse%s", MQTT_RELAY_TOPIC, mqttSetter.c_str()); mqttSubscribe(buffer); } @@ -278,9 +278,9 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo // Get value unsigned int value = (char)payload[0] - '0'; - // Inching topic - if (t.indexOf("inching") > 0) { - relayInching(value, !sameSetGet); + // Pulse topic + if (t.indexOf("pulse") > 0) { + relayPulseMode(value, !sameSetGet); return; } diff --git a/code/espurna/web.ino b/code/espurna/web.ino index 151deb7d..bb2df58f 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -237,8 +237,8 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { #endif #if ITEAD_1CH_INCHING - byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); - digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + byte relayPulseMode = getSetting("relayPulseMode", String(RELAY_PULSE_MODE)).toInt(); + digitalWrite(LED_PULSE, relayPulseMode != RELAY_PULSE_NONE); #endif // Check if we should reconfigure MQTT connection @@ -291,8 +291,8 @@ void _wsStart(uint32_t client_id) { relay.add(relayStatus(relayID)); } root["relayMode"] = getSetting("relayMode", RELAY_MODE); - root["relayInch"] = getSetting("relayInch", RELAY_INCHING); - root["relayInchTime"] = getSetting("relayInchTime", RELAY_INCHING_TIME); + root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE); + root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME); if (relayCount() > 1) { root["multirelayVisible"] = 1; root["relaySync"] = getSetting("relaySync", RELAY_SYNC); diff --git a/code/html/index.html b/code/html/index.html index 82ab1ba9..48b1b969 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -197,23 +197,23 @@

- +
- +
 
-
When inching enable the relay will automatically switch back to its normal state after the inching time (below).
+
When pulse mode is enabled the relay will automatically switch back to its normal state after the pulse time (below).
- - + +
 
-
Inching time in seconds.
+
Pulse time in seconds.