From f4d84fc4e13fadf9c4a2f59e3c2f73056718adc4 Mon Sep 17 00:00:00 2001 From: Sam Quinn Date: Sun, 19 May 2019 01:06:00 -0700 Subject: [PATCH 1/4] Added a version of the Magichome LED controllers that only have RGB without the White LED controll or IR remote sensor. --- code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 62 +++++++++++++++++++++++----------- code/espurna/migrate.ino | 15 ++++++++ 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 0a6c255dd8..424a07f8b6 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -91,6 +91,7 @@ //#define LUANI_HVIO //#define LYASI_LIGHT //#define MAGICHOME_LED_CONTROLLER +//#defire MAGICHOME_LED_CONTROLLER_RGB //#define MAGICHOME_LED_CONTROLLER_20 //#define MAGICHOME_ZJ_WFMN_A_11 //#define MAGICHOME_ZJ_WFMN_B_11 diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 557f472c69..91cdef6f5e 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -702,11 +702,19 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 - #define RF_SUPPORT 1 + // RFB Direct hack thanks to @wildwiz + // https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack + #ifndef RFB_DIRECT + #define RFB_DIRECT 0 + #endif - // Only used when RFB_DIRECT=1 - #define RFB_RX_PIN 4 - #define RFB_TX_PIN 5 + #ifndef RFB_RX_PIN + #define RFB_RX_PIN 4 // GPIO for RX when RFB_DIRECT + #endif + + #ifndef RFB_TX_PIN + #define RFB_TX_PIN 5 // GPIO for TX when RFB_DIRECT + #endif // When using un-modified harware, ESPurna communicates with the secondary // MCU EFM8BB1 via UART at 19200 bps so we need to change the speed of @@ -1168,6 +1176,26 @@ // ----------------------------------------------------------------------------- // LED Controller // ----------------------------------------------------------------------------- +#elif defined(MAGICHOME_LED_CONTROLLER_RGB) + // Info + #define MANUFACTURER "MAGICHOME" + #define DEVICE "LED_CONTROLLER_RGB" + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER + #define DUMMY_RELAY_COUNT 1 + + // LEDs + #define LED1_PIN 2 + #define LED1_PIN_INVERSE 1 + + // Light + #define LIGHT_CHANNELS 3 + #define LIGHT_CH1_PIN 5 // RED + #define LIGHT_CH2_PIN 12 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 #elif defined(MAGICHOME_LED_CONTROLLER) @@ -1286,8 +1314,7 @@ // RF #define RF_SUPPORT 1 - #define RFB_DIRECT 1 - #define RFB_RX_PIN 4 + #define RF_PIN 4 // ----------------------------------------------------------------------------- // HUACANXING H801 & H802 @@ -2423,9 +2450,10 @@ #endif #define DALLAS_PIN 2 + #ifndef RF_SUPPORT #define RF_SUPPORT 1 - #define RFB_DIRECT 1 - #define RFB_RX_PIN 14 + #endif + #define RF_PIN 14 #ifndef DIGITAL_SUPPORT #define DIGITAL_SUPPORT 1 @@ -3277,9 +3305,9 @@ // Relays #define RELAY1_PIN 15 - #define RELAY1_TYPE RELAY_TYPE_NORMAL - - // Light RGBW + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // Light RGBW #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 @@ -3292,8 +3320,8 @@ #define LIGHT_CH1_INVERSE 0 #define LIGHT_CH2_INVERSE 0 #define LIGHT_CH3_INVERSE 0 - #define LIGHT_CH4_INVERSE 0 - + #define LIGHT_CH4_INVERSE 0 + // ---------------------------------------------------------------------------------------- // Smart life Mini Smart Socket is similar Homecube 16A but some GPIOs differ // https://www.ebay.de/itm/Smart-Steckdose-WIFI-WLAN-Amazon-Alexa-Fernbedienung-Home-Socket-Zeitschaltuh-DE/123352026749?hash=item1cb85a8e7d:g:IasAAOSwk6dbj390 @@ -3501,7 +3529,7 @@ #define LED1_PIN 4 // 4 blue led #define LED1_MODE LED_MODE_WIFI #define LED1_PIN_INVERSE 1 - + #define LED2_PIN 5 // 5 red led #define LED2_MODE LED_MODE_RELAY #define LED2_PIN_INVERSE 1 @@ -3666,11 +3694,7 @@ #define NOFUSS_SUPPORT 1 #define UART_MQTT_SUPPORT 1 #define INFLUXDB_SUPPORT 1 - #define IR_SUPPORT 1 - #define RF_SUPPORT 1 - - #define RFB_DIRECT 1 - #define RFB_RX_PIN 4 + #define IR_SUPPORT 1 #elif defined(TRAVIS03) diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 0f084b5557..66b033e404 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -285,6 +285,21 @@ void migrate() { setSetting("chLogic", 3, 0); setSetting("relays", 1); + #elif defined(MAGICHOME_LED_CONTROLLER_RGB) + + setSetting("board", 21); + setSetting("relayProvider", RELAY_PROVIDER_LIGHT); + setSetting("lightProvider", LIGHT_PROVIDER_DIMMER); + setSetting("ledGPIO", 0, 2); + setSetting("ledLogic", 0, 1); + setSetting("chGPIO", 0, 14); + setSetting("chGPIO", 1, 5); + setSetting("chGPIO", 2, 12); + setSetting("chLogic", 0, 0); + setSetting("chLogic", 1, 0); + setSetting("chLogic", 2, 0); + setSetting("relays", 1); + #elif defined(MAGICHOME_LED_CONTROLLER_IR) setSetting("board", 21); From 4ba70eb7154db71e51bf45c5457aa0adc00701f1 Mon Sep 17 00:00:00 2001 From: Sam Quinn Date: Sun, 19 May 2019 01:12:20 -0700 Subject: [PATCH 2/4] Forgot to update platformio.ini with the build flags for Magichome RGB led controller --- code/platformio.ini | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/code/platformio.ini b/code/platformio.ini index 983261f5c0..8d3d571ab2 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1317,6 +1317,32 @@ upload_flags = ${common.upload_flags} monitor_speed = ${common.monitor_speed} extra_scripts = ${common.extra_scripts} +[env:magichome-led-controller_rgb] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DMAGICHOME_LED_CONTROLLER_RGB +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + +[env:magichome-led-controller-rgb-ota] +platform = ${common.platform} +framework = ${common.framework} +board = ${common.board_1m} +board_build.flash_mode = ${common.flash_mode} +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DMAGICHOME_LED_CONTROLLER_RGB +upload_speed = ${common.upload_speed} +upload_port = ${common.upload_port} +upload_flags = ${common.upload_flags} +monitor_speed = ${common.monitor_speed} +extra_scripts = ${common.extra_scripts} + + [env:magichome-led-controller-20] platform = ${common.platform} framework = ${common.framework} From ff3ebd2b81e930f662a4f15e546045bae602c629 Mon Sep 17 00:00:00 2001 From: Sam Quinn Date: Sun, 19 May 2019 02:05:26 -0700 Subject: [PATCH 3/4] Auto-indenting caused more changes then nessesary --- code/espurna/config/hardware.h | 84 ++++++++++++++++------------------ 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 91cdef6f5e..a1e6de34eb 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -702,19 +702,11 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 - // RFB Direct hack thanks to @wildwiz - // https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge---Direct-Hack - #ifndef RFB_DIRECT - #define RFB_DIRECT 0 - #endif - - #ifndef RFB_RX_PIN - #define RFB_RX_PIN 4 // GPIO for RX when RFB_DIRECT - #endif + #define RF_SUPPORT 1 - #ifndef RFB_TX_PIN - #define RFB_TX_PIN 5 // GPIO for TX when RFB_DIRECT - #endif + // Only used when RFB_DIRECT=1 + #define RFB_RX_PIN 4 + #define RFB_TX_PIN 5 // When using un-modified harware, ESPurna communicates with the secondary // MCU EFM8BB1 via UART at 19200 bps so we need to change the speed of @@ -1176,27 +1168,6 @@ // ----------------------------------------------------------------------------- // LED Controller // ----------------------------------------------------------------------------- -#elif defined(MAGICHOME_LED_CONTROLLER_RGB) - // Info - #define MANUFACTURER "MAGICHOME" - #define DEVICE "LED_CONTROLLER_RGB" - #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT - #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER - #define DUMMY_RELAY_COUNT 1 - - // LEDs - #define LED1_PIN 2 - #define LED1_PIN_INVERSE 1 - - // Light - #define LIGHT_CHANNELS 3 - #define LIGHT_CH1_PIN 5 // RED - #define LIGHT_CH2_PIN 12 // GREEN - #define LIGHT_CH3_PIN 13 // BLUE - #define LIGHT_CH1_INVERSE 0 - #define LIGHT_CH2_INVERSE 0 - #define LIGHT_CH3_INVERSE 0 - #elif defined(MAGICHOME_LED_CONTROLLER) // Info @@ -1226,6 +1197,27 @@ #define IR_RX_PIN 4 #define IR_BUTTON_SET 1 +#elif defined(MAGICHOME_LED_CONTROLLER_RGB) + // Info + #define MANUFACTURER "MAGICHOME" + #define DEVICE "LED_CONTROLLER_RGB" + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER + #define DUMMY_RELAY_COUNT 1 + + // LEDs + #define LED1_PIN 2 + #define LED1_PIN_INVERSE 1 + + // Light + #define LIGHT_CHANNELS 3 + #define LIGHT_CH1_PIN 5 // RED + #define LIGHT_CH2_PIN 12 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 + #elif defined(MAGICHOME_LED_CONTROLLER_20) // Info @@ -1314,7 +1306,8 @@ // RF #define RF_SUPPORT 1 - #define RF_PIN 4 + #define RFB_DIRECT 1 + #define RFB_RX_PIN 4 // ----------------------------------------------------------------------------- // HUACANXING H801 & H802 @@ -2450,10 +2443,9 @@ #endif #define DALLAS_PIN 2 - #ifndef RF_SUPPORT #define RF_SUPPORT 1 - #endif - #define RF_PIN 14 + #define RFB_DIRECT 1 + #define RFB_RX_PIN 14 #ifndef DIGITAL_SUPPORT #define DIGITAL_SUPPORT 1 @@ -3305,9 +3297,9 @@ // Relays #define RELAY1_PIN 15 - #define RELAY1_TYPE RELAY_TYPE_NORMAL - - // Light RGBW + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // Light RGBW #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 @@ -3320,8 +3312,8 @@ #define LIGHT_CH1_INVERSE 0 #define LIGHT_CH2_INVERSE 0 #define LIGHT_CH3_INVERSE 0 - #define LIGHT_CH4_INVERSE 0 - + #define LIGHT_CH4_INVERSE 0 + // ---------------------------------------------------------------------------------------- // Smart life Mini Smart Socket is similar Homecube 16A but some GPIOs differ // https://www.ebay.de/itm/Smart-Steckdose-WIFI-WLAN-Amazon-Alexa-Fernbedienung-Home-Socket-Zeitschaltuh-DE/123352026749?hash=item1cb85a8e7d:g:IasAAOSwk6dbj390 @@ -3529,7 +3521,7 @@ #define LED1_PIN 4 // 4 blue led #define LED1_MODE LED_MODE_WIFI #define LED1_PIN_INVERSE 1 - + #define LED2_PIN 5 // 5 red led #define LED2_MODE LED_MODE_RELAY #define LED2_PIN_INVERSE 1 @@ -3694,7 +3686,11 @@ #define NOFUSS_SUPPORT 1 #define UART_MQTT_SUPPORT 1 #define INFLUXDB_SUPPORT 1 - #define IR_SUPPORT 1 + #define IR_SUPPORT 1 + #define RF_SUPPORT 1 + + #define RFB_DIRECT 1 + #define RFB_RX_PIN 4 #elif defined(TRAVIS03) From 2ca46c04cbb33025d95f31c32b866a63c3e744aa Mon Sep 17 00:00:00 2001 From: Sam Quinn Date: Mon, 20 May 2019 10:24:22 -0700 Subject: [PATCH 4/4] Noticed a typo in platformio where there was an underscore instead of a dash. Also fixed one whitespace issue --- code/espurna/config/hardware.h | 1 + code/platformio.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index a1e6de34eb..9ad15912af 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -1168,6 +1168,7 @@ // ----------------------------------------------------------------------------- // LED Controller // ----------------------------------------------------------------------------- + #elif defined(MAGICHOME_LED_CONTROLLER) // Info diff --git a/code/platformio.ini b/code/platformio.ini index 8d3d571ab2..e6d01d4fb6 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1317,7 +1317,7 @@ upload_flags = ${common.upload_flags} monitor_speed = ${common.monitor_speed} extra_scripts = ${common.extra_scripts} -[env:magichome-led-controller_rgb] +[env:magichome-led-controller-rgb] platform = ${common.platform} framework = ${common.framework} board = ${common.board_1m}