Fixed Alexa whites
This commit is contained in:
parent
53f09c0630
commit
ed729c32d2
@ -2,6 +2,10 @@
|
||||
|
||||
### Development versions after 0.9.1 release
|
||||
|
||||
#### Build 2003222
|
||||
|
||||
- Fixed Alexa Whites on non-RGBW lights (bump Espalexa to 2.4.5)
|
||||
|
||||
#### Build 2003221
|
||||
|
||||
- Moved Cronixie driver from FX library to drawOverlay handler
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
/*
|
||||
* @title Espalexa library
|
||||
* @version 2.4.4
|
||||
* @version 2.4.5
|
||||
* @author Christian Schwinne
|
||||
* @license MIT
|
||||
* @contributors d-999
|
||||
@ -49,7 +49,7 @@
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
#ifdef ESPALEXA_DEBUG
|
||||
#pragma message "Espalexa 2.4.4 debug mode"
|
||||
#pragma message "Espalexa 2.4.5 debug mode"
|
||||
#define EA_DEBUG(x) Serial.print (x)
|
||||
#define EA_DEBUGLN(x) Serial.println (x)
|
||||
#else
|
||||
@ -164,7 +164,7 @@ private:
|
||||
json += "\",\"modelid\":\"" + modelidString(dev->getType());
|
||||
json += "\",\"manufacturername\":\"Philips\",\"productname\":\"E" + String(static_cast<uint8_t>(dev->getType()));
|
||||
json += "\",\"uniqueid\":\"" + String(encodeLightId(deviceId+1));
|
||||
json += "\",\"swversion\":\"espalexa-2.4.4\"}";
|
||||
json += "\",\"swversion\":\"espalexa-2.4.5\"}";
|
||||
|
||||
return json;
|
||||
}
|
||||
@ -188,7 +188,7 @@ private:
|
||||
}
|
||||
res += "\r\nFree Heap: " + (String)ESP.getFreeHeap();
|
||||
res += "\r\nUptime: " + (String)millis();
|
||||
res += "\r\n\r\nEspalexa library v2.4.4 by Christian Schwinne 2020";
|
||||
res += "\r\n\r\nEspalexa library v2.4.5 by Christian Schwinne 2020";
|
||||
server->send(200, "text/plain", res);
|
||||
}
|
||||
#endif
|
||||
@ -370,9 +370,10 @@ public:
|
||||
if (!discoverable) return; //do not reply to M-SEARCH if not discoverable
|
||||
|
||||
String request = packetBuffer;
|
||||
if(request.indexOf("M-SEARCH") >= 0) {
|
||||
if(request.indexOf("M-SEA") >= 0) { //M-SEARCH
|
||||
EA_DEBUGLN(request);
|
||||
if(request.indexOf("upnp:rootdevice") > 0 || request.indexOf("asic:1") > 0 || request.indexOf("ssdp:all") > 0) {
|
||||
//match upnp:rootdevice, device:basic:1, ssdp:all and ssdp:discover
|
||||
if(request.indexOf("np:rootd") > 0 || request.indexOf("asic:1") > 0 || request.indexOf("dp:all") > 0 || request.indexOf("dp:dis") > 0) {
|
||||
EA_DEBUGLN("Responding search req...");
|
||||
respondToSearch();
|
||||
}
|
||||
|
@ -122,19 +122,11 @@ 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 ){
|
||||
if (temp <= 66) {
|
||||
r = 255;
|
||||
g = temp;
|
||||
g = 99.470802 * log(g) - 161.119568;
|
||||
if( temp <= 19){
|
||||
if (temp <= 19) {
|
||||
b = 0;
|
||||
} else {
|
||||
b = temp-10;
|
||||
@ -151,8 +143,7 @@ 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;
|
||||
@ -226,7 +217,7 @@ uint32_t EspalexaDevice::getRGB()
|
||||
rgb[1] = 255.0*g;
|
||||
rgb[2] = 255.0*b;
|
||||
}
|
||||
_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.
|
||||
_rgb = ((rgb[0] << 16) | (rgb[1] << 8) | (rgb[2]));
|
||||
return _rgb;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
typedef class EspalexaDevice;
|
||||
|
||||
typedef void (*BrightnessCallbackFunction) (uint8_t b);
|
||||
typedef void (*DeviceCallbackFunction) (EspalexaDevice* d);
|
||||
typedef void (*ColorCallbackFunction) (uint8_t br, uint32_t col);
|
||||
typedef std::function<void(uint8_t b)> BrightnessCallbackFunction;
|
||||
typedef std::function<void(EspalexaDevice* d)> DeviceCallbackFunction;
|
||||
typedef std::function<void(uint8_t br, uint32_t col)> ColorCallbackFunction;
|
||||
|
||||
enum class EspalexaColorMode : uint8_t { none = 0, ct = 1, hs = 2, xy = 3 };
|
||||
enum class EspalexaDeviceType : uint8_t { onoff = 0, dimmable = 1, whitespectrum = 2, color = 3, extendedcolor = 4 };
|
||||
|
@ -7,7 +7,6 @@
|
||||
* @author Christian Schwinne
|
||||
*/
|
||||
|
||||
|
||||
//ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS).
|
||||
|
||||
//ESP8266-01 (black) has 1MB flash and can thus fit the whole program. Use 1M(64K SPIFFS).
|
||||
@ -119,7 +118,7 @@
|
||||
#endif
|
||||
|
||||
//version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2003221
|
||||
#define VERSION 2003222
|
||||
|
||||
char versionString[] = "0.9.1";
|
||||
|
||||
|
@ -61,12 +61,28 @@ void onAlexaChange(EspalexaDevice* dev)
|
||||
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
|
||||
} else //color
|
||||
{
|
||||
if (espalexaDevice->getColorMode() == EspalexaColorMode::ct) //shade of white
|
||||
{
|
||||
uint16_t ct = espalexaDevice->getCt();
|
||||
if (useRGBW)
|
||||
{
|
||||
switch (ct) { //these values empirically look good on RGBW
|
||||
case 199: col[0]=255; col[1]=255; col[2]=255; col[3]=255; break;
|
||||
case 234: col[0]=127; col[1]=127; col[2]=127; col[3]=255; break;
|
||||
case 284: col[0]= 0; col[1]= 0; col[2]= 0; col[3]=255; break;
|
||||
case 350: col[0]=130; col[1]= 90; col[2]= 0; col[3]=255; break;
|
||||
case 383: col[0]=255; col[1]=153; col[2]= 0; col[3]=255; break;
|
||||
}
|
||||
} else {
|
||||
colorCTtoRGB(ct, col);
|
||||
}
|
||||
} else {
|
||||
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 && col[3] == 0) colorRGBtoRGBW(col); // do not touch white value if EspalexaDevice.cpp did set the white channel
|
||||
col[2] = ( color & 0xFF);
|
||||
}
|
||||
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +57,9 @@ void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
|
||||
case 4: rgb[0]=t,rgb[1]=p,rgb[2]=255;break;
|
||||
case 5: rgb[0]=255,rgb[1]=p,rgb[2]=q;
|
||||
}
|
||||
if (useRGBW) colorRGBtoRGBW(col);
|
||||
if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY) colorRGBtoRGBW(col);
|
||||
}
|
||||
|
||||
#ifndef WLED_DISABLE_HUESYNC
|
||||
void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb
|
||||
{
|
||||
//this is only an approximation using WS2812B with gamma correction enabled
|
||||
@ -81,9 +80,10 @@ void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb
|
||||
} else {
|
||||
rgb[0]=237;rgb[1]=255;rgb[2]=239;//150
|
||||
}
|
||||
if (useRGBW) colorRGBtoRGBW(col);
|
||||
if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY) colorRGBtoRGBW(col);
|
||||
}
|
||||
|
||||
#ifndef WLED_DISABLE_HUESYNC
|
||||
void colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
|
||||
{
|
||||
float z = 1.0f - x - y;
|
||||
|
Loading…
Reference in New Issue
Block a user