Skip to content

Commit

Permalink
Custom buttons icon size
Browse files Browse the repository at this point in the history
Solves #1480
  • Loading branch information
edwardtfn committed Dec 28, 2023
1 parent ad08c45 commit 501855e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
27 changes: 26 additions & 1 deletion advanced/esphome/nspanel_esphome_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
---
substitutions:
##### DON'T CHANGE THIS #####
version: "4.2dev.2"
version: "4.2dev.3"
temp_units: "°C"
#############################

Expand Down Expand Up @@ -525,6 +525,7 @@ api:
time_color: int
meridiem: string[]
chip_font_size: int
custom_buttons_font_size: int
notification_icon: string
notification_icon_color_normal: int[]
notification_icon_color_unread: int[]
Expand Down Expand Up @@ -558,6 +559,16 @@ api:
disp1->send_command_printf("home.wifi_icon.font=%" PRIu32, chip_font_size);
id(home_chip_font_size) = chip_font_size;
// Custom buttons icon size
ESP_LOGV(TAG, "Custom buttons sizes");
id(home_custom_buttons_font_size) = custom_buttons_font_size;
for (int i = 1; i <= 7; ++i) {
disp1->send_command_printf("home.button%02d.font=%i", i, id(home_custom_buttons_font_size));
}
disp1->send_command_printf("home.bt_notific.font=%i", id(home_custom_buttons_font_size));
disp1->send_command_printf("home.bt_qrcode.font=%i", id(home_custom_buttons_font_size));
disp1->send_command_printf("home.bt_entities.font=%i", id(home_custom_buttons_font_size));
// Notification button
ESP_LOGV(TAG, "Set Notification button");
disp1->send_command_printf("is_notification=%i", (notification_text->state.empty() and notification_label->state.empty()) ? 0 : 1);
Expand Down Expand Up @@ -851,6 +862,12 @@ globals:
restore_value: true
initial_value: '7'

#### Custom buttons ####
- id: home_custom_buttons_font_size
type: uint
restore_value: true
initial_value: '8'

##### Relay icons #####
- id: home_relay1_icon
type: std::string
Expand Down Expand Up @@ -2631,6 +2648,14 @@ script:
for (int i = 1; i <= 10; ++i) {
disp1->send_command_printf("home.icon_top_%02d.font=%i", i, id(home_chip_font_size));
}
// Custom buttons icon size
ESP_LOGV(TAG, "Adjusting custom buttons sizes");
for (int i = 1; i <= 7; ++i) {
disp1->send_command_printf("home.button%02d.font=%i", i, id(home_custom_buttons_font_size));
}
disp1->send_command_printf("home.bt_notific.font=%i", id(home_custom_buttons_font_size));
disp1->send_command_printf("home.bt_qrcode.font=%i", id(home_custom_buttons_font_size));
disp1->send_command_printf("home.bt_entities.font=%i", id(home_custom_buttons_font_size));
disp1->send_command_printf("home.wifi_icon.font=%i", id(home_chip_font_size));
ESP_LOGV(TAG, "Restoring relay's icons");
disp1->set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str());
Expand Down
21 changes: 19 additions & 2 deletions nspanel_blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ blueprint:
🎉 Roadmap can be found here: [Roadmap](https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap)


ℹ️ Version: v4.2dev.2
ℹ️ Version: v4.2dev.3

source_url: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_blueprint.yaml
domain: automation
Expand Down Expand Up @@ -624,6 +624,21 @@ blueprint:
default: ' '
selector: *placeholder-selector
##### PLACEHOLDER ######################################################################
custom_buttons_font_size:
name: Custom buttons font size
description: >
*HOME page*

*The size of the icons shown on the custom buttons*
default: '8'
selector:
select:
multiple: false
options:
- label: 24px
value: '7'
- label: 32px
value: '8'
## Page Home - Custom button 01
home_custom_button01:
name: Custom button 01 - ENTITY (Optional)
Expand Down Expand Up @@ -3913,7 +3928,7 @@ trigger_variables:

variables:
##### GENERAL #####
blueprint_version: '4.2dev.2'
blueprint_version: '4.2dev.3'
date_format_temp: !input 'date_format'
# Avoid breaking change for existing users with legacy type format
date_format: >
Expand Down Expand Up @@ -7395,6 +7410,7 @@ action:
- &variables-home_buttons
variables:
chip_font_size: !input chip_font_size
custom_buttons_font_size: !input custom_buttons_font_size
bt_notific:
icon: !input 'home_button04_icon'
color_normal: !input 'home_button04_icon_color01'
Expand Down Expand Up @@ -7442,6 +7458,7 @@ action:
}}
meridiem: '{{ dict.values(mui[language].meridiem) | list }}'
chip_font_size: '{{ chip_font_size }}'
custom_buttons_font_size: '{{ custom_buttons_font_size }}'
notification_icon: >
{{
all_icons[bt_notific.icon.split(":")[1]] | default(bt_notific.icon
Expand Down

0 comments on commit 501855e

Please sign in to comment.