mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
RGB - to RGBW conversion algorithm changed
This commit is contained in:
@@ -228,7 +228,7 @@ void Input::dht22Poll() {
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||
if (item) thermoSetCurTemp(item->valuestring, temp);
|
||||
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%");
|
||||
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%")<<endl;
|
||||
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
||||
char addrstr[MQTT_TOPIC_LENGTH] = "";
|
||||
#ifdef WITH_DOMOTICZ
|
||||
|
||||
@@ -574,7 +574,9 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int subItemN)
|
||||
|
||||
|
||||
|
||||
|
||||
int whiteOffset=0;
|
||||
int rgbsLimit =100;
|
||||
int rgbvLevel =255;
|
||||
switch (itemType) {
|
||||
|
||||
#ifdef _dmxout
|
||||
@@ -582,14 +584,27 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int subItemN)
|
||||
DmxWrite(iaddr, map(Par[0], 0, 100, 0, 255));
|
||||
break;
|
||||
case CH_RGBW: //Colour RGBW
|
||||
// Saturation 0 - Only white
|
||||
// 0..50 - white + RGB
|
||||
//50..100 RGB
|
||||
{
|
||||
int k;
|
||||
DmxWrite(iaddr + 3, k = map((100 - Par[1]) * Par[2], 0, 10000, 0, 255));
|
||||
debugSerial<<F("W:")<<k<<endl;
|
||||
if (Par[2]<50) { // Using white
|
||||
DmxWrite(iaddr + 3, map((50 - Par[1]) * Par[2], 0, 5000, 0, 255));
|
||||
rgbvLevel = map (Par[1],0,50,0,255);
|
||||
rgbsLimit = Par[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
rgbsLimit=50;
|
||||
DmxWrite(iaddr + 3, 0);
|
||||
}
|
||||
//DmxWrite(iaddr + 3, k = map((100 - Par[1]) * Par[2], 0, 10000, 0, 255));
|
||||
//debugSerial<<F("W:")<<k<<endl;
|
||||
}
|
||||
case CH_RGB: // RGB
|
||||
{
|
||||
CRGB rgb = CHSV(map(Par[0], 0, 365, 0, 255), map(Par[1], 0, 100, 0, 255), map(Par[2], 0, 100, 0, 255));
|
||||
CRGB rgb = CHSV(map(Par[0], 0, 365, 0, 255), map(Par[1], 0, rgbsLimit, 0, 255), map(Par[2], 0, 100, 0, rgbvLevel));
|
||||
DmxWrite(iaddr, rgb.r);
|
||||
DmxWrite(iaddr + 1, rgb.g);
|
||||
DmxWrite(iaddr + 2, rgb.b);
|
||||
|
||||
@@ -960,7 +960,7 @@ int mqttConfigResp(char *as) {
|
||||
root = aJson.parse(as);
|
||||
|
||||
if (!root) {
|
||||
debugSerial<<F("\nload failed");
|
||||
debugSerial<<F("\nload failed\n");
|
||||
return 0;
|
||||
}
|
||||
debugSerial<<F("\nLoaded");
|
||||
|
||||
Reference in New Issue
Block a user