updated scripting ready for test

This commit is contained in:
Martijn
2024-11-25 18:57:25 +01:00
parent 420634cd4e
commit 0a946467eb
6 changed files with 360 additions and 297 deletions
+13 -37
View File
@@ -10,6 +10,14 @@ packages:
base: !include base.yaml base: !include base.yaml
scripts: !include 1bar_1display_scripts.yaml scripts: !include 1bar_1display_scripts.yaml
esphome:
on_boot:
priority: -100
then:
- script.execute: setup_bar_displays
- script.execute: update_bar1_left
- script.execute: update_bar1_right
mcp23008: mcp23008:
- id: 'base_J2' - id: 'base_J2'
i2c_id: buttons i2c_id: buttons
@@ -18,27 +26,6 @@ mcp23008:
i2c_id: buttons i2c_id: buttons
address: 0x23 address: 0x23
# output:
# # - platform: mcp23xxx
# # mcp23xxx_id: base_J2
# # pin: 1
# # id: cs_pin_1
# # - platform: mcp23xxx
# # mcp23xxx_id: base_J2
# # pin: 5
# # id: cs_pin_2
# - platform: mcp23xxx
# mcp23xxx_id: base_J3
# pin: 1
# id: cs_pin_3
# - platform: mcp23xxx
# mcp23xxx_id: base_J3
# pin: 5
# id: cs_pin_4
binary_sensor: binary_sensor:
############################ ############################
### Buttons Main Display ### ### Buttons Main Display ###
@@ -116,7 +103,10 @@ light:
to: 3 to: 3
output: output:
- id: cs_pin_3 #######################################
### CS pins to control BAR Displays ###
#######################################
- id: cs_pin_bar1_left
platform: gpio platform: gpio
pin: pin:
mcp23xxx: base_J3 mcp23xxx: base_J3
@@ -124,7 +114,7 @@ output:
mode: mode:
output: true output: true
inverted: false inverted: false
- id: cs_pin_4 - id: cs_pin_bar1_right
platform: gpio platform: gpio
pin: pin:
mcp23xxx: base_J3 mcp23xxx: base_J3
@@ -160,20 +150,6 @@ display:
################## ##################
### BAR module ### ### BAR module ###
################## ##################
# - id: bar_display
# platform: ili9xxx
# model: ST7735
# color_order: bgr
# update_interval: never
# dc_pin:
# number: GPIO37
# allow_other_uses: true
# invert_colors: false
# show_test_card: false
# dimensions:
# height: 160
# width: 80
# offset_width: 24
- id: bar_display - id: bar_display
platform: ili9xxx platform: ili9xxx
model: ST7735 model: ST7735
+39 -40
View File
@@ -6,61 +6,62 @@
## ## ## ##
############################################## ##############################################
image:
- file: mdi:lightbulb
id: lightbulb_script
resize: 80x80
- file: mdi:alert
id: alert_script
resize: 80x80
color:
- id: orange_script
hex: FF7F00
script: script:
- id: update_display_1 ######################
### update scripts ###
######################
- id: update_bar1_left
then: then:
- lambda: |- - lambda: |-
id(cs_pin_3).turn_on(); // CS actief voor Display 1 id(cs_pin_bar1_left).turn_on(); // <<
id(cs_pin_4).turn_off(); id(cs_pin_bar1_right).turn_off();
// id(cs_pin_3).write(true); id(cs_pin_bar2_left).turn_off();
// id(cs_pin_4).write(true); id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(bar1_left_page1).execute(); id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
id(bar1_left_draw).execute();
id(bar_display).update(); id(bar_display).update();
delay(10); // Optioneel voor stabiliteit delay(1);
id(cs_pin_3).turn_off(); // CS inactief na update id(cs_pin_bar1_left).turn_off();
- id: update_display_2 - id: update_bar1_right
then: then:
- lambda: |- - lambda: |-
id(cs_pin_3).turn_off(); id(cs_pin_bar1_left).turn_off();
id(cs_pin_4).turn_on(); // CS actief voor Display 2 id(cs_pin_bar1_right).turn_on(); // <<
// id(cs_pin_3).write(true); id(cs_pin_bar2_left).turn_off();
// id(cs_pin_4).write(true); id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(bar1_right_page1).execute(); id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
id(bar1_left_draw).execute();
id(bar_display).update(); id(bar_display).update();
delay(10); // Optioneel voor stabiliteit delay(1);
id(cs_pin_4).turn_off(); // CS inactief na update id(cs_pin_bar1_right).turn_off();
- id: bar1_left_page1 ####################
### draw scripts ###
####################
- id: bar1_left_draw
then: then:
- lambda: |- - lambda: |-
id(bar_display).image(80, 0, id(lightbulb_script), ImageAlign::TOP_CENTER, id(orange_script)); ESP_LOGD("TODO", "You need to extend the bar1_left_draw script to draw something on the bar display \n script: \n - id: !extend bar1_left_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar1_right_page1 - id: bar1_right_draw
then: then:
- lambda: |- - lambda: |-
id(bar_display).image(80, 0, id(alert_script), ImageAlign::TOP_CENTER, id(orange_script)); ESP_LOGD("TODO", "You need to extend the bar1_right_draw script to draw something on the bar display \n script: \n - id: !extend bar1_right_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
##############################
### other handling scripts ###
##############################
- id: update_main - id: update_main
then: then:
- component.update: main_display - component.update: main_display
- id: update_all - id: update_all
then: then:
- component.update: main_display - component.update: main_display
- script.execute: update_display_1 - component.update: bar1_display_left
- script.execute: update_display_2 - component.update: bar1_display_right
# - script.execute: update_display_3
# - script.execute: update_display_4
- id: next_page_main - id: next_page_main
then: then:
- display.page.show_next: main_display - display.page.show_next: main_display
@@ -68,7 +69,6 @@ script:
- id: next_page_all - id: next_page_all
then: then:
- display.page.show_next: main_display - display.page.show_next: main_display
# - display.page.show_next: bar_display
- script.execute: update_all - script.execute: update_all
- id: prev_page_main - id: prev_page_main
then: then:
@@ -77,5 +77,4 @@ script:
- id: prev_page_all - id: prev_page_all
then: then:
- display.page.show_previous: main_display - display.page.show_previous: main_display
# - display.page.show_previous: bar_display
- script.execute: update_all - script.execute: update_all
+41 -77
View File
@@ -148,6 +148,43 @@ light:
from: 7 from: 7
to: 7 to: 7
output:
#######################################
### CS pins to control BAR Displays ###
#######################################
- id: cs_pin_bar1_left
platform: gpio
pin:
mcp23xxx: base_J1
number: 5
mode:
output: true
inverted: true
- id: cs_pin_bar1_right
platform: gpio
pin:
mcp23xxx: base_J1
number: 1
mode:
output: true
inverted: true
- id: cs_pin_bar2_left
platform: gpio
pin:
mcp23xxx: base_J2
number: 5
mode:
output: true
inverted: true
- id: cs_pin_bar2_right
platform: gpio
pin:
mcp23xxx: base_J2
number: 1
mode:
output: true
inverted: true
display: display:
#################### ####################
### Main Display ### ### Main Display ###
@@ -172,10 +209,10 @@ display:
height: 240 height: 240
width: 320 width: 320
rotation: 180 rotation: 180
#################### ###################
### BAR module 1 ### ### BAR modules ###
#################### ###################
- id: bar1_display_left - id: bar_display
platform: ili9xxx platform: ili9xxx
model: ST7735 model: ST7735
color_order: bgr color_order: bgr
@@ -183,82 +220,9 @@ display:
dc_pin: dc_pin:
number: GPIO37 number: GPIO37
allow_other_uses: true allow_other_uses: true
cs_pin:
mcp23xxx: base_J2
number: 5
mode:
output: true
inverted: false
invert_colors: false invert_colors: false
show_test_card: false show_test_card: false
dimensions: dimensions:
height: 160 height: 160
width: 80 width: 80
offset_width: 24 offset_width: 24
rotation: 270
- id: bar1_display_right
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J2
number: 1
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 90
####################
### BAR module 2 ###
####################
- id: bar2_display_left
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J3
number: 5
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 270
- id: bar2_display_right
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J3
number: 1
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 90
+85 -8
View File
@@ -7,6 +7,91 @@
############################################## ##############################################
script: script:
######################
### update scripts ###
######################
- id: update_bar1_left
then:
- lambda: |-
id(cs_pin_bar1_left).turn_on(); // <<
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
id(bar1_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar1_left).turn_off();
- id: update_bar1_right
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_on(); // <<
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
id(bar1_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar1_right).turn_off();
- id: update_bar2_left
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_on(); // <<
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
id(bar2_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar2_left).turn_off();
- id: update_bar2_right
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_on(); // <<
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
id(bar2_right_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar2_right).turn_off();
####################
### draw scripts ###
####################
- id: bar1_left_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar1_left_draw script to draw something on the bar display \n script: \n - id: !extend bar1_left_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar1_right_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar1_right_draw script to draw something on the bar display \n script: \n - id: !extend bar1_right_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar2_left_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar2_left_draw script to draw something on the bar display \n script: \n - id: !extend bar2_left_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar2_right_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar2_right_draw script to draw something on the bar display \n script: \n - id: !extend bar2_right_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
##############################
### other handling scripts ###
##############################
- id: update_main - id: update_main
then: then:
- component.update: main_display - component.update: main_display
@@ -24,10 +109,6 @@ script:
- id: next_page_all - id: next_page_all
then: then:
- display.page.show_next: main_display - display.page.show_next: main_display
- display.page.show_next: bar1_display_left
- display.page.show_next: bar1_display_right
- display.page.show_next: bar2_display_left
- display.page.show_next: bar2_display_right
- script.execute: update_all - script.execute: update_all
- id: prev_page_main - id: prev_page_main
then: then:
@@ -36,8 +117,4 @@ script:
- id: prev_page_all - id: prev_page_all
then: then:
- display.page.show_previous: main_display - display.page.show_previous: main_display
- display.page.show_previous: bar1_display_left
- display.page.show_previous: bar1_display_right
- display.page.show_previous: bar2_display_left
- display.page.show_previous: bar2_display_right
- script.execute: update_all - script.execute: update_all
+59 -123
View File
@@ -202,6 +202,59 @@ light:
from: 11 from: 11
to: 11 to: 11
output:
#######################################
### CS pins to control BAR Displays ###
#######################################
- id: cs_pin_bar1_left
platform: gpio
pin:
mcp23xxx: base_J1
number: 5
mode:
output: true
inverted: true
- id: cs_pin_bar1_right
platform: gpio
pin:
mcp23xxx: base_J1
number: 1
mode:
output: true
inverted: true
- id: cs_pin_bar2_left
platform: gpio
pin:
mcp23xxx: base_J2
number: 5
mode:
output: true
inverted: true
- id: cs_pin_bar2_right
platform: gpio
pin:
mcp23xxx: base_J2
number: 1
mode:
output: true
inverted: true
- id: cs_pin_bar3_left
platform: gpio
pin:
mcp23xxx: base_J3
number: 5
mode:
output: true
inverted: true
- id: cs_pin_bar3_right
platform: gpio
pin:
mcp23xxx: base_J3
number: 1
mode:
output: true
inverted: true
display: display:
#################### ####################
### Main Display ### ### Main Display ###
@@ -226,10 +279,10 @@ display:
height: 240 height: 240
width: 320 width: 320
rotation: 180 rotation: 180
#################### ###################
### BAR module 1 ### ### BAR modules ###
#################### ###################
- id: bar1_display_left - id: bar_display
platform: ili9xxx platform: ili9xxx
model: ST7735 model: ST7735
color_order: bgr color_order: bgr
@@ -237,127 +290,10 @@ display:
dc_pin: dc_pin:
number: GPIO37 number: GPIO37
allow_other_uses: true allow_other_uses: true
cs_pin:
mcp23xxx: base_J1
number: 5
mode:
output: true
inverted: false
invert_colors: false invert_colors: false
show_test_card: false show_test_card: false
auto_clear_enabled: false
dimensions: dimensions:
height: 160 height: 160
width: 80 width: 80
offset_width: 24 offset_width: 24
rotation: 270
- id: bar1_display_right
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J1
number: 1
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 90
####################
### BAR module 2 ###
####################
- id: bar2_display_left
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J2
number: 5
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 270
- id: bar2_display_right
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J2
number: 1
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 90
####################
### BAR module 3 ###
####################
- id: bar3_display_left
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J3
number: 5
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 270
- id: bar3_display_right
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO37
allow_other_uses: true
cs_pin:
mcp23xxx: base_J3
number: 1
mode:
output: true
inverted: false
invert_colors: false
show_test_card: false
dimensions:
height: 160
width: 80
offset_width: 24
rotation: 90
+123 -12
View File
@@ -7,6 +7,129 @@
############################################## ##############################################
script: script:
######################
### update scripts ###
######################
- id: update_bar1_left
then:
- lambda: |-
id(cs_pin_bar1_left).turn_on(); // <<
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
id(bar1_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar1_left).turn_off();
- id: update_bar1_right
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_on(); // <<
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
id(bar1_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar1_right).turn_off();
- id: update_bar2_left
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_on(); // <<
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
id(bar2_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar2_left).turn_off();
- id: update_bar2_right
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_on(); // <<
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
id(bar2_right_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar2_right).turn_off();
- id: update_bar3_left
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_on(); // <<
id(cs_pin_bar3_right).turn_off();
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
id(bar3_left_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar3_left).turn_off();
- id: update_bar3_right
then:
- lambda: |-
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_on(); // <<
id(bar_display).clear();
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
id(bar3_right_draw).execute();
id(bar_display).update();
delay(1);
id(cs_pin_bar3_right).turn_off();
####################
### draw scripts ###
####################
- id: bar1_left_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar1_left_draw script to draw something on the bar display \n script: \n - id: !extend bar1_left_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar1_right_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar1_right_draw script to draw something on the bar display \n script: \n - id: !extend bar1_right_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar2_left_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar2_left_draw script to draw something on the bar display \n script: \n - id: !extend bar2_left_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar2_right_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar2_right_draw script to draw something on the bar display \n script: \n - id: !extend bar2_right_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar3_left_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar3_left_draw script to draw something on the bar display \n script: \n - id: !extend bar3_left_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
- id: bar3_right_draw
then:
- lambda: |-
ESP_LOGD("TODO", "You need to extend the bar3_right_draw script to draw something on the bar display \n script: \n - id: !extend bar3_right_draw\n then:\n - lambda: |-\n \\ your draw scripts here!");
##############################
### other handling scripts ###
##############################
- id: update_main - id: update_main
then: then:
- component.update: main_display - component.update: main_display
@@ -26,12 +149,6 @@ script:
- id: next_page_all - id: next_page_all
then: then:
- display.page.show_next: main_display - display.page.show_next: main_display
- display.page.show_next: bar1_display_left
- display.page.show_next: bar1_display_right
- display.page.show_next: bar2_display_left
- display.page.show_next: bar2_display_right
- display.page.show_next: bar3_display_left
- display.page.show_next: bar3_display_right
- script.execute: update_all - script.execute: update_all
- id: prev_page_main - id: prev_page_main
then: then:
@@ -40,10 +157,4 @@ script:
- id: prev_page_all - id: prev_page_all
then: then:
- display.page.show_previous: main_display - display.page.show_previous: main_display
- display.page.show_previous: bar1_display_left
- display.page.show_previous: bar1_display_right
- display.page.show_previous: bar2_display_left
- display.page.show_previous: bar2_display_right
- display.page.show_previous: bar3_display_left
- display.page.show_previous: bar3_display_right
- script.execute: update_all - script.execute: update_all