From 4c06e7e280edd2163d30f01eb82d5c578bfa5e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 19 Dec 2016 12:56:24 +0100 Subject: [PATCH 1/9] Added inching support --- code/data/index.html.gz | Bin 2579 -> 2753 bytes code/html/index.html | 24 ++++++++++++++++++++++-- code/src/config/general.h | 10 ++++++++++ code/src/relay.ino | 25 +++++++++++++++++++++++++ code/src/web.ino | 4 +++- 5 files changed, 60 insertions(+), 3 deletions(-) diff --git a/code/data/index.html.gz b/code/data/index.html.gz index d879c6416c1a747e0513785478c4c96b25875c19..42bf102c36f5c34bc5919cef235f24b59152e543 100644 GIT binary patch literal 2753 zcmV;y3O@B8iwFP!000001I=6EZreB#eifb$*G+-gPMq$d*xCkyG}#8%roP%m(ED?s zCCcK4615^_$NOma^PcQxNXnLEIgVqyTNH>XiZh%U4!@Zp)!yIUf4&-j8(x!0$70ZP ze;Ex1JsTcxGFS|H0iO{b^gTfrGS~2y zI*Px?EXh6d4qG3AIS3@EQnsUo)4_O^(gb+AAG+db=u;fCJehiR z+gt9rSf>zNX`}o4E3R2wR>*6jMy&#>DfH5WfjKqRIap~lz8rrY8HGB6A8>*xOISvQ zH~8)P?)uB+$0JOkn4f1{FF=dytFK>f$KQ@H$()DW8{FUC+#Z2>{D+2B{q(Q#csp|v z%ODrb{j^d!-+4NqVVO4=e!jo{vYN1yi;DZklqao8uC+{X8`)Ncz3Z|+tvrP}m^b)p zetR9;Js{gDGX^_9VLsU4OVQko9>57{;b%$L>wqrRza`}y)YLXCTE}8QWp@w*Cw(vA zDh1&9bt0tyP$k8kj5h5>=gYkW&0f?UT;*8?Qz5#Ae41xebD6-~Zi84U;3hB$WfoWT zH66=ViwZtXSb!rr69K5b4m?wY2|8g_5XoET#5GjhI&Z!42yn#3PV$iY8eV}GpGr^Q z9LQzR<4FoIznR$uGPC%v*&{%)h4%_)z-t=FL@fGV(ej$iu)6{_Sa^f?=67GA9k=6& z>qk80uz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GfZPCImaF)g-m!U6phNHH_O$WN4B~Jh5<mW67&6sk&a;M#PRG1&`+(p6{DGpMn<>X<{! z$2GTiP^w2cfcPnaWZg`mL_J+q%YaxK+iEyH<^mg18h?vaj(ft6CdLroBFzNs8uWM; zoWccSmZNN+{Mx`04SKPz27rx>*>;{-9$X*zA3JS}o&HBqW$>hePqE5!keG+RhZgcA
-
+
+ +
+ +
+
 
+
When inching enable the relay will automatically switch back to its normal state after the inching time (below).
+
+ +
+ + +
 
