Add more web page sliders

Add web page sliders when ``SetOption37 128`` is active allowing control of white(s)
This commit is contained in:
Theo Arends 2020-01-16 14:22:39 +01:00
parent aa170fefd4
commit a6e95211cc
5 changed files with 43 additions and 13 deletions

View File

@ -78,3 +78,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add experimental support for NRF24L01 as BLE-bridge for Mijia Bluetooth sensors by Christian Baars (#7394)
- Add support to BMP driver to enter reset state (sleep enable) when deep sleep is used in Tasmota
- Add support for gzipped binaries
- Add web page sliders when ``SetOption37 128`` is active allowing control of white(s)

View File

@ -2,7 +2,7 @@
### 8.1.0.4 20200116
- Bump version
- Add web page sliders when ``SetOption37 128`` is active allowing control of white(s)
### 8.1.0.3 20200106

View File

@ -141,8 +141,8 @@ void ExecuteCommand(const char *cmnd, uint32_t source)
/********************************************************************************************/
// topicBuf: /power1 dataBuf: toggle = Console command
// topicBuf: cmnd/tasmota/power1 dataBuf: toggle = Mqtt command using topic
// topicBuf: cmnd/tasmotas/power1 dataBuf: toggle = Mqtt command using a group topic
// topicBuf: cmnd/tasmota/power1 dataBuf: toggle = Mqtt command using topic
// topicBuf: cmnd/tasmotas/power1 dataBuf: toggle = Mqtt command using a group topic
// topicBuf: cmnd/DVES_83BB10_fb/power1 dataBuf: toggle = Mqtt command using fallback topic
void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)

View File

@ -984,6 +984,17 @@ void HandleWifiLogin(void)
WSContentStop();
}
void WebSliderColdWarm(void)
{
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Cold Warm
"a", // a - Unique HTML id
"#fff", "#ff0", // White to Yellow
1, // sl1
153, 500, // Range color temperature
LightGetColorTemp(),
't', 0); // t0 - Value id releated to lc("t0", value) and WebGetArg("t0", tmp, sizeof(tmp));
}
void HandleRoot(void)
{
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page.
@ -1033,17 +1044,13 @@ void HandleRoot(void)
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
if ((LST_COLDWARM == light_subtype) || (LST_RGBCW == light_subtype)) {
bool split_white = ((LST_RGBW <= light_subtype) && (devices_present > 1)); // Only on RGBW or RGBCW and SetOption37 128
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Cold Warm
"a", // a - Unique HTML id
"#fff", "#ff0", // White to Yellow
1, // sl1
153, 500, // Range color temperature
LightGetColorTemp(),
't', 0); // t0 - Value id releated to lc("t0", value) and WebGetArg("t0", tmp, sizeof(tmp));
if ((LST_COLDWARM == light_subtype) || ((LST_RGBCW == light_subtype) && !split_white)) {
WebSliderColdWarm();
}
if (light_subtype > 2) {
if (light_subtype > 2) { // No W or CW
uint16_t hue;
uint8_t sat;
LightGetHSB(&hue, &sat, nullptr);
@ -1079,6 +1086,19 @@ void HandleRoot(void)
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100%
Settings.light_dimmer,
'd', 0); // d0 - Value id is related to lc("d0", value) and WebGetArg("d0", tmp, sizeof(tmp));
if (split_white) { // SetOption37 128
if (LST_RGBCW == light_subtype) {
WebSliderColdWarm();
}
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // White brightness - Black to White
"f", // f - Unique HTML id
"#000", "#fff", // Black to White
5, // sl5 - Unique range HTML id - Not used
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100%
LightGetDimmer(2),
'w', 0); // w0 - Value id is related to lc("w0", value) and WebGetArg("w0", tmp, sizeof(tmp));
}
} else { // Settings.flag3.pwm_multi_channels - SetOption68 1 - Enable multi-channels PWM instead of Color PWM
uint32_t pwm_channels = light_subtype > LST_MAX ? LST_MAX : light_subtype;
stemp[0] = 'e'; stemp[1] = '0'; stemp[2] = '\0'; // d0
@ -1229,6 +1249,11 @@ bool HandleRootStatusRefresh(void)
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_DIMMER " %s"), tmp);
ExecuteWebCommand(svalue, SRC_WEBGUI);
}
WebGetArg("w0", tmp, sizeof(tmp)); // 0 - 100 White value
if (strlen(tmp)) {
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_WHITE " %s"), tmp);
ExecuteWebCommand(svalue, SRC_WEBGUI);
}
uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7);
for (uint32_t j = 1; j <= pwm_channels; j++) {
snprintf_P(webindex, sizeof(webindex), PSTR("e%d"), j);

View File

@ -1336,11 +1336,15 @@ void LightUpdateColorMapping(void)
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("%d colors: %d %d %d %d %d") ,Settings.param[P_RGB_REMAP], Light.color_remap[0],Light.color_remap[1],Light.color_remap[2],Light.color_remap[3],Light.color_remap[4]);
}
uint8_t LightGetDimmer(uint8_t dimmer) {
return light_state.getDimmer(dimmer);
}
void LightSetDimmer(uint8_t dimmer) {
light_controller.changeDimmer(dimmer);
}
uint32_t LightGetHSB(uint16_t *hue,uint8_t *sat, uint8_t *bri) {
void LightGetHSB(uint16_t *hue, uint8_t *sat, uint8_t *bri) {
light_state.getHSB(hue, sat, bri);
}