From 7b24b67606e2bd9986904e606c3e6268a704e689 Mon Sep 17 00:00:00 2001
From: Theo Arends <11044339+arendst@users.noreply.github.com>
Date: Fri, 22 Nov 2019 17:24:56 +0100
Subject: [PATCH] Refactor shutter slider
---
tasmota/xdrv_01_webserver.ino | 38 +++++++++++++++--------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index e47eede98..2377bbd0d 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -377,16 +377,16 @@ const char HTTP_HEAD_STYLE3[] PROGMEM =
#endif
"
%s
";
-const char HTTP_MSG_SLIDER_BASIC[] PROGMEM =
- "%s%s
"
- "";
-const char HTTP_MSG_SLIDER_GRAD[] PROGMEM =
+const char HTTP_MSG_SLIDER_GRADIENT[] PROGMEM =
"";
-const char HTTP_MSG_SLIDER_GRAD_2[] PROGMEM =
- "";
const char HTTP_MSG_SLIDER_HUE[] PROGMEM =
""
"
";
+const char HTTP_MSG_SLIDER_CHANNEL[] PROGMEM =
+ "";
+const char HTTP_MSG_SLIDER_SHUTTER[] PROGMEM =
+ "" D_CLOSE "" D_OPEN "
"
+ "";
const char HTTP_MSG_RSTRT[] PROGMEM =
"
" D_DEVICE_WILL_RESTART "
";
@@ -1009,11 +1009,11 @@ void HandleRoot(void)
if (devices_present) {
#ifdef USE_LIGHT
if (light_type) {
+ uint8_t light_subtype = light_type &7;
if (!Settings.flag3.pwm_multi_channels) { // SetOption68 0 - Enable multi-channels PWM instead of Color PWM
- uint8_t light_subtype = light_type &7;
if ((LST_COLDWARM == light_subtype) || (LST_RGBWC == light_subtype)) {
// Cold - Warm &t related to lb("t", value) and WebGetArg("t", tmp, sizeof(tmp));
- WSContentSend_P(HTTP_MSG_SLIDER_GRAD, "a", "#fff", "#ff0", 153, 500, LightGetColorTemp(), 't'); // White to Yellow
+ WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, "a", "#fff", "#ff0", 153, 500, LightGetColorTemp(), 't'); // White to Yellow
}
if (light_subtype > 2) {
uint16_t hue;
@@ -1022,22 +1022,17 @@ void HandleRoot(void)
LightGetHSB(&hue, &sat, &bri);
WSContentSend_P(HTTP_MSG_SLIDER_HUE, hue); // Hue
snprintf_P(stemp, sizeof(stemp), PSTR("#%02X%02X%02X"), Settings.light_color[0], Settings.light_color[1], Settings.light_color[2]);
- WSContentSend_P(HTTP_MSG_SLIDER_GRAD, "s", "grey", stemp, 1, 100, changeUIntScale(sat, 0, 255, 0, 100), 'n');
+ // Saturation "s" related to eb('s').style.backgroundImage='linear-gradient(to right,grey,hsl('+p+',100%%,50%%))';
+ WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, "s", "grey", stemp, 1, 100, changeUIntScale(sat, 0, 255, 0, 100), 'n');
}
// Dark - Bright &d related to lb("d", value) and WebGetArg("d", tmp, sizeof(tmp));
- WSContentSend_P(HTTP_MSG_SLIDER_GRAD, "b", "#000", "#fff", 1, 100, Settings.light_dimmer, 'd'); // Black to White
+ WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, "b", "#000", "#fff", 1, 100, Settings.light_dimmer, 'd'); // Black to White
} else { // Settings.flag3.pwm_multi_channels - SetOption68 1 - Enable multi-channels PWM instead of Color PWM
- uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7);
+ uint32_t pwm_channels = light_subtype > LST_MAX ? LST_MAX : light_subtype;
for (uint32_t i = 0; i < pwm_channels; i++) {
-/*
- snprintf_P(stemp, sizeof(stemp), PSTR("C%d"), i);
- WSContentSend_P(HTTP_MSG_SLIDER_BASIC, stemp, FPSTR("100%"),
- 1, 100,
- changeUIntScale(Settings.light_color[i], 0, 255, 0, 100), 'd', i+1);
-*/
- uint8_t index = i;
- if (pwm_channels < 3) { index = i +3; }
- WSContentSend_P(HTTP_MSG_SLIDER_GRAD_2, GetTextIndexed(stemp, sizeof(stemp), index, kChannelColors), changeUIntScale(Settings.light_color[i], 0, 255, 0, 100), i+1); // Black to White
+ uint8_t index = (pwm_channels < 3) ? i +3 : i;
+ WSContentSend_P(HTTP_MSG_SLIDER_CHANNEL, GetTextIndexed(stemp, sizeof(stemp), index, kChannelColors),
+ changeUIntScale(Settings.light_color[i], 0, 255, 0, 100), i+1); // Dark to Light
}
} // Settings.flag3.pwm_multi_channels
}
@@ -1045,8 +1040,7 @@ void HandleRoot(void)
#ifdef USE_SHUTTER
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (uint32_t i = 0; i < shutters_present; i++) {
- WSContentSend_P(HTTP_MSG_SLIDER_BASIC, F(D_CLOSE), F(D_OPEN),
- 0, 100, Settings.shutter_position[i], 'u', i+1);
+ WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, Settings.shutter_position[i], i+1);
}
}
#endif // USE_SHUTTER