+
Inching time in seconds.
+
+
-
+
diff --git a/code/src/config/general.h b/code/src/config/general.h index 250ef440..bf261172 100644 --- a/code/src/config/general.h +++ b/code/src/config/general.h @@ -21,12 +21,22 @@ #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 + +// Inching time in seconds +#define RELAY_INCHING_TIME 1 + // 0 means OFF, 1 ON and 2 whatever was before #define RELAY_MODE RELAY_MODE_OFF // 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 + // ----------------------------------------------------------------------------- // WIFI & WEB // ----------------------------------------------------------------------------- diff --git a/code/src/relay.ino b/code/src/relay.ino index 77b7cb92..fd751a25 100644 --- a/code/src/relay.ino +++ b/code/src/relay.ino @@ -8,6 +8,7 @@ Copyright (C) 2016 by Xose PĂ©rez */ #include +#include #include #include @@ -16,6 +17,7 @@ bool recursive = false; #ifdef SONOFF_DUAL unsigned char dualRelayStatus = 0; #endif +Ticker inching; // ----------------------------------------------------------------------------- // RELAY @@ -58,6 +60,28 @@ bool relayStatus(unsigned char id) { #endif } +void relayInchingBack(unsigned char id) { + relayToggle(id); + inching.detach(); +} + +void relayInching(unsigned char id) { + + byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); + if (relayInch == RELAY_INCHING_NONE) return; + + bool status = relayStatus(id); + if ((relayInch == RELAY_INCHING_ON) & (status)) return; + if ((relayInch == RELAY_INCHING_OFF) & (!status)) return; + + inching.attach( + getSetting("relayInchTime", String(RELAY_INCHING_TIME)).toInt(), + relayInchingBack, + id + ); + +} + bool relayStatus(unsigned char id, bool status, bool report) { bool changed = false; @@ -82,6 +106,7 @@ bool relayStatus(unsigned char id, bool status, bool report) { #endif if (!recursive) { + relayInching(id); relaySync(id); relaySave(); } diff --git a/code/src/web.ino b/code/src/web.ino index 5645a24b..58fc5d94 100644 --- a/code/src/web.ino +++ b/code/src/web.ino @@ -234,6 +234,8 @@ void _wsStart(uint32_t client_id) { relay.add(relayStatus(relayID)); } root["relayMode"] = getSetting("relayMode", String(RELAY_MODE)); + root["relayInch"] = getSetting("relayInch", String(RELAY_INCHING)); + root["relayInchTime"] = getSetting("relayInchTime", String(RELAY_INCHING_TIME)); if (relayCount() > 1) { root["multirelayVisible"] = 1; root["relaySync"] = getSetting("relaySync", String(RELAY_SYNC)); @@ -502,7 +504,7 @@ void webSetup() { char lastModified[50]; sprintf(lastModified, "%s %s GMT", __DATE__, __TIME__); server.serveStatic("/", SPIFFS, "/").setLastModified(lastModified); - + // 404 server.onNotFound([](AsyncWebServerRequest *request){ request->send(404); From 7fe281f379647d9e963e9c735d2e9b5f17765b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 19 Dec 2016 13:05:55 +0100 Subject: [PATCH 2/9] Add config placeholder for Itead's 1CH inching module --- code/platformio.ini | 9 +++++++++ code/src/config/hardware.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/code/platformio.ini b/code/platformio.ini index edc8d1d4..d1aa66de 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -190,6 +190,15 @@ upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 +[env:1ch-inching-debug] +platform = espressif8266 +framework = arduino +board = esp01_1m +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +extra_script = pio_hooks.py +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DITEAD_1CH_INCHING + [env:electrodragon-debug] platform = espressif8266 framework = arduino diff --git a/code/src/config/hardware.h b/code/src/config/hardware.h index 249a21f6..e564cf32 100644 --- a/code/src/config/hardware.h +++ b/code/src/config/hardware.h @@ -113,6 +113,15 @@ #define LED_PIN 13 #define LED_PIN_INVERSE 0 +#elif defined(ITEAD_1CH_INCHING) + + #define MANUFACTURER "ITEAD" + #define DEVICE "1CH_INCHING" + #define BUTTON1_PIN 0 + #define RELAY1_PIN 12 + #define LED_PIN 13 + #define LED_PIN_INVERSE 0 + // ----------------------------------------------------------------------------- // Electrodragon boards // ----------------------------------------------------------------------------- From 26ae5a4dd49ac0b837747ed17f39e19019df1610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 19 Dec 2016 13:22:50 +0100 Subject: [PATCH 3/9] Prevent inching when manually switched back --- code/src/relay.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/src/relay.ino b/code/src/relay.ino index fd751a25..99e6348f 100644 --- a/code/src/relay.ino +++ b/code/src/relay.ino @@ -71,8 +71,11 @@ void relayInching(unsigned char id) { if (relayInch == RELAY_INCHING_NONE) return; bool status = relayStatus(id); - if ((relayInch == RELAY_INCHING_ON) & (status)) return; - if ((relayInch == RELAY_INCHING_OFF) & (!status)) return; + bool inchingStatus = (relayInch == RELAY_INCHING_ON); + if (inchingStatus == status) { + inching.detach(); + return; + } inching.attach( getSetting("relayInchTime", String(RELAY_INCHING_TIME)).toInt(), @@ -116,7 +119,7 @@ bool relayStatus(unsigned char id, bool status, bool report) { if (report) relayMQTT(id); if (!recursive) relayWS(); return changed; - + } void relaySync(unsigned char id) { From 9e00de6b6f842a27ac47ca8270c29cf8b639f1d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 20 Dec 2016 01:11:58 +0100 Subject: [PATCH 4/9] Support for hardware inching button --- code/src/button.ino | 13 +++++++++++++ code/src/config/hardware.h | 2 ++ code/src/web.ino | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/code/src/button.ino b/code/src/button.ino index baaaca41..85c0ce9d 100644 --- a/code/src/button.ino +++ b/code/src/button.ino @@ -77,6 +77,10 @@ void buttonSetup() { _buttons.push_back(new DebounceEvent(BUTTON4_PIN)); #endif + #ifdef ITEAD_1CH_INCHING + pinMode(LED_INCHING, OUTPUT); + #endif + DEBUG_MSG("[BUTTON] Number of buttons: %d\n", _buttons.size()); } @@ -91,6 +95,15 @@ void buttonLoop() { if (event == EVENT_DOUBLE_CLICK) createAP(); if (event == EVENT_LONG_CLICK) ESP.reset(); } + #ifdef ITEAD_1CH_INCHING + if (i == 1) { + byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); + relayInch = (relayInch == RELAY_INCHING_NONE) ? RELAY_INCHING_OFF : RELAY_INCHING_NONE; + setSetting("relayInch", String(relayInch)); + digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + continue; + } + #endif if (event == EVENT_SINGLE_CLICK) relayToggle(i); } } diff --git a/code/src/config/hardware.h b/code/src/config/hardware.h index e564cf32..c44555e9 100644 --- a/code/src/config/hardware.h +++ b/code/src/config/hardware.h @@ -118,9 +118,11 @@ #define MANUFACTURER "ITEAD" #define DEVICE "1CH_INCHING" #define BUTTON1_PIN 0 + #define BUTTON2_PIN 9 #define RELAY1_PIN 12 #define LED_PIN 13 #define LED_PIN_INVERSE 0 + #define LED_INCHING 5 // ----------------------------------------------------------------------------- // Electrodragon boards diff --git a/code/src/web.ino b/code/src/web.ino index 58fc5d94..cee4cc56 100644 --- a/code/src/web.ino +++ b/code/src/web.ino @@ -184,6 +184,11 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { setCurrentRatio(getSetting("emonRatio").toFloat()); #endif + #if ITEAD_1CH_INCHING + byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); + digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + #endif + // Check if we should reconfigure MQTT connection if (dirtyMQTT) { mqttDisconnect(); From 09fa28f28e3dca9ec87f135994b78e8f89d5d11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 20 Dec 2016 01:19:38 +0100 Subject: [PATCH 5/9] Set inching LED initial state --- code/src/button.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/src/button.ino b/code/src/button.ino index 85c0ce9d..7cc0f5bf 100644 --- a/code/src/button.ino +++ b/code/src/button.ino @@ -79,6 +79,8 @@ void buttonSetup() { #ifdef ITEAD_1CH_INCHING pinMode(LED_INCHING, OUTPUT); + byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); + digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); #endif DEBUG_MSG("[BUTTON] Number of buttons: %d\n", _buttons.size()); @@ -99,7 +101,7 @@ void buttonLoop() { if (i == 1) { byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); relayInch = (relayInch == RELAY_INCHING_NONE) ? RELAY_INCHING_OFF : RELAY_INCHING_NONE; - setSetting("relayInch", String(relayInch)); + setSetting("relayInch", String() + relayInch); digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); continue; } From 4a580376388d4feffda93a262ecec07ef4959c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 27 Dec 2016 04:53:26 +0100 Subject: [PATCH 6/9] Set inching mode through MQTT --- code/src/button.ino | 5 +-- code/src/config/hardware.h | 8 ++--- code/src/relay.ino | 69 ++++++++++++++++++++++++++++++++------ 3 files changed, 63 insertions(+), 19 deletions(-) diff --git a/code/src/button.ino b/code/src/button.ino index 7cc0f5bf..529dfcfe 100644 --- a/code/src/button.ino +++ b/code/src/button.ino @@ -99,10 +99,7 @@ void buttonLoop() { } #ifdef ITEAD_1CH_INCHING if (i == 1) { - byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); - relayInch = (relayInch == RELAY_INCHING_NONE) ? RELAY_INCHING_OFF : RELAY_INCHING_NONE; - setSetting("relayInch", String() + relayInch); - digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + relayInchingToggle(); continue; } #endif diff --git a/code/src/config/hardware.h b/code/src/config/hardware.h index ace41432..a67a7261 100644 --- a/code/src/config/hardware.h +++ b/code/src/config/hardware.h @@ -136,11 +136,11 @@ #define MANUFACTURER "ITEAD" #define DEVICE "1CH_INCHING" #define BUTTON1_PIN 0 - #define BUTTON2_PIN 9 + #define BUTTON2_PIN 15 #define RELAY1_PIN 12 - #define LED_PIN 13 - #define LED_PIN_INVERSE 0 - #define LED_INCHING 5 + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 0 + #define LED_INCHING 14 // ----------------------------------------------------------------------------- // Electrodragon boards diff --git a/code/src/relay.ino b/code/src/relay.ino index 5042eab7..1396f172 100644 --- a/code/src/relay.ino +++ b/code/src/relay.ino @@ -69,9 +69,9 @@ void relayInchingBack(unsigned char id) { inching.detach(); } -void relayInching(unsigned char id) { +void relayInchingStart(unsigned char id) { - byte relayInch = getSetting("relayInch", String(RELAY_INCHING)).toInt(); + byte relayInch = getSetting("relayInch", RELAY_INCHING).toInt(); if (relayInch == RELAY_INCHING_NONE) return; bool status = relayStatus(id); @@ -82,13 +82,53 @@ void relayInching(unsigned char id) { } inching.attach( - getSetting("relayInchTime", String(RELAY_INCHING_TIME)).toInt(), + getSetting("relayInchTime", RELAY_INCHING_TIME).toInt(), relayInchingBack, id ); } +unsigned int relayInching() { + unsigned int relayInch = getSetting("relayInch", RELAY_INCHING).toInt(); + return relayInch; +} + +void relayInching(unsigned int relayInch, bool report) { + + setSetting("relayInch", relayInch); + + /* + 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()); + char value[2]; + sprintf(value, "%d", relayInch); + mqttSend(topic, value); + } + */ + + char message[20]; + sprintf(message, "{\"relayInch\": %d}", relayInch); + wsSend(message); + + #ifdef LED_INCHING + digitalWrite(LED_INCHING, relayInch != RELAY_INCHING_NONE); + #endif + +} + +void relayInching(unsigned int relayInch) { + relayInching(relayInch, true); +} + +void relayInchingToggle() { + unsigned int relayInch = relayInching(); + relayInch = (relayInch == RELAY_INCHING_NONE) ? RELAY_INCHING_OFF : RELAY_INCHING_NONE; + relayInching(relayInch); +} + bool relayStatus(unsigned char id, bool status, bool report) { if (id >= _relays.size()) return false; @@ -115,7 +155,7 @@ bool relayStatus(unsigned char id, bool status, bool report) { #endif if (!recursive) { - relayInching(id); + relayInchingStart(id); relaySync(id); relaySave(); } @@ -209,10 +249,16 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo bool sameSetGet = mqttGetter.compareTo(mqttSetter) == 0; if (type == MQTT_CONNECT_EVENT) { + relayMQTT(); - char buffer[strlen(MQTT_RELAY_TOPIC) + mqttSetter.length() + 3]; + char buffer[strlen(MQTT_RELAY_TOPIC) + mqttSetter.length() + 10]; + sprintf(buffer, "%s/+%s", MQTT_RELAY_TOPIC, mqttSetter.c_str()); mqttSubscribe(buffer); + + sprintf(buffer, "%s/inching%s", MQTT_RELAY_TOPIC, mqttSetter.c_str()); + mqttSubscribe(buffer); + } if (type == MQTT_MESSAGE_EVENT) { @@ -222,11 +268,13 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo if (!t.startsWith(MQTT_RELAY_TOPIC)) return; if (!t.endsWith(mqttSetter)) return; - // If relayMode is not SAME avoid responding to a retained message - if (sameSetGet && isFirstMessage) { - isFirstMessage = false; - byte relayMode = getSetting("relayMode", RELAY_MODE).toInt(); - if (relayMode != RELAY_MODE_SAME) return; + // Get value + unsigned int value = (char)payload[0] - '0'; + + // Inching topic + if (t.indexOf("inching") > 0) { + relayInching(value, !sameSetGet); + return; } // Get relay ID @@ -234,7 +282,6 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo if (relayID >= relayCount()) relayID = 0; // Action to perform - unsigned int value = (char)payload[0] - '0'; if (value == 2) { relayToggle(relayID); } else { 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 7/9] 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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h}5o$bo&1N*&b#2tcp3p z%WY*bWL}=1vzjp0bVm^tkA#njkcj%y7JAry&R32W+?*{(&99%gIrw-<-go~Kd51FL zz7zHV3q0n*w&Gf9FUxv<=<1z|$tg;tktvk8T)?wY>z}T+$65NXvi1uv3rG~7Dl(dt zbA!CXXJCG#aO7D0!y&Qo*D{HB>&@Jw4;TV=a)QyFl2fcnQ2+?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.
From 17f1e09b869b3364f9ddc4770bdbca5b3e06c6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 11 Jan 2017 13:58:24 +0100 Subject: [PATCH 8/9] Rename relayPulseStart to relayPulse --- code/espurna/relay.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index cf8eeb29..3fe65617 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -74,7 +74,7 @@ void relayPulseBack(unsigned char id) { pulseTicker.detach(); } -void relayPulseStart(unsigned char id) { +void relayPulse(unsigned char id) { byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt(); if (relayPulseMode == RELAY_PULSE_NONE) return; @@ -160,7 +160,7 @@ bool relayStatus(unsigned char id, bool status, bool report) { #endif if (!recursive) { - relayPulseStart(id); + relayPulse(id); relaySync(id); relaySave(); } From e5b1352d4191a5a5e2024470cf7dde280fdf4a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 20 Jan 2017 14:41:14 +0100 Subject: [PATCH 9/9] Added missing configuration values to 1ch-inching board --- code/espurna/config/hardware.h | 3 +++ code/espurna/data/index.html.gz | Bin 3714 -> 3716 bytes code/espurna/relay.ino | 2 +- code/html/index.html | 10 +++++----- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 71ddf4f7..2d0dd5f2 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -146,8 +146,11 @@ #define MANUFACTURER "ITEAD" #define DEVICE "1CH_INCHING" #define BUTTON1_PIN 0 + #define BUTTON1_RELAY 1 #define BUTTON2_PIN 15 + #define BUTTON2_RELAY 0 #define RELAY1_PIN 12 + #define RELAY1_PIN_INVERSE 0 #define LED1_PIN 13 #define LED1_PIN_INVERSE 0 #define LED_PULSE 14 diff --git a/code/espurna/data/index.html.gz b/code/espurna/data/index.html.gz index 64b44bfd24a0dbfeedfc689f0cabd679e90079e9..bde3ff451a0fbb148705fc21c8609ff56df87187 100644 GIT binary patch literal 3716 zcmV-~4twz*iwFP!000001I=7*Q{y-i{wq3f-7Zv-1j5YL)Gnlo0%kXLGr&P+x!o^U zimk*tY|CrOgv{0bvHN(x?7CaBV>=0uH+E}kz%Np(-_&}#C3EtZi|g~juQ!)0G;!2B zaX$qQdM8GjNc1l6Zt^VQ?63|0PCEACNh}O!e#kQ|%&C`~QR{=(JBeiSz%mh?dOB2@ z@pHqZuM&@$X(~=V8S}B|JhkkzFcYIwZ^R$*whcc#M>gRxG=7v~k^&Kr!D}ND7-k{^ z6P^YFdWaU?9LPi($)lF`c_dDc>O7cfBy=c*DF&k_ZC`6>*RetlRWR+H1oDx|;M9xw zROJTVa@XUVSR}be@9^pq5C?`LuC;y8!r`F3PI&?}-7h|)Nd4`t>z3x3Xt~GOe(re- zIg`oQYwF%o&!hPsk<^A{pMNEdh^qp5i+ZC}0XH0;@27c~_;N=Abt1XN z0mdQ`8IQc)PnTDhw`ZSrFoYIvpTz|eE^v{1=dDv7I&PBLJoIvf^&{La~jH1}77f78#y!v4nDgU9~6$1$B^dvkgr!ZWe zgx%hGo@Fo;2Gx-q=NUIrC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vGtMBdOaU>FC3U<1NziMVB(d z$8~8TFfYsJxIv6n-C@L&2PQ|5En?J{b4LKI;aY-!Hcc@6v`DSL(?*sehxo8WoOLNtD3}ze4D84(5q&iBQ-C7FRH#Q8J6=nJtRA0*I@L-gw zm>ur7S>G0jhl*#IwqWHdnpR4ga#mJ8e2#huQ8%Dn*ux5ySUf&mUKGL7SUy5pMzkFi z95|+zd6pn{MMVjN8gQb4^f6mp$OiB6IyDzBSU5pBYyB`nF?~>DzJD;L4QTy(n5PEU~knB@PpF$ zE(ukp+>?huYy$bJrd2 zF!1Ro?4BF2!h84Dg<-mg#yHpL+!iZYBp*=!hIuq}WmD(bsQy3(T$%%>usSi38iC<> zt^5bjiACB2Fh~WqSuCtDzPzX8S(rHTAyEW$F<|nikv6j;IgS6aP|6%JU2*DYv$Pxz&w1B zVE|7N_lPbXPFJZ6FSugZsHfts_lVYVn46;G^&6j<@qIz+Z0l={-{-gwN!Z<8XHDh+j6VZ&Fx#Nh_rf#knao$_OU(7`J2v(iTI=zK;H<)(x|Qj^ zf8Q?t?~Zd{bWXRcYO9fgb-M4$6T3CI7~rSNsHE$v76MqGdmq~LZ>JiELC%H3kG0tq zUh%a@K|nBiU5t^QRmqLKO9@2O^e7clE#Y{rGkWgB?gbw$Y$G(7i^S-bUF}au z&|3eLbgzN_SVZ%?$o1p9>I%gtlJ+b9!{*JfX07Orh_8~}zxcq1@{pT8@sQ`pXV`wIE^+E^93fRZa=vyQE{Z4C_HHK$-gz@R{PWbK@;s~ gGBr$RK7@Pp-2NBU>}&%b=r6teAGHv&8vjKA07>37nE(I) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index dfdcffeb..f6cddb25 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -118,7 +118,7 @@ void relayPulseMode(unsigned int value, bool report) { wsSend(message); #ifdef LED_PULSE - digitalWrite(LED_PULSE, relayPulseMode != RELAY_PULSE_NONE); + digitalWrite(LED_PULSE, value != RELAY_PULSE_NONE); #endif } diff --git a/code/html/index.html b/code/html/index.html index defd5d43..fcbfb0d9 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -197,7 +197,7 @@
-