diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 509415cd..5c9d03c4 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -699,6 +699,11 @@ #define LIGHT_CH3_INVERSE 0 #define LIGHT_CH4_INVERSE 0 + // IR + #define IR_SUPPORT 1 + #define IR_PIN 4 + #define IR_BUTTON_SET 1 + #elif defined(MAGICHOME_LED_CONTROLLER_20) // Info @@ -706,7 +711,6 @@ #define DEVICE "LED_CONTROLLER_20" #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 //#define LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index a6cf877d..7b62fa97 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -294,6 +294,9 @@ void setup() { #if RF_SUPPORT rfSetup(); #endif + #if IR_SUPPORT + irSetup(); + #endif #if DOMOTICZ_SUPPORT domoticzSetup(); #endif @@ -356,5 +359,8 @@ void loop() { #if RF_SUPPORT rfLoop(); #endif + #if IR_SUPPORT + irLoop(); + #endif } diff --git a/code/espurna/ir.ino b/code/espurna/ir.ino index 1b842a7a..2a1e59b0 100644 --- a/code/espurna/ir.ino +++ b/code/espurna/ir.ino @@ -25,9 +25,9 @@ void _irProcessCode(unsigned long code) { boolean found = false; // Repeat last valid code - DEBUG_MSG_P(PSTR("[IR] Received 0x%08X\n"), code); + DEBUG_MSG_P(PSTR("[IR] Received 0x%06X\n"), code); if (code == 0xFFFFFFFF) { - DEBUG_MSG_P(PSTR("[IR] Processing 0x%08X\n"), code); + DEBUG_MSG_P(PSTR("[IR] Processing 0x%06X\n"), code); code = last_code; } @@ -39,6 +39,10 @@ void _irProcessCode(unsigned long code) { unsigned long button_mode = pgm_read_dword(&IR_BUTTON[i][1]); unsigned long button_value = pgm_read_dword(&IR_BUTTON[i][2]); + if (button_mode == IR_BUTTON_MODE_STATE) { + relayStatus(0, button_value); + } + #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE if (button_mode == IR_BUTTON_MODE_BRIGHTER) { @@ -50,23 +54,23 @@ void _irProcessCode(unsigned long code) { lightColor(button_value); } + /* + #if LIGHT_PROVIDER == LIGHT_PROVIDER_FASTLED + if (button_mode == IR_BUTTON_MODE_EFFECT) { + _buttonAnimMode(button_value); + } + #endif + */ + /* if (button_mode == IR_BUTTON_MODE_HSV) { lightColor(button_value); } */ - #endif + lightUpdate(true, true); - /* - #if LIGHT_PROVIDER == LIGHT_PROVIDER_FASTLED - if (button_mode == IR_BUTTON_MODE_EFFECT) { - _buttonAnimMode(button_value); - } #endif - */ - - lightUpdate(true, true); found = true; last_code = code; @@ -77,7 +81,6 @@ void _irProcessCode(unsigned long code) { } if (!found) { - last_code = 0; DEBUG_MSG_P(PSTR("[IR] Ignoring code\n")); } diff --git a/code/espurna/web.ino b/code/espurna/web.ino index 2a5289e8..7f9923cc 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -215,7 +215,7 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) { if (lightHasColor()) { if (action.equals("color") && root.containsKey("data")) { - lightColor(root["data"]); + lightColor((const char *) root["data"]); lightUpdate(true, true); }