Update to Espalexa v2.4.4

This commit is contained in:
cschwinne 2020-01-07 01:02:52 +01:00
parent ed560a338e
commit 558811e4f9
4 changed files with 36 additions and 31 deletions

View File

@ -10,7 +10,7 @@
*/
/*
* @title Espalexa library
* @version 2.4.3
* @version 2.4.4
* @author Christian Schwinne
* @license MIT
* @contributors d-999
@ -49,7 +49,7 @@
#include <WiFiUdp.h>
#ifdef ESPALEXA_DEBUG
#pragma message "Espalexa 2.4.3 debug mode"
#pragma message "Espalexa 2.4.4 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.3\"}";
json += "\",\"swversion\":\"espalexa-2.4.4\"}";
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.3 by Christian Schwinne 2019";
res += "\r\n\r\nEspalexa library v2.4.4 by Christian Schwinne 2020";
server->send(200, "text/plain", res);
}
#endif
@ -298,7 +298,7 @@ private:
"SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/1.17.0\r\n" // _modelName, _modelNumber
"hue-bridgeid: "+ escapedMac +"\r\n"
"ST: urn:schemas-upnp-org:device:basic:1\r\n" // _deviceType
"USN: uuid:2f402f80-da50-11e1-9b23-"+ escapedMac +"::upnp:rootdevice\r\n" // _uuid::_deviceType
"USN: uuid:2f402f80-da50-11e1-9b23-"+ escapedMac +"::ssdp:all\r\n" // _uuid::_deviceType
"\r\n";
espalexaUdp.beginPacket(espalexaUdp.remoteIP(), espalexaUdp.remotePort());
@ -372,7 +372,7 @@ public:
String request = packetBuffer;
if(request.indexOf("M-SEARCH") >= 0) {
EA_DEBUGLN(request);
if(request.indexOf("upnp:rootdevice") > 0 || request.indexOf("asic:1") > 0) {
if(request.indexOf("upnp:rootdevice") > 0 || request.indexOf("asic:1") > 0 || request.indexOf("ssdp:all") > 0) {
EA_DEBUGLN("Responding search req...");
respondToSearch();
}
@ -584,4 +584,4 @@ public:
~Espalexa(){delete devices;} //note: Espalexa is NOT meant to be destructed
};
#endif
#endif

View File

@ -130,30 +130,28 @@ uint32_t EspalexaDevice::getRGB()
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;
g = 99.470802 * log(g) - 161.119568;
if( temp <= 19){
b = 0;
} else {
b = temp-10;
b = 138.517731 * log(b) - 305.044793;
}
} else {
r = temp - 60;
r = 329.698727 * pow(r, -0.13320476);
g = temp - 60;
g = 288.12217 * pow(g, -0.07551485 );
b = 255;
}
if( temp <= 66 ){
r = 255;
g = temp;
g = 99.470802 * log(g) - 161.119568;
if( temp <= 19){
b = 0;
} else {
b = temp-10;
b = 138.517731 * log(b) - 305.044793;
}
} else {
r = temp - 60;
r = 329.698727 * pow(r, -0.13320476);
g = temp - 60;
g = 288.12217 * pow(g, -0.07551485 );
b = 255;
}
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);
}
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)
{
@ -232,6 +230,12 @@ uint32_t EspalexaDevice::getRGB()
return _rgb;
}
//white channel for RGBW lights. Always 0 unless colormode is ct
uint8_t EspalexaDevice::getW()
{
return (getRGB() >> 24) & 0xFF;
}
uint8_t EspalexaDevice::getR()
{
return (getRGB() >> 16) & 0xFF;

View File

@ -51,6 +51,7 @@ public:
uint8_t getR();
uint8_t getG();
uint8_t getB();
uint8_t getW();
EspalexaColorMode getColorMode();
EspalexaDeviceType getType();

View File

@ -98,7 +98,7 @@
//version code in format yymmddb (b = daily build)
#define VERSION 2001052
#define VERSION 2001071
char versionString[] = "0.9.0-b2";