mirror of https://github.com/arendst/Tasmota.git
Reduce minimal by 1k
This commit is contained in:
parent
a97aeeedb7
commit
fd7554d96e
|
@ -273,6 +273,7 @@ const char HTTP_MSG_SLIDER_GRADIENT[] PROGMEM =
|
||||||
"</div>"
|
"</div>"
|
||||||
"</td>";
|
"</td>";
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/4057236/how-to-add-onload-event-to-a-div-element
|
||||||
const char HTTP_MSG_EXEC_JAVASCRIPT[] PROGMEM =
|
const char HTTP_MSG_EXEC_JAVASCRIPT[] PROGMEM =
|
||||||
"<img style='display:none;' src onerror=\"";
|
"<img style='display:none;' src onerror=\"";
|
||||||
|
|
||||||
|
@ -418,10 +419,7 @@ const char HTTP_END[] PROGMEM =
|
||||||
"</body>"
|
"</body>"
|
||||||
"</html>";
|
"</html>";
|
||||||
|
|
||||||
//const char HTTP_DEVICE_CONTROL[] PROGMEM = "<td style='width:%d%%'><button onclick='la(\"&o=%d\");'>%s%s</button></td>"; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp))
|
|
||||||
//const char HTTP_DEVICE_CONTROL[] PROGMEM = "<td style='width:%d%%'><button id='o%d' style='background:#%06x;' onclick='la(\"&o=%d\");'>%s%s</button></td>"; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp))
|
|
||||||
const char HTTP_DEVICE_CONTROL[] PROGMEM = "<td style='width:%d%%'><button id='o%d' onclick='la(\"&o=%d\");'>%s%s</button></td>"; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp))
|
const char HTTP_DEVICE_CONTROL[] PROGMEM = "<td style='width:%d%%'><button id='o%d' onclick='la(\"&o=%d\");'>%s%s</button></td>"; // ?o is related to WebGetArg(PSTR("o"), tmp, sizeof(tmp))
|
||||||
|
|
||||||
const char HTTP_DEVICE_STATE[] PROGMEM = "<td style='width:%d%%;text-align:center;font-weight:%s;font-size:%dpx'>%s</td>";
|
const char HTTP_DEVICE_STATE[] PROGMEM = "<td style='width:%d%%;text-align:center;font-weight:%s;font-size:%dpx'>%s</td>";
|
||||||
|
|
||||||
enum ButtonTitle {
|
enum ButtonTitle {
|
||||||
|
@ -467,9 +465,9 @@ ESP8266WebServer *Webserver;
|
||||||
struct WEB {
|
struct WEB {
|
||||||
String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE
|
String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE
|
||||||
uint32_t upload_size = 0;
|
uint32_t upload_size = 0;
|
||||||
|
uint32_t slider_update_time = 0;
|
||||||
int slider[LST_MAX];
|
int slider[LST_MAX];
|
||||||
uint16_t upload_error = 0;
|
uint16_t upload_error = 0;
|
||||||
uint8_t slider_update[LST_MAX];
|
|
||||||
uint8_t state = HTTP_OFF;
|
uint8_t state = HTTP_OFF;
|
||||||
uint8_t upload_file_type;
|
uint8_t upload_file_type;
|
||||||
uint8_t config_block_count = 0;
|
uint8_t config_block_count = 0;
|
||||||
|
@ -608,7 +606,6 @@ void StartWebserver(int type)
|
||||||
|
|
||||||
for (uint32_t i = 0; i < LST_MAX; i++) {
|
for (uint32_t i = 0; i < LST_MAX; i++) {
|
||||||
Web.slider[i] = -1;
|
Web.slider[i] = -1;
|
||||||
Web.slider_update[i] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Webserver) {
|
if (!Webserver) {
|
||||||
|
@ -1234,8 +1231,11 @@ void HandleRoot(void) {
|
||||||
#endif
|
#endif
|
||||||
WSContentSend_P(HTTP_SCRIPT_ROOT_PART2);
|
WSContentSend_P(HTTP_SCRIPT_ROOT_PART2);
|
||||||
WSContentSendStyle();
|
WSContentSendStyle();
|
||||||
|
|
||||||
WSContentSend_P(PSTR("<div style='padding:0;' id='l1' name='l1'></div>"));
|
WSContentSend_P(PSTR("<div style='padding:0;' id='l1' name='l1'></div>"));
|
||||||
|
|
||||||
|
#ifndef FIRMWARE_MINIMAL
|
||||||
|
|
||||||
if (TasmotaGlobal.devices_present) {
|
if (TasmotaGlobal.devices_present) {
|
||||||
uint32_t buttons_non_light = TasmotaGlobal.devices_present;
|
uint32_t buttons_non_light = TasmotaGlobal.devices_present;
|
||||||
uint32_t button_idx = 1;
|
uint32_t button_idx = 1;
|
||||||
|
@ -1252,8 +1252,7 @@ void HandleRoot(void) {
|
||||||
|
|
||||||
#ifdef USE_SHUTTER
|
#ifdef USE_SHUTTER
|
||||||
// Chk for reduced toggle buttons used by shutters
|
// Chk for reduced toggle buttons used by shutters
|
||||||
uint32_t shutter_button = 0; // Bitmask for each button
|
uint32_t shutter_button = 0; // Bitmask for each button
|
||||||
|
|
||||||
// Find and skip dedicated shutter buttons
|
// Find and skip dedicated shutter buttons
|
||||||
if (buttons_non_light && Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support
|
if (buttons_non_light && Settings->flag3.shutter_mode) { // SetOption80 - Enable shutter support
|
||||||
for (button_idx = 1; button_idx <= buttons_non_light; button_idx++) {
|
for (button_idx = 1; button_idx <= buttons_non_light; button_idx++) {
|
||||||
|
@ -1265,9 +1264,9 @@ void HandleRoot(void) {
|
||||||
}
|
}
|
||||||
#endif // USE_SHUTTER
|
#endif // USE_SHUTTER
|
||||||
|
|
||||||
if (buttons_non_light_non_shutter) { // Any non light AND non shutter button
|
if (buttons_non_light_non_shutter) { // Any non light AND non shutter button
|
||||||
// Display toggle buttons
|
// Display toggle buttons
|
||||||
WSContentSend_P(HTTP_TABLE100); // "<table style='width:100%%'>"
|
WSContentSend_P(HTTP_TABLE100); // "<table style='width:100%%'>"
|
||||||
WSContentSend_P(PSTR("<tr>"));
|
WSContentSend_P(PSTR("<tr>"));
|
||||||
|
|
||||||
#ifdef USE_SONOFF_IFAN
|
#ifdef USE_SONOFF_IFAN
|
||||||
|
@ -1517,7 +1516,6 @@ void HandleRoot(void) {
|
||||||
}
|
}
|
||||||
WSContentSend_P(PSTR("</script>"));
|
WSContentSend_P(PSTR("</script>"));
|
||||||
|
|
||||||
#ifndef FIRMWARE_MINIMAL
|
|
||||||
XdrvXsnsCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
XdrvXsnsCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
||||||
#endif // Not FIRMWARE_MINIMAL
|
#endif // Not FIRMWARE_MINIMAL
|
||||||
|
|
||||||
|
@ -1558,6 +1556,8 @@ bool HandleRootStatusRefresh(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef FIRMWARE_MINIMAL
|
||||||
|
|
||||||
#ifdef USE_SCRIPT_WEB_DISPLAY
|
#ifdef USE_SCRIPT_WEB_DISPLAY
|
||||||
Script_Check_HTML_Setvars();
|
Script_Check_HTML_Setvars();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1727,6 +1727,7 @@ bool HandleRootStatusRefresh(void)
|
||||||
uint16_t hue;
|
uint16_t hue;
|
||||||
uint8_t sat;
|
uint8_t sat;
|
||||||
int current_value = -1;
|
int current_value = -1;
|
||||||
|
uint32_t slider_update_time = millis();
|
||||||
for (uint32_t i = 0; i < LST_MAX; i++) {
|
for (uint32_t i = 0; i < LST_MAX; i++) {
|
||||||
if (Web.slider[i] != -1) {
|
if (Web.slider[i] != -1) {
|
||||||
if (!Settings->flag3.pwm_multi_channels) { // SetOption68 0 - Enable multi-channels PWM instead of Color PWM
|
if (!Settings->flag3.pwm_multi_channels) { // SetOption68 0 - Enable multi-channels PWM instead of Color PWM
|
||||||
|
@ -1750,12 +1751,13 @@ bool HandleRootStatusRefresh(void)
|
||||||
current_value = changeUIntScale(Settings->light_color[i], 0, 255, 0, 100);
|
current_value = changeUIntScale(Settings->light_color[i], 0, 255, 0, 100);
|
||||||
}
|
}
|
||||||
if (current_value != Web.slider[i]) {
|
if (current_value != Web.slider[i]) {
|
||||||
Web.slider_update[i]++;
|
if (0 == Web.slider_update_time) {
|
||||||
if (Web.slider_update[i] > 2) { // Allow two other users screen sync
|
Web.slider_update_time = slider_update_time + Settings->web_refresh; // Allow other users to sync screen
|
||||||
Web.slider_update[i] = 0;
|
}
|
||||||
|
else if (slider_update_time > Web.slider_update_time) {
|
||||||
|
Web.slider_update_time = 1; // Allow multiple updates
|
||||||
Web.slider[i] = current_value;
|
Web.slider[i] = current_value;
|
||||||
}
|
}
|
||||||
// https://stackoverflow.com/questions/4057236/how-to-add-onload-event-to-a-div-element
|
|
||||||
if (!msg_exec_javascript) {
|
if (!msg_exec_javascript) {
|
||||||
WSContentSend_P(HTTP_MSG_EXEC_JAVASCRIPT); // "<img style='display:none;' src onerror=\""
|
WSContentSend_P(HTTP_MSG_EXEC_JAVASCRIPT); // "<img style='display:none;' src onerror=\""
|
||||||
msg_exec_javascript = true;
|
msg_exec_javascript = true;
|
||||||
|
@ -1764,6 +1766,9 @@ bool HandleRootStatusRefresh(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (1 == Web.slider_update_time) {
|
||||||
|
Web.slider_update_time = 0;
|
||||||
|
}
|
||||||
#endif // USE_LIGHT
|
#endif // USE_LIGHT
|
||||||
|
|
||||||
if (msg_exec_javascript) {
|
if (msg_exec_javascript) {
|
||||||
|
@ -1782,6 +1787,8 @@ bool HandleRootStatusRefresh(void)
|
||||||
WSContentSend_P(PSTR("\n\n")); // Prep for SSE
|
WSContentSend_P(PSTR("\n\n")); // Prep for SSE
|
||||||
WSContentEnd();
|
WSContentEnd();
|
||||||
|
|
||||||
|
#endif // not FIRMWARE_MINIMAL
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1164,14 +1164,6 @@ void ShutterSettingsSave(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShutterShow()
|
|
||||||
{
|
|
||||||
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
|
|
||||||
WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (ShutterGetOptions(i) & 1) ? D_OPEN : D_CLOSE,(ShutterGetOptions(i) & 1) ? D_CLOSE : D_OPEN, (ShutterGetOptions(i) & 1) ? (100 - ShutterRealToPercentPosition(-9999, i)) : ShutterRealToPercentPosition(-9999, i), i+1);
|
|
||||||
WSContentSeparator(3); // Don't print separator on next WSContentSeparator(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShutterStartInit(uint32_t i, int32_t direction, int32_t target_pos)
|
void ShutterStartInit(uint32_t i, int32_t direction, int32_t target_pos)
|
||||||
{
|
{
|
||||||
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: dir %d, delta1 %d, delta2 %d"),direction, (Shutter[i].open_max - Shutter[i].real_position) / Shutter[i].close_velocity, Shutter[i].real_position / Shutter[i].close_velocity);
|
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: dir %d, delta1 %d, delta2 %d"),direction, (Shutter[i].open_max - Shutter[i].real_position) / Shutter[i].close_velocity, Shutter[i].real_position / Shutter[i].close_velocity);
|
||||||
|
@ -2394,11 +2386,6 @@ bool Xdrv27(uint32_t function)
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
case FUNC_WEB_SENSOR:
|
|
||||||
// ShutterShow();
|
|
||||||
break;
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
case FUNC_ACTIVE:
|
case FUNC_ACTIVE:
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1142,13 +1142,6 @@ void ShutterToggle(bool dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShutterShow(){
|
|
||||||
for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) {
|
|
||||||
WSContentSend_P(HTTP_MSG_SLIDER_SHUTTER, (Settings->shutter_options[i] & 1) ? D_OPEN : D_CLOSE,(Settings->shutter_options[i] & 1) ? D_CLOSE : D_OPEN, (Settings->shutter_options[i] & 1) ? (100 - ShutterRealToPercentPosition(-9999, i)) : ShutterRealToPercentPosition(-9999, i), i+1);
|
|
||||||
WSContentSeparator(3); // Don't print separator on next WSContentSeparator(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Commands
|
* Commands
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -1976,11 +1969,6 @@ bool Xdrv27(uint32_t function)
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef USE_WEBSERVER
|
|
||||||
case FUNC_WEB_SENSOR:
|
|
||||||
// ShutterShow();
|
|
||||||
break;
|
|
||||||
#endif // USE_WEBSERVER
|
|
||||||
case FUNC_ACTIVE:
|
case FUNC_ACTIVE:
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -292,6 +292,7 @@ struct DALI {
|
||||||
uint32_t bit_cycles;
|
uint32_t bit_cycles;
|
||||||
uint32_t last_activity;
|
uint32_t last_activity;
|
||||||
uint32_t received_dali_data; // Data received from DALI bus
|
uint32_t received_dali_data; // Data received from DALI bus
|
||||||
|
uint32_t slider_update_time;
|
||||||
uint8_t pin_rx;
|
uint8_t pin_rx;
|
||||||
uint8_t pin_tx;
|
uint8_t pin_tx;
|
||||||
uint8_t max_short_address;
|
uint8_t max_short_address;
|
||||||
|
@ -300,7 +301,6 @@ struct DALI {
|
||||||
uint8_t last_dimmer;
|
uint8_t last_dimmer;
|
||||||
uint8_t dimmer[DALI_MAX_STORED];
|
uint8_t dimmer[DALI_MAX_STORED];
|
||||||
uint8_t web_dimmer[DALI_MAX_STORED];
|
uint8_t web_dimmer[DALI_MAX_STORED];
|
||||||
uint8_t web_update[DALI_MAX_STORED];
|
|
||||||
uint8_t target;
|
uint8_t target;
|
||||||
bool allow_light;
|
bool allow_light;
|
||||||
bool last_power;
|
bool last_power;
|
||||||
|
@ -1293,20 +1293,25 @@ void DaliShow(bool json) {
|
||||||
} else {
|
} else {
|
||||||
WSContentSend_P(PSTR("</table>")); // Terminate current {t}
|
WSContentSend_P(PSTR("</table>")); // Terminate current {t}
|
||||||
WSContentSend_P(HTTP_MSG_EXEC_JAVASCRIPT); // "<img style='display:none;' src onerror=\""
|
WSContentSend_P(HTTP_MSG_EXEC_JAVASCRIPT); // "<img style='display:none;' src onerror=\""
|
||||||
|
uint32_t slider_update_time = millis();
|
||||||
for (uint32_t i = Settings->sbflag1.dali_light; i <= Settings->mbflag2.dali_group_sliders; i++) { // DaliLight 0/1, DaliGroupSliders
|
for (uint32_t i = Settings->sbflag1.dali_light; i <= Settings->mbflag2.dali_group_sliders; i++) { // DaliLight 0/1, DaliGroupSliders
|
||||||
WSContentSend_P(PSTR("eb('k75%d').style='background:#%06x';"),
|
WSContentSend_P(PSTR("eb('k75%d').style='background:#%06x';"),
|
||||||
i, WebColor((Dali->power[i]) ? COL_BUTTON : COL_FORM));
|
i, WebColor((Dali->power[i]) ? COL_BUTTON : COL_FORM));
|
||||||
if (Dali->dimmer[i] != Dali->web_dimmer[i]) {
|
if (Dali->dimmer[i] != Dali->web_dimmer[i]) {
|
||||||
Dali->web_update[i]++;
|
if (0 == Dali->slider_update_time) {
|
||||||
if (Dali->web_update[i] > 2) { // Allow two other users screen sync
|
Dali->slider_update_time = slider_update_time + Settings->web_refresh; // Allow other users to sync screen
|
||||||
Dali->web_update[i] = 0;
|
}
|
||||||
|
else if (slider_update_time > Dali->slider_update_time) {
|
||||||
|
Dali->slider_update_time = 1; // Allow multiple updates
|
||||||
Dali->web_dimmer[i] = Dali->dimmer[i];
|
Dali->web_dimmer[i] = Dali->dimmer[i];
|
||||||
}
|
}
|
||||||
WSContentSend_P(PSTR("eb('i75%d').value='%d';"),
|
WSContentSend_P(PSTR("eb('i75%d').value='%d';"),
|
||||||
i, changeUIntScale(Dali->dimmer[i], 0, 254, 0, 100));
|
i, changeUIntScale(Dali->dimmer[i], 0, 254, 0, 100));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (1 == Dali->slider_update_time) {
|
||||||
|
Dali->slider_update_time = 0;
|
||||||
|
}
|
||||||
WSContentSend_P(PSTR("\">{t}")); // Restart {t} = <table style='width:100%'>
|
WSContentSend_P(PSTR("\">{t}")); // Restart {t} = <table style='width:100%'>
|
||||||
WSContentSeparator(3); // Don't print separator on next WSContentSeparator(1)
|
WSContentSeparator(3); // Don't print separator on next WSContentSeparator(1)
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
Loading…
Reference in New Issue