mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +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 *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
if (item) thermoSetCurTemp(item->valuestring, temp);
|
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) {
|
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
||||||
char addrstr[MQTT_TOPIC_LENGTH] = "";
|
char addrstr[MQTT_TOPIC_LENGTH] = "";
|
||||||
#ifdef WITH_DOMOTICZ
|
#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) {
|
switch (itemType) {
|
||||||
|
|
||||||
#ifdef _dmxout
|
#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));
|
DmxWrite(iaddr, map(Par[0], 0, 100, 0, 255));
|
||||||
break;
|
break;
|
||||||
case CH_RGBW: //Colour RGBW
|
case CH_RGBW: //Colour RGBW
|
||||||
|
// Saturation 0 - Only white
|
||||||
|
// 0..50 - white + RGB
|
||||||
|
//50..100 RGB
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
DmxWrite(iaddr + 3, k = map((100 - Par[1]) * Par[2], 0, 10000, 0, 255));
|
if (Par[2]<50) { // Using white
|
||||||
debugSerial<<F("W:")<<k<<endl;
|
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
|
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, rgb.r);
|
||||||
DmxWrite(iaddr + 1, rgb.g);
|
DmxWrite(iaddr + 1, rgb.g);
|
||||||
DmxWrite(iaddr + 2, rgb.b);
|
DmxWrite(iaddr + 2, rgb.b);
|
||||||
|
|||||||
@@ -920,7 +920,7 @@ int loadConfigFromEEPROM()
|
|||||||
root = aJson.parse(&as);
|
root = aJson.parse(&as);
|
||||||
if (!root) {
|
if (!root) {
|
||||||
debugSerial<<F("\nload failed\n");
|
debugSerial<<F("\nload failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
debugSerial<<F("\nLoaded\n");
|
debugSerial<<F("\nLoaded\n");
|
||||||
applyConfig();
|
applyConfig();
|
||||||
@@ -960,7 +960,7 @@ int mqttConfigResp(char *as) {
|
|||||||
root = aJson.parse(as);
|
root = aJson.parse(as);
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
debugSerial<<F("\nload failed");
|
debugSerial<<F("\nload failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
debugSerial<<F("\nLoaded");
|
debugSerial<<F("\nLoaded");
|
||||||
|
|||||||
Reference in New Issue
Block a user