Improvements and Bugfixes.
This commit is contained in:
+26
-13
@@ -14,7 +14,7 @@
|
||||
|
||||
union _eeprom_NotificationLEDs_StatusTable {
|
||||
struct {
|
||||
int hourOffset : 1;
|
||||
unsigned hourOffset : 1;
|
||||
} status;
|
||||
uint8_t data;
|
||||
};
|
||||
@@ -329,8 +329,12 @@ template<
|
||||
retval = true;
|
||||
} else if (msg.type == V_RGBW) {
|
||||
uint32_t color = strtoul(msg.data, NULL, 16);
|
||||
// MySensors uses "RGBW" format, but the NeoPixel library uses "WRGB" format
|
||||
setStaticColor((color & 0xFFFFFF00) >> 8 | ((color & 0xFF) << 24));
|
||||
if (color == 0) {
|
||||
enableDefaultScene();
|
||||
} else {
|
||||
// MySensors uses "RGBW" format, but the NeoPixel library uses "WRGB" format
|
||||
setStaticColor((color & 0xFFFFFF00) >> 8 | ((color & 0xFF) << 24));
|
||||
}
|
||||
retval = true;
|
||||
}
|
||||
if (retval) {
|
||||
@@ -352,21 +356,30 @@ template<
|
||||
if (msg.type == V_PERCENTAGE) {
|
||||
auto b = msg.getByte();
|
||||
if (sceneMode == 0) {
|
||||
brightness = b;
|
||||
sceneData.analogClock.lastUnixTime = 0;
|
||||
if (b == 0) {
|
||||
powerOff();
|
||||
} else {
|
||||
brightness = b;
|
||||
sceneData.analogClock.lastUnixTime = 0;
|
||||
}
|
||||
} else {
|
||||
uint16_t cb = max(staticColor.wrgb[0], max(staticColor.wrgb[1], max(staticColor.wrgb[2], staticColor.wrgb[3]))) * 100 / 255;
|
||||
uint16_t nb = msg.getByte();
|
||||
for (auto i = 0; i < 4; i++) {
|
||||
uint16_t newcolor = ((uint16_t)staticColor.wrgb[i] * nb) / cb;
|
||||
if (newcolor > 255) {
|
||||
newcolor = 255;
|
||||
if (b == 0) {
|
||||
enableDefaultScene();
|
||||
} else {
|
||||
uint16_t cb = max(staticColor.wrgb[0], max(staticColor.wrgb[1], max(staticColor.wrgb[2], staticColor.wrgb[3]))) * 100 / 255;
|
||||
for (auto i = 0; i < 4; i++) {
|
||||
uint16_t newcolor = ((uint16_t)staticColor.wrgb[i] * b) / cb;
|
||||
if (newcolor > 255) {
|
||||
newcolor = 255;
|
||||
}
|
||||
staticColor.wrgb[i] = newcolor;
|
||||
}
|
||||
staticColor.wrgb[i] = newcolor;
|
||||
setStaticColor(staticColor.color);
|
||||
}
|
||||
setStaticColor(staticColor.color);
|
||||
}
|
||||
retval = true;
|
||||
sendPowerSwitchStatus();
|
||||
sendRGBWStatus();
|
||||
sendDimmerStatus();
|
||||
}
|
||||
// Request Message
|
||||
|
||||
Reference in New Issue
Block a user