@@ -802,6 +802,26 @@ api:
|
||||
disp1->set_component_font_color(id.c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(value_color[0],
|
||||
value_color[1],
|
||||
value_color[2])));
|
||||
if (current_page->state.find("entitypage") == 0 and !(value.empty())) { // Adjust value's font on entities pages
|
||||
// Adjusted length starts at 0
|
||||
float adjusted_length = 0.0;
|
||||
|
||||
// Iterate over each character in the string
|
||||
for (char const &c: value) {
|
||||
// Check if character is a space or other specified exceptions
|
||||
if (std::string(" iljtIf'-,;:!.\"|()[]{}").find(c) != std::string::npos) {
|
||||
adjusted_length += 0.5; // Count these as half
|
||||
} else {
|
||||
adjusted_length += 1.0; // Count all other characters as 1
|
||||
}
|
||||
}
|
||||
// Decide which font to use based on adjusted length
|
||||
if (adjusted_length > 8.0 and adjusted_length <= 12.0) {
|
||||
disp1->send_command_printf("%s.font=1", id.c_str());
|
||||
} else if (adjusted_length > 12.0) {
|
||||
disp1->send_command_printf("%s.font=0", id.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Wake Up Service
|
||||
@@ -1035,7 +1055,7 @@ globals:
|
||||
initial_value: '6'
|
||||
- id: screensaver_display_time_color
|
||||
type: uint16_t
|
||||
restore_value: false
|
||||
restore_value: true
|
||||
initial_value: '16904'
|
||||
|
||||
- id: page_entity_value_horizontal_alignment
|
||||
|
||||
Reference in New Issue
Block a user