From 7dc4eeca844ba41e826294fb2219d1fbe8774ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sat, 26 Aug 2017 21:39:17 +0200 Subject: [PATCH] Fix support for Sonoff B1 --- code/espurna/config/general.h | 6 +++--- code/espurna/config/hardware.h | 6 ++++-- code/espurna/light.ino | 12 ++++++------ code/platformio.ini | 6 +++--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index a08f0fe3..7778e863 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -16,7 +16,7 @@ // Serial debug log #ifndef DEBUG_SERIAL_SUPPORT -#define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log +#define DEBUG_SERIAL_SUPPORT 1 // Enable serial debug log #endif #ifndef DEBUG_PORT #define DEBUG_PORT Serial // Default debugging port @@ -26,10 +26,10 @@ // UDP debug log // To receive the message son the destination computer use nc: -// nc -ul 8111 +// nc -ul 8113 #ifndef DEBUG_UDP_SUPPORT -#define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log +#define DEBUG_UDP_SUPPORT 0 // Enable UDP debug log #endif #define DEBUG_UDP_IP IPAddress(192, 168, 1, 100) #define DEBUG_UDP_PORT 8113 diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 991c2795..fd6bb1b2 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -435,9 +435,10 @@ #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192 #define DUMMY_RELAY_COUNT 1 - #define MY9291_DI_PIN 13 - #define MY9291_DCKI_PIN 15 + #define MY9291_DI_PIN 12 + #define MY9291_DCKI_PIN 14 #define MY9291_COMMAND MY9291_COMMAND_DEFAULT + #define MY9291_CHANNELS 5 #elif defined(ITEAD_SONOFF_LED) @@ -606,6 +607,7 @@ #define MY9291_DI_PIN 13 #define MY9291_DCKI_PIN 15 #define MY9291_COMMAND MY9291_COMMAND_DEFAULT + #define MY9291_CHANNELS 4 // ----------------------------------------------------------------------------- // LED Controller diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 3d8db861..cf572e31 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -235,7 +235,8 @@ void _lightProviderUpdate() { unsigned int green = _toPWM(1) * ratio; unsigned int blue = _toPWM(2) * ratio; unsigned int white = _toPWM(3) * ratio; - _my9291->setColor((my9291_color_t) { red, green, blue, white }); + unsigned int warm = _toPWM(4) * ratio; + _my9291->setColor((my9291_color_t) { red, green, blue, white, warm }); _my9291->setState(true); } else { @@ -533,11 +534,10 @@ void _lightAPISetup() { void lightSetup() { #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY9192 - _my9291 = new my9291(MY9291_DI_PIN, MY9291_DCKI_PIN, MY9291_COMMAND); - _channels.push_back((channel_t) {0, false, 0}); - _channels.push_back((channel_t) {0, false, 0}); - _channels.push_back((channel_t) {0, false, 0}); - _channels.push_back((channel_t) {0, false, 0}); + _my9291 = new my9291(MY9291_DI_PIN, MY9291_DCKI_PIN, MY9291_COMMAND, MY9291_CHANNELS); + for (unsigned char i=0; i