Skip to content

Commit

Permalink
Add button utilities to home page
Browse files Browse the repository at this point in the history
Solves #168
  • Loading branch information
edwardtfn committed Feb 29, 2024
1 parent 9a6ad74 commit f050341
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 133 deletions.
9 changes: 9 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ for the QR code button.
Icon codepoint from [HASwitchPlate Material Design Icons](https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html)
for the entities page button.
- `entities_pages_icon_color` (int[]): RGB color array for the entities page button icon.
- `utilities` (bool): Flag indicating whether the utilities page button is enabled.
- `utilities_icon` (string):
Icon codepoint from [HASwitchPlate Material Design Icons](https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html)
for the utilities page button.
- `utilities_icon_color` (int[]): RGB color array for utilities page button icon.
- `outdoor_temp_font` (int): Font Id for outdoor temperature indication on the "Home" page.

**Home Assistant Example:**
Expand All @@ -437,6 +442,10 @@ data:
qrcode_icon_color: [0, 255, 0] # Green
entities_pages_icon: "\uEDCF" # Example for mdi:format-list-bulleted-square
entities_pages_icon_color: [0, 0, 255] # Blue
utilities: true
utilities_icon: "\uE299" # Example for mdi:gauge
utilities_icon_color: [255, 255, 255] # White
outdoor_temp_font: 5
```
> [!NOTE]
Expand Down
10 changes: 10 additions & 0 deletions esphome/nspanel_esphome_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ api:
qrcode_icon_color: int[] # RGB color array for QR code button icon.
entities_pages_icon: string # Icon codepoint for entities page button, sourced from HASwitchPlate Material Design Icons.
entities_pages_icon_color: int[] # RGB color array for entities page button icon.
utilities: bool # Enable/disable flag for utilities page button display.
utilities_icon: string # Icon codepoint for utilities page button, sourced from HASwitchPlate Material Design Icons.
utilities_icon_color: int[] # RGB color array for utilities page button icon.
outdoor_temp_font: int # Font Id for outdoor temperature indication on the "Home" page.
then:
- lambda: |-
Expand Down Expand Up @@ -478,6 +481,13 @@ api:
entities_pages_icon_color[1],
entities_pages_icon_color[2])));
// Utilities button
disp1->send_command_printf("is_utilities=%i", utilities ? 1 : 0);
disp1->set_component_text_printf("home.bt_utilities", "%s", utilities_icon.c_str());
disp1->set_component_font_color("home.bt_utilities", esphome::display::ColorUtil::color_to_565(esphome::Color(utilities_icon_color[0],
utilities_icon_color[1],
utilities_icon_color[2])));
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 1));
}
Expand Down
2 changes: 1 addition & 1 deletion hmi/dev/nspanel_eu_code/Program.s.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Program.s
int back_page_id=0
int dimdelta=0
int api=0 // 0 = disconnected from HA, 1 = connected to HA
int is_qrcode=0,is_notification=0
int is_qrcode=0,is_notification=0,is_utilities=0
int brightness=100,brightness_dim=40,brightness_sleep=0
int display_mode=1 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank
int charset=1 // 1 = International (original), 2 = CJK
Expand Down
18 changes: 18 additions & 0 deletions hmi/dev/nspanel_eu_code/home.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Page home
}
vis bt_notific,is_notification
vis bt_qrcode,is_qrcode
vis bt_utilities,is_utilities
if(display_mode==3)
{
vis left_bt_text,0
Expand Down Expand Up @@ -611,6 +612,23 @@ Text unavailable
Text :
Max. Text Size : 1

Text bt_utilities
Attributes
ID : 45
Scope : global
Dragging : 0
Send Component ID : on press and release
Associated Keyboard: none
Text :
Max. Text Size : 3

Events
Touch Release Event
if(api==1)
{
page utilities
}

Picture weather
Attributes
ID : 7
Expand Down
2 changes: 1 addition & 1 deletion hmi/dev/nspanel_us_code/Program.s.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Program.s
int back_page_id=0
int dimdelta=0
int api=0 // 0 = disconnected from HA, 1 = connected to HA
int is_qrcode=0,is_notification=0
int is_qrcode=0,is_notification=0,is_utilities=0
int brightness=100,brightness_dim=40,brightness_sleep=0
int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank
int charset=1 // 1 = International (original), 2 = CJK
Expand Down
18 changes: 18 additions & 0 deletions hmi/dev/nspanel_us_code/home.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Page home
}
vis bt_notific,is_notification
vis bt_qrcode,is_qrcode
vis bt_utilities,is_utilities
if(display_mode==3)
{
vis left_bt_text,0
Expand Down Expand Up @@ -611,6 +612,23 @@ Text unavailable
Text :
Max. Text Size : 1

Text bt_utilities
Attributes
ID : 45
Scope : global
Dragging : 0
Send Component ID : on press and release
Associated Keyboard: none
Text :
Max. Text Size : 3

Events
Touch Release Event
if(api==1)
{
page utilities
}

Picture weather
Attributes
ID : 7
Expand Down
2 changes: 1 addition & 1 deletion hmi/dev/nspanel_us_land_code/Program.s.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Program.s
int back_page_id=0
int dimdelta=0
int api=0 // 0 = disconnected from HA, 1 = connected to HA
int is_qrcode=0,is_notification=0
int is_qrcode=0,is_notification=0,is_utilities=0
int brightness=100,brightness_dim=40,brightness_sleep=0
int display_mode=3 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank
int charset=1 // 1 = International (original), 2 = CJK
Expand Down
18 changes: 18 additions & 0 deletions hmi/dev/nspanel_us_land_code/home.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Page home
}
vis bt_notific,is_notification
vis bt_qrcode,is_qrcode
vis bt_utilities,is_utilities
if(display_mode==3)
{
vis left_bt_text,0
Expand Down Expand Up @@ -611,6 +612,23 @@ Text unavailable
Text :
Max. Text Size : 1

Text bt_utilities
Attributes
ID : 45
Scope : global
Dragging : 0
Send Component ID : on press and release
Associated Keyboard: none
Text :
Max. Text Size : 3

Events
Touch Release Event
if(api==1)
{
page utilities
}

Picture weather
Attributes
ID : 7
Expand Down
Binary file modified hmi/nspanel_eu.HMI
Binary file not shown.
Binary file modified hmi/nspanel_eu.tft
Binary file not shown.
Binary file modified hmi/nspanel_us.HMI
Binary file not shown.
Binary file modified hmi/nspanel_us.tft
Binary file not shown.
Binary file modified hmi/nspanel_us_land.HMI
Binary file not shown.
Binary file modified hmi/nspanel_us_land.tft
Binary file not shown.
Loading

0 comments on commit f050341

Please sign in to comment.