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();