Browse Source

Clean up IR code

fastled
Xose Pérez 7 years ago
parent
commit
2f91d90814
4 changed files with 27 additions and 14 deletions
  1. +5
    -1
      code/espurna/config/hardware.h
  2. +6
    -0
      code/espurna/espurna.ino
  3. +15
    -12
      code/espurna/ir.ino
  4. +1
    -1
      code/espurna/web.ino

+ 5
- 1
code/espurna/config/hardware.h View File

@ -699,6 +699,11 @@
#define LIGHT_CH3_INVERSE 0 #define LIGHT_CH3_INVERSE 0
#define LIGHT_CH4_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) #elif defined(MAGICHOME_LED_CONTROLLER_20)
// Info // Info
@ -706,7 +711,6 @@
#define DEVICE "LED_CONTROLLER_20" #define DEVICE "LED_CONTROLLER_20"
#define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT
#define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER
#define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER
#define DUMMY_RELAY_COUNT 1 #define DUMMY_RELAY_COUNT 1
//#define LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR //#define LIGHT_PROVIDER_EXPERIMENTAL_RGB_ONLY_HSV_IR


+ 6
- 0
code/espurna/espurna.ino View File

@ -294,6 +294,9 @@ void setup() {
#if RF_SUPPORT #if RF_SUPPORT
rfSetup(); rfSetup();
#endif #endif
#if IR_SUPPORT
irSetup();
#endif
#if DOMOTICZ_SUPPORT #if DOMOTICZ_SUPPORT
domoticzSetup(); domoticzSetup();
#endif #endif
@ -356,5 +359,8 @@ void loop() {
#if RF_SUPPORT #if RF_SUPPORT
rfLoop(); rfLoop();
#endif #endif
#if IR_SUPPORT
irLoop();
#endif
} }

+ 15
- 12
code/espurna/ir.ino View File

@ -25,9 +25,9 @@ void _irProcessCode(unsigned long code) {
boolean found = false; boolean found = false;
// Repeat last valid code // 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) { 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; 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_mode = pgm_read_dword(&IR_BUTTON[i][1]);
unsigned long button_value = pgm_read_dword(&IR_BUTTON[i][2]); 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 LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
if (button_mode == IR_BUTTON_MODE_BRIGHTER) { if (button_mode == IR_BUTTON_MODE_BRIGHTER) {
@ -50,23 +54,23 @@ void _irProcessCode(unsigned long code) {
lightColor(button_value); 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) { if (button_mode == IR_BUTTON_MODE_HSV) {
lightColor(button_value); lightColor(button_value);
} }
*/ */
#endif
lightUpdate(true, true);
/*
#if LIGHT_PROVIDER == LIGHT_PROVIDER_FASTLED
if (button_mode == IR_BUTTON_MODE_EFFECT) {
_buttonAnimMode(button_value);
}
#endif #endif
*/
lightUpdate(true, true);
found = true; found = true;
last_code = code; last_code = code;
@ -77,7 +81,6 @@ void _irProcessCode(unsigned long code) {
} }
if (!found) { if (!found) {
last_code = 0;
DEBUG_MSG_P(PSTR("[IR] Ignoring code\n")); DEBUG_MSG_P(PSTR("[IR] Ignoring code\n"));
} }


+ 1
- 1
code/espurna/web.ino View File

@ -215,7 +215,7 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
if (lightHasColor()) { if (lightHasColor()) {
if (action.equals("color") && root.containsKey("data")) { if (action.equals("color") && root.containsKey("data")) {
lightColor(root["data"]);
lightColor((const char *) root["data"]);
lightUpdate(true, true); lightUpdate(true, true);
} }


Loading…
Cancel
Save