Skip to content

Commit

Permalink
[desk-display] Add notification service with simple text scroller
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz committed May 1, 2024
1 parent bf0ab8c commit 7f6f5a5
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions desk-display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,47 @@ packages:
common: !include modules/common-32-idf.yaml
wifi: !include modules/common/wifi.yaml

api:
services:
- service: notify
variables:
message: string
type: int
then:
- text.set:
id: notification_text
value: !lambda return message;
- display.page.show: notification
- delay: 1s
- lambda: |-
int x_offset, baseline, width, height;
id(font_8bithud)->measure(id(notification_text).state.c_str(), &width, &x_offset, &baseline, &height);

Check warning on line 25 in desk-display.yaml

View workflow job for this annotation

GitHub Actions / 🧹 yamllint

line too long
id(text_width) = width;
- repeat:
count: !lambda "return id(text_width) - 16;"
then:
- globals.set:
id: scroller_position
value: !lambda "return id(scroller_position) - 1;"
- delay: 100ms
- display.page.show: clock_page
- text.set:
id: notification_text
value: ""
- globals.set:
id: scroller_position
value: "0"

globals:
- id: scroller_position
type: int32_t
restore_value: false
initial_value: "0"
- id: text_width
type: uint32_t
restore_value: false
initial_value: "0"

light:
- platform: esp32_rmt_led_strip
chipset: WS2812
Expand Down Expand Up @@ -80,9 +121,13 @@ display:
id(sntp_time).now());
# yamllint enable rule:line-length

# - id: notification
# lambda: |-
# return
- id: notification
lambda: |-
auto light_color = id(matrix).current_values;
Color color(light_color.get_red() * 255, light_color.get_green() * 255,
light_color.get_blue() * 255);
it.print(id(scroller_position), 0, id(font_8bithud), color, id(notification_text).state.c_str());

Check warning on line 130 in desk-display.yaml

View workflow job for this annotation

GitHub Actions / 🧹 yamllint

line too long
font:
- id: font_8bithud
Expand All @@ -102,3 +147,9 @@ switch:
- lambda: id(display_entity).set_enabled(true);
turn_off_action:
- lambda: id(display_entity).set_enabled(false);

text:
- platform: template
id: notification_text
optimistic: true
mode: text

0 comments on commit 7f6f5a5

Please sign in to comment.