fix 1BAR / 1 Display Setup
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
packages:
|
||||
remote_package_files:
|
||||
url: https://github.com/dixi83/ESPHome_ButtonPlus
|
||||
files:
|
||||
- 'package/1bar_1display.yaml'
|
||||
ref: main
|
||||
refresh: 10s
|
||||
|
||||
globals:
|
||||
- id: !extend nr_of_pages
|
||||
initial_value: '1'
|
||||
|
||||
font:
|
||||
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
||||
id: font_arial20
|
||||
size: 20
|
||||
bpp: 4
|
||||
- file: "https://torinak.com/font/7segment.ttf"
|
||||
id: font_clock
|
||||
size: 64
|
||||
bpp: 4
|
||||
- file: "https://torinak.com/font/7segment.ttf"
|
||||
id: font_date
|
||||
size: 24
|
||||
bpp: 4
|
||||
|
||||
image:
|
||||
- file: mdi:lightbulb
|
||||
id: lightbulb
|
||||
resize: 80x80
|
||||
- file: mdi:alert
|
||||
id: alert
|
||||
resize: 80x80
|
||||
- file: mdi:chevron-right
|
||||
id: icon_next_page
|
||||
resize: 30x30
|
||||
- file: mdi:chevron-left
|
||||
id: icon_prev_page
|
||||
resize: 30x30
|
||||
- file: mdi:home-thermometer-outline
|
||||
id: icon_temp_inside
|
||||
resize: 40x40
|
||||
|
||||
color:
|
||||
- id: red
|
||||
hex: FF0000
|
||||
- id: blue
|
||||
hex: 0000FF
|
||||
- id: yellow
|
||||
hex: FFFF00
|
||||
- id: green
|
||||
hex: 00FF00
|
||||
- id: orange
|
||||
hex: FF7F00
|
||||
- id: white
|
||||
hex: FFFFFF
|
||||
- id: grey
|
||||
hex: A6A6A6
|
||||
|
||||
event:
|
||||
- platform: template
|
||||
name: BAR1 button Left event
|
||||
id: bar1_btn_left_event
|
||||
event_types:
|
||||
- "press page 0"
|
||||
- "release page 0"
|
||||
- "long press page 0"
|
||||
- platform: template
|
||||
name: BAR1 button Right event
|
||||
id: bar1_btn_right_event
|
||||
event_types:
|
||||
- "press page 0"
|
||||
- "release page 0"
|
||||
- "long press page 0"
|
||||
|
||||
binary_sensor:
|
||||
- id: !extend main_display_btn_left
|
||||
on_click:
|
||||
- script.execute: prev_page
|
||||
- id: !extend main_display_btn_right
|
||||
on_click:
|
||||
- script.execute: next_page
|
||||
- id: !extend bar1_btn_left
|
||||
on_click:
|
||||
lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar1_btn_left_event).trigger("press page 0");
|
||||
break;
|
||||
}
|
||||
on_release:
|
||||
lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar1_btn_left_event).trigger("release page 0");
|
||||
break;
|
||||
}
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at least 2s
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar1_btn_left_event).trigger("long press page 0");
|
||||
break;
|
||||
}
|
||||
- id: !extend bar1_btn_right
|
||||
on_click:
|
||||
lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar1_btn_right_event).trigger("press page 0");
|
||||
break;
|
||||
}
|
||||
on_release:
|
||||
lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar1_btn_right_event).trigger("release page 0");
|
||||
break;
|
||||
}
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at least 2s
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar1_btn_right_event).trigger("long press page 0");
|
||||
break;
|
||||
}
|
||||
|
||||
display:
|
||||
#########
|
||||
# MAIN ##
|
||||
#########
|
||||
- id: !extend main_display
|
||||
# data_rate: 40MHz
|
||||
lambda: |-
|
||||
id(all_pages_main).execute();
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
it.print(100, 160, id(font_arial20), "This is page 0!");
|
||||
break;
|
||||
}
|
||||
|
||||
script:
|
||||
- id: all_pages_main
|
||||
then:
|
||||
- lambda: |-
|
||||
//>>> prev/next icons next to butotns
|
||||
id(main_display).image(0, 208, id(icon_prev_page), ImageAlign::TOP_LEFT, id(red));
|
||||
id(main_display).image(320, 208, id(icon_next_page), ImageAlign::TOP_RIGHT, id(red));
|
||||
//
|
||||
//>>> temperature inside:
|
||||
id(main_display).image(36, 15, id(icon_temp_inside), ImageAlign::TOP_CENTER, id(red));
|
||||
id(main_display).printf(36, 80, id(font_arial20), id(white), TextAlign::TOP_CENTER , "%.1f°", id(inside_temperature).state);
|
||||
//
|
||||
//>>> print time and date
|
||||
id(main_display).strftime(160, 5, id(font_clock), TextAlign::TOP_CENTER, "%H:%M", id(datetime).now());
|
||||
id(main_display).strftime(160, 80, id(font_date), TextAlign::TOP_CENTER, "%d-%m-%Y", id(datetime).now());
|
||||
- id: !extend bar1_left_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
}
|
||||
- id: !extend bar1_right_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ output:
|
||||
number: 5
|
||||
mode:
|
||||
output: true
|
||||
inverted: false
|
||||
inverted: true
|
||||
- id: cs_pin_bar1_right
|
||||
platform: gpio
|
||||
pin:
|
||||
@@ -121,7 +121,7 @@ output:
|
||||
number: 1
|
||||
mode:
|
||||
output: true
|
||||
inverted: false
|
||||
inverted: true
|
||||
|
||||
display:
|
||||
####################
|
||||
@@ -130,9 +130,9 @@ display:
|
||||
- id: main_display
|
||||
platform: ili9xxx
|
||||
model: ili9341
|
||||
invert_colors: false
|
||||
color_order: rgb
|
||||
update_interval: 30s
|
||||
invert_colors: false
|
||||
dc_pin:
|
||||
number: GPIO37
|
||||
allow_other_uses: true
|
||||
|
||||
@@ -19,7 +19,7 @@ script:
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
|
||||
id(bar1_left_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
delay(2);
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
- id: update_bar1_right
|
||||
then:
|
||||
@@ -30,7 +30,7 @@ script:
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
|
||||
id(bar1_right_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
delay(2);
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
##################################
|
||||
### setup mini display scripts ###
|
||||
@@ -63,19 +63,3 @@ script:
|
||||
- component.update: main_display
|
||||
- script.execute: update_bar1_left
|
||||
- script.execute: update_bar1_right
|
||||
- id: next_page_main
|
||||
then:
|
||||
- display.page.show_next: main_display
|
||||
- script.execute: update_main
|
||||
- id: next_page_all
|
||||
then:
|
||||
- display.page.show_next: main_display
|
||||
- script.execute: update_all
|
||||
- id: prev_page_main
|
||||
then:
|
||||
- display.page.show_previous: main_display
|
||||
- script.execute: update_main
|
||||
- id: prev_page_all
|
||||
then:
|
||||
- display.page.show_previous: main_display
|
||||
- script.execute: update_all
|
||||
|
||||
Reference in New Issue
Block a user