diff --git a/platformio.ini b/platformio.ini index 16d54e3c..e20bb469 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,9 @@ lib_extra_dirs = ./wled00/src ; env_default = esp01_1m ; env_default = d1_mini ; env_default = esp32dev - +; env_default = esp8285_4CH_MagicHome +; env_default = esp8285_4CH_H801 +; env_default = esp8285_5CH_H801 [common] framework = arduino @@ -57,8 +59,10 @@ arduino_core_2_4_1 = espressif8266@1.7.3 arduino_core_2_4_2 = espressif8266@1.8.0 arduino_core_2_5_0 = espressif8266@2.0.4 arduino_core_2_5_2 = espressif8266@2.2.3 +arduino_core_2_6_1 = espressif8266@2.3.0 +arduino_core_2_6_2 = espressif8266@2.3.1 arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage -platform = ${common:esp8266.arduino_core_2_5_2} +platform = ${common:esp8266.arduino_core_2_6_2} build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs @@ -74,7 +78,7 @@ build_flags = -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE ; -D WLED_DISABLE_HUESYNC - -D WLED_DISABLE_INFRARED + ; -D WLED_DISABLE_INFRARED [common:esp8266_512k] platform = espressif8266@1.8.0 @@ -144,6 +148,7 @@ framework = ${common.framework} build_flags = ${common.build_flags} ${common:esp8266_512k.build_flags} + -D WLED_DISABLE_INFRARED lib_deps = ${common.lib_deps_external} @@ -160,4 +165,50 @@ build_flags = lib_deps = ${common.lib_deps_external} lib_ignore = - IRremoteESP8266 \ No newline at end of file + IRremoteESP8266 + + +[env:esp8285_4CH_MagicHome] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_ENABLE_ANALOG_LEDS +lib_deps = + ${common.lib_deps_external} + +[env:esp8285_4CH_H801] +board = esp8285 +platform = ${common:esp8266.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_ENABLE_ANALOG_LEDS + -D WLED_USE_H801 +lib_deps = + ${common.lib_deps_external} + +[env:esp8285_5CH_H801] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_ENABLE_ANALOG_LEDS + -D WLED_USE_H801 + -D WLED_ENABLE_5CH_LEDS +lib_deps = + ${common.lib_deps_external} \ No newline at end of file diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 7adc73f2..0f1c510d 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -5,9 +5,14 @@ //PIN CONFIGURATION #define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) //#define USE_APA102 // Uncomment for using APA102 LEDs. -#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) -#define IR_PIN 4 //infrared pin (-1 to disable) -#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,... +#ifdef WLED_USE_H801 + #define BTNPIN -1 //button pin. Needs to have pullup (gpio0 recommended) + #define IR_PIN 0 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#else + #define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) + #define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#endif +#define RLYPIN -1 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,... #define AUXPIN -1 //debug auxiliary output pin (-1 to disable) #define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on @@ -20,12 +25,21 @@ #endif #endif -#ifndef WLED_DISABLE_ANALOG_LEDS +#ifdef WLED_USE_ANALOG_LEDS + //PWM pins - PINs 15,13,12,14 (W2 = 04)are used with H801 Wifi LED Controller + #ifdef WLED_USE_H801 + #define RPIN 15 //R pin for analog LED strip + #define GPIN 13 //G pin for analog LED strip + #define BPIN 12 //B pin for analog LED strip + #define WPIN 14 //W pin for analog LED strip (W1: 14, W2: 04) + #define W2PIN 04 //W2 pin for analog LED strip + #else //PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller - #define RPIN 5 //R pin for analog LED strip - #define GPIN 12 //G pin for analog LED strip - #define BPIN 13 //B pin for analog LED strip - #define WPIN 15 //W pin for analog LED strip + #define RPIN 5 //R pin for analog LED strip + #define GPIN 12 //G pin for analog LED strip + #define BPIN 15 //B pin for analog LED strip + #define WPIN 13 //W pin for analog LED strip (W1: 14, W2: 04) + #endif #endif //automatically uses the right driver method for each platform @@ -112,14 +126,18 @@ public: _pGrbw->Begin(); break; - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS //init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller pinMode(RPIN, OUTPUT); pinMode(GPIN, OUTPUT); pinMode(BPIN, OUTPUT); switch (_type) { - case NeoPixelType_Grb: break; - case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + case NeoPixelType_Grb: break; + #ifdef WLED_USE_5CH_LEDS + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); pinMode(W2PIN, OUTPUT); break; + #else + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + #endif } analogWriteRange(255); //same range as one RGB channel analogWriteFreq(880); //PWM frequency proven as good for LEDs @@ -128,15 +146,19 @@ public: } } -#ifndef WLED_DISABLE_ANALOG_LEDS - void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w) +#ifdef WLED_USE_ANALOG_LEDS + void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w, uint8_t w2=0) { analogWrite(RPIN, r); analogWrite(GPIN, g); analogWrite(BPIN, b); switch (_type) { - case NeoPixelType_Grb: break; - case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + case NeoPixelType_Grb: break; + #ifdef WLED_USE_5CH_LEDS + case NeoPixelType_Grbw: analogWrite(WPIN, w); analogWrite(W2PIN, w2); break; + #else + case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + #endif } } #endif @@ -148,7 +170,7 @@ public: { case NeoPixelType_Grb: { _pGrb->Show(); - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS RgbColor color = _pGrb->GetPixelColor(0); b = _pGrb->GetBrightness(); SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0); @@ -157,10 +179,27 @@ public: break; case NeoPixelType_Grbw: { _pGrbw->Show(); - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS RgbwColor colorW = _pGrbw->GetPixelColor(0); b = _pGrbw->GetBrightness(); - SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + // check color values for Warm / COld white mix (for RGBW) // EsplanexaDevice.cpp + #ifdef WLED_USE_5CH_LEDS + if (colorW.R == 255 & colorW.G == 255 && colorW.B == 255 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, 0, colorW.W * b / 255); + } else if (colorW.R == 127 & colorW.G == 127 && colorW.B == 127 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 512, colorW.W * b / 255); + } else if (colorW.R == 0 & colorW.G == 0 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, 0); + } else if (colorW.R == 130 & colorW.G == 90 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, colorW.W * b / 512); + } else if (colorW.R == 255 & colorW.G == 153 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, 0); + } else { // not only white colors + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + } + #else + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + #endif #endif } break; diff --git a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp index 43ad6f02..e8cff164 100644 --- a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp +++ b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp @@ -110,8 +110,8 @@ uint32_t EspalexaDevice::getKelvin() uint32_t EspalexaDevice::getRGB() { if (_rgb != 0) return _rgb; //color has not changed - uint8_t rgb[3]; - float r, g, b; + byte rgb[4]{0, 0, 0, 0}; + float r, g, b, w; if (_mode == EspalexaColorMode::none) return 0; @@ -122,6 +122,15 @@ uint32_t EspalexaDevice::getRGB() float temp = 10000/ _ct; //kelvins = 1,000,000/mired (and that /100) float r, g, b; +// Cold white to warm white receiving from Alexa: _ct = 199, 234, 284, 350, 383 (from cold white to warm white) + switch (_ct) { + case 199: rgb[0]=255,rgb[1]=255,rgb[2]=255;rgb[3]=255;break; + case 234: rgb[0]=127,rgb[1]=127,rgb[2]=127;rgb[3]=255;break; + case 284: rgb[0]=0,rgb[1]=0,rgb[2]=0;rgb[3]=255;break; + case 350: rgb[0]=130,rgb[1]=90,rgb[2]=0;rgb[3]=255;break; + case 383: rgb[0]=255,rgb[1]=153,rgb[2]=0;rgb[3]=255;break; + default: { + if( temp <= 66 ){ r = 255; g = temp; @@ -143,6 +152,8 @@ uint32_t EspalexaDevice::getRGB() rgb[0] = (byte)constrain(r,0.1,255.1); rgb[1] = (byte)constrain(g,0.1,255.1); rgb[2] = (byte)constrain(b,0.1,255.1); + + } } else if (_mode == EspalexaColorMode::hs) { float h = ((float)_hue)/65535.0; @@ -216,7 +227,7 @@ uint32_t EspalexaDevice::getRGB() rgb[1] = 255.0*g; rgb[2] = 255.0*b; } - _rgb = ((rgb[0] << 16) | (rgb[1] << 8) | (rgb[2])); + _rgb = ((rgb[3] << 24) | (rgb[0] << 16) | (rgb[1] << 8) | (rgb[2])); //white value is only >0 if Alexa did provide a CT value, RGB colors will not be touched. return _rgb; } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 1f3bcd26..de60f202 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -33,7 +33,10 @@ //#define WLED_DEBUG //to toggle using analog RGB or RGBW led strips (un)comment the following line -//#define WLED_DISABLE_ANALOG_LEDS +//#define WLED_USE_ANALOG_LEDS + +//to toggle using 5CH analog RGBWS led strips (un)comment the following line +//#define WLED_USE_5CH_LEDS //library inclusions #include @@ -89,6 +92,7 @@ #endif #ifdef ARDUINO_ARCH_ESP32 + #undef WLED_USE_ANALOG_LEDS // Solid RGBW not implemented for ESP32 yet /*#ifndef WLED_DISABLE_INFRARED #include #endif*/ //there are issues with ESP32 infrared, so it is disabled for now diff --git a/wled00/wled12_alexa.ino b/wled00/wled12_alexa.ino index b858d238..c3bc01ab 100644 --- a/wled00/wled12_alexa.ino +++ b/wled00/wled12_alexa.ino @@ -62,10 +62,11 @@ void onAlexaChange(EspalexaDevice* dev) } else //color { uint32_t color = espalexaDevice->getRGB(); + col[3] = ((color >> 24) & 0xFF); // white color from Alexa is "pure white only" col[0] = ((color >> 16) & 0xFF); col[1] = ((color >> 8) & 0xFF); col[2] = (color & 0xFF); - if (useRGBW) colorRGBtoRGBW(col); + if (useRGBW && col[3] == 0) colorRGBtoRGBW(col); // do not touch white value if EspalexaDevice.cpp did set the white channel colorUpdated(10); } } diff --git a/wled00/wled14_colors.ino b/wled00/wled14_colors.ino index de57be9e..9bedafb4 100644 --- a/wled00/wled14_colors.ino +++ b/wled00/wled14_colors.ino @@ -158,6 +158,6 @@ void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw) float low = minf(rgb[0],minf(rgb[1],rgb[2])); float high = maxf(rgb[0],maxf(rgb[1],rgb[2])); if (high < 0.1f) return; - float sat = 255.0f * ((high - low) / high); + float sat = 100.0f * ((high - low) / high);; // maximum saturation is 100 (corrected from 255) rgb[3] = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3); }