mirror of https://github.com/arendst/Tasmota.git
Merge pull request #7521 from dgwynne/HSColor
Make the B or brightness part of the HSBColor command optional
This commit is contained in:
commit
aa170fefd4
|
@ -2249,31 +2249,31 @@ void CmndHsbColor(void)
|
||||||
bool validHSB = (XdrvMailbox.data_len > 0);
|
bool validHSB = (XdrvMailbox.data_len > 0);
|
||||||
if (validHSB) {
|
if (validHSB) {
|
||||||
uint16_t HSB[3];
|
uint16_t HSB[3];
|
||||||
if (strstr(XdrvMailbox.data, ",") != nullptr) { // Command with 3 comma separated parameters, Hue (0<H<360), Saturation (0<S<100) AND Brightness (0<B<100)
|
uint16_t c_hue;
|
||||||
for (uint32_t i = 0; i < 3; i++) {
|
uint8_t c_sat;
|
||||||
char *substr;
|
|
||||||
|
|
||||||
if (0 == i) {
|
light_state.getHSB(&c_hue, &c_sat, nullptr);
|
||||||
substr = strtok(XdrvMailbox.data, ",");
|
HSB[0] = c_hue;
|
||||||
} else {
|
HSB[1] = c_sat;
|
||||||
substr = strtok(nullptr, ",");
|
HSB[2] = light_state.getBriRGB();
|
||||||
}
|
|
||||||
if (substr != nullptr) {
|
char *substr = strstr(XdrvMailbox.data, ",");
|
||||||
HSB[i] = atoi(substr);
|
if (substr != nullptr) { // Command with comma separated parameters, Hue (0<H<360), Saturation (0<S<100) AND optional Brightness (0<B<100)
|
||||||
if (0 < i) {
|
HSB[0] = atoi(XdrvMailbox.data);
|
||||||
HSB[i] = changeUIntScale(HSB[i], 0, 100, 0, 255); // change sat and bri to 0..255
|
|
||||||
}
|
for (uint32_t i = 1; i < 3; i++) {
|
||||||
} else {
|
substr++;
|
||||||
validHSB = false;
|
HSB[i] = atoi(substr);
|
||||||
|
HSB[i] = changeUIntScale(HSB[i], 0, 100, 0, 255); // change sat and bri to 0..255
|
||||||
|
substr = strstr(substr, ",");
|
||||||
|
if (substr == nullptr) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (substr != nullptr) {
|
||||||
|
validHSB = false;
|
||||||
|
}
|
||||||
} else { // Command with only 1 parameter, Hue (0<H<360), Saturation (0<S<100) OR Brightness (0<B<100)
|
} else { // Command with only 1 parameter, Hue (0<H<360), Saturation (0<S<100) OR Brightness (0<B<100)
|
||||||
uint16_t c_hue;
|
|
||||||
uint8_t c_sat;
|
|
||||||
light_state.getHSB(&c_hue, &c_sat, nullptr);
|
|
||||||
HSB[0] = c_hue;
|
|
||||||
HSB[1] = c_sat;
|
|
||||||
HSB[2] = light_state.getBri();
|
|
||||||
|
|
||||||
if (1 == XdrvMailbox.index) {
|
if (1 == XdrvMailbox.index) {
|
||||||
HSB[0] = XdrvMailbox.payload;
|
HSB[0] = XdrvMailbox.payload;
|
||||||
|
|
Loading…
Reference in New Issue