Custom decimal separator on climate page

Solves #1161
This commit is contained in:
Edward Firmo
2024-02-27 13:47:08 +01:00
parent f819c1fe33
commit 9ff59624e0
17 changed files with 516 additions and 34 deletions

View File

@@ -2518,20 +2518,27 @@ script:
- lambda: |-
if (id(is_uploading_tft)) set_climate->stop();
if (current_page->state == "climate") {
bool useDecimal = (temp_step % 10 != 0);
char buffer[15];
disp1->send_command_printf("climateslider.maxval=%i", total_steps);
disp1->send_command_printf("slider_high.maxval=%i", total_steps);
disp1->send_command_printf("slider_low.maxval=%i", total_steps);
disp1->set_component_value("temp_offset", temp_offset);
disp1->set_component_value("temp_step", temp_step);
char dec_separator_str[2] = {id(mui_decimal_separator), '\0'};
disp1->set_component_text("dec_separator", dec_separator_str);
set_component_visibility->execute("current_temp", true);
if (current_temp > -999)
disp1->set_component_text_printf("current_temp", "%.1f°", current_temp);
if (current_temp > -999) {
snprintf(buffer, sizeof(buffer), (useDecimal) ? "%.1f°" : "%.0f°", current_temp);
disp1->set_component_text("current_temp", adjustDecimalSeparator(buffer, id(mui_decimal_separator)).c_str());
}
else
disp1->set_component_text_printf("current_temp", id(mui_unavailable_global).c_str());
if (target_temp > -999) { // Target temp enabled
disp1->set_component_value("active_slider", 0);
disp1->set_component_text_printf("target_high", "%.1f°", target_temp);
snprintf(buffer, sizeof(buffer), (useDecimal) ? "%.1f°" : "%.0f°", target_temp);
disp1->set_component_text("target_high", adjustDecimalSeparator(buffer, id(mui_decimal_separator)).c_str());
disp1->set_component_value("climateslider", round(((10*target_temp) - temp_offset) / temp_step));
set_component_visibility->execute("slider_high", false);
set_component_visibility->execute("slider_low", false);
@@ -2542,7 +2549,8 @@ script:
set_component_visibility->execute("climate.slider_high", false);
if (target_temp_low > -999) { // Target temp low enabled
disp1->set_component_value("active_slider", 2);
disp1->set_component_text_printf("target_low", "%.1f°", target_temp_low);
snprintf(buffer, sizeof(buffer), (useDecimal) ? "%.1f°" : "%.0f°", target_temp_low);
disp1->set_component_text("target_low", adjustDecimalSeparator(buffer, id(mui_decimal_separator)).c_str());
disp1->set_component_value("slider_low", round(((10*target_temp_low) - temp_offset) / temp_step));
set_component_visibility->execute("target_low", true);
set_component_visibility->execute("slider_low", true);
@@ -2552,7 +2560,8 @@ script:
}
if (target_temp_high > -999) { // Target temp high enabled
disp1->set_component_value("active_slider", 1);
disp1->set_component_text_printf("target_high", "%.1f°", target_temp_high);
snprintf(buffer, sizeof(buffer), (useDecimal) ? "%.1f°" : "%.0f°", target_temp_high);
disp1->set_component_text("target_high", adjustDecimalSeparator(buffer, id(mui_decimal_separator)).c_str());
disp1->set_component_value("slider_high", round(((10*target_temp_high) - temp_offset) / temp_step));
set_component_visibility->execute("target_high", true);
set_component_visibility->execute("slider_high", true);
@@ -2562,7 +2571,7 @@ script:
}
}
if (target_temp > -999 or target_temp_high > -999 or target_temp_low > -999) {
disp1->set_component_text_printf("target_icon", "%s", climate_icon.c_str());
disp1->set_component_text("target_icon", climate_icon.c_str());
set_component_visibility->execute("target_icon", true);
set_component_visibility->execute("decrease_temp", true);
set_component_visibility->execute("increase_temp", true);
@@ -2625,7 +2634,7 @@ script:
then: # Wi-Fi connected
- lambda: |-
if (current_page->state == "boot") {
disp1->set_component_text_printf("boot.ip_addr", "%s", network::get_ip_address().str().c_str());
disp1->set_component_text("boot.ip_addr", network::get_ip_address().str().c_str());
set_brightness->execute(100);
}
- wait_until: