Project setup

This commit is contained in:
2026-05-12 13:04:34 +02:00
parent 47d298f4ad
commit 43e510b93d
19 changed files with 2034 additions and 1 deletions
+304
View File
@@ -0,0 +1,304 @@
packages:
base: !include ../common.yaml
scripts: !include scripts.yaml
events: !include events.yaml
esphome:
on_boot:
priority: -100
then:
- script.execute: setup_bar_displays
- script.execute: update_bar1_left
- script.execute: update_bar1_right
- script.execute: update_bar2_left
- script.execute: update_bar2_right
- script.execute: update_bar3_left
- script.execute: update_bar3_right
mcp23008:
- id: 'base_J0'
i2c_id: buttons
address: 0x20
- id: 'base_J1'
i2c_id: buttons
address: 0x21
- id: 'base_J2'
i2c_id: buttons
address: 0x22
- id: 'base_J3'
i2c_id: buttons
address: 0x23
binary_sensor:
############################
### Buttons Main Display ###
############################
- platform: gpio
id: 'main_display_btn_left'
name: "Main Display button Left"
pin:
mcp23xxx: base_J0
number: 6
mode: INPUT_PULLUP
inverted: true
- platform: gpio
id: 'main_display_btn_right'
name: "Main Display button Right"
pin:
mcp23xxx: base_J0
number: 2
mode: INPUT_PULLUP
inverted: true
############################
### Buttons BAR module 1 ###
############################
- platform: gpio
id: 'bar1_btn_left'
name: "BAR 1 button Left"
pin:
mcp23xxx: base_J1
number: 6
mode: INPUT_PULLUP
inverted: true
- platform: gpio
id: 'bar1_btn_right'
name: "BAR 1 button Right"
pin:
mcp23xxx: base_J1
number: 2
mode: INPUT_PULLUP
inverted: true
############################
### Buttons BAR module 2 ###
############################
- platform: gpio
id: 'bar2_btn_left'
name: "BAR 2 button Left"
pin:
mcp23xxx: base_J2
number: 6
mode: INPUT_PULLUP
inverted: true
- platform: gpio
id: 'bar2_btn_right'
name: "BAR 2 button Right"
pin:
mcp23xxx: base_J2
number: 2
mode: INPUT_PULLUP
inverted: true
############################
### Buttons BAR module 3 ###
############################
- platform: gpio
id: 'bar3_btn_left'
name: "BAR 3 button Left"
pin:
mcp23xxx: base_J3
number: 6
mode: INPUT_PULLUP
inverted: true
- platform: gpio
id: 'bar3_btn_right'
name: "BAR 3 button Right"
pin:
mcp23xxx: base_J3
number: 2
mode: INPUT_PULLUP
inverted: true
light:
- id: !extend neopixels
num_leds: 13
##############################
### RGB LED's BAR module 1 ###
##############################
- platform: partition
name: "BAR 1 Left RGB Front"
id: bar1_left_rgb_front
segments:
- id: neopixels
from: 0
to: 0
- platform: partition
name: "BAR 1 Left RGB Back"
id: bar1_left_rgb_back
segments:
- id: neopixels
from: 1
to: 1
- platform: partition
name: "BAR 1 Right RGB Front"
id: bar1_right_rgb_front
segments:
- id: neopixels
from: 2
to: 2
- platform: partition
name: "BAR 1 Right RGB Back"
id: bar1_right_rgb_back
segments:
- id: neopixels
from: 3
to: 3
##############################
### RGB LED's BAR module 2 ###
##############################
- platform: partition
name: "BAR 2 Left RGB Front"
id: bar2_left_rgb_front
segments:
- id: neopixels
from: 4
to: 4
- platform: partition
name: "BAR 2 Left RGB Back"
id: bar2_left_rgb_back
segments:
- id: neopixels
from: 5
to: 5
- platform: partition
name: "BAR 2 Right RGB Front"
id: bar2_right_rgb_front
segments:
- id: neopixels
from: 6
to: 6
- platform: partition
name: "BAR 2 Right RGB Back"
id: bar2_right_rgb_back
segments:
- id: neopixels
from: 7
to: 7
##############################
### RGB LED's BAR module 3 ###
##############################
- platform: partition
name: "BAR 3 Left RGB Front"
id: bar3_left_rgb_front
segments:
- id: neopixels
from: 8
to: 8
- platform: partition
name: "BAR 3 Left RGB Back"
id: bar3_left_rgb_back
segments:
- id: neopixels
from: 9
to: 9
- platform: partition
name: "BAR 3 Right RGB Front"
id: bar3_right_rgb_front
segments:
- id: neopixels
from: 10
to: 10
- platform: partition
name: "BAR 3 Right RGB Back"
id: bar3_right_rgb_back
segments:
- id: neopixels
from: 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:
####################
### Main Display ###
####################
- id: main_display
platform: ili9xxx
model: ili9341
invert_colors: false
color_order: rgb
update_interval: 30s
dc_pin:
number: GPIO7
allow_other_uses: true
cs_pin:
mcp23xxx: base_J0
number: 5
mode:
output: true
inverted: false
show_test_card: false
dimensions:
height: 240
width: 320
rotation: 180
###################
### BAR modules ###
###################
- id: bar_display
platform: ili9xxx
model: ST7735
color_order: bgr
update_interval: never
dc_pin:
number: GPIO7
allow_other_uses: true
invert_colors: false
show_test_card: false
auto_clear_enabled: false
dimensions:
height: 160
width: 80
offset_width: 24
+275
View File
@@ -0,0 +1,275 @@
esphome:
name: buttonplus
friendly_name: ButtonPlus
esp32:
variant: ESP32S3
board: esp32-s3-devkitc1-n16r8
flash_size: 16MB
framework:
type: esp-idf
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: ""
ota:
- platform: esphome
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Buttonplus"
password: ""
packages:
remote_package_files:
files:
- path: 'base.yaml'
vars:
nr_of_pages: '3'
page_names: '{"Start", "Music", "Page 3"}'
- path: '../cards/music.yaml'
vars:
music_card_entity_id: 'media_player.spotifyplus_kennyboy44'
music_card_text_color: FFFFFF
music_card_icon_main_color: FF7F00
music_card_icon_bar_color: FF7F00
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
type: GRAYSCALE
- file: mdi:alert
id: alert
resize: 80x80
type: GRAYSCALE
- file: mdi:chevron-right
id: icon_next_page
resize: 30x30
type: GRAYSCALE
- file: mdi:chevron-left
id: icon_prev_page
resize: 30x30
type: GRAYSCALE
- file: mdi:home-thermometer-outline
id: icon_temp_inside
resize: 40x40
type: GRAYSCALE
- file: mdi:brightness-percent
id: icon_ambient_inside
resize: 40x40
type: GRAYSCALE
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
display:
#########
# MAIN ##
#########
- id: !extend main_display
# data_rate: 40MHz
lambda: |-
id(all_pages_main).execute();
switch (id(actual_page)){
case 0:
it.print(100, 150, id(font_arial20), "Hooray, it works!");
break;
case 1:
id(music_card).execute(20, 125);
break;
case 2:
it.print(100, 150, id(font_arial20), "Last Page");
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));
//
//>>> Page name
id(main_display).print(100, 208, id(font_arial20), id(active_page_name).c_str());
//
//>>> 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(buttonplus_temperature).state);
//
//>>> ambient light:
id(main_display).image(285, 15, id(icon_ambient_inside), ImageAlign::TOP_CENTER, id(red));
id(main_display).printf(285, 80, id(font_arial20), id(white), TextAlign::TOP_CENTER , "%.1flux", id(buttonplus_ambientlight).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;
case 1:
id(music_card_bar).execute("volume_down");
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;
case 1:
id(music_card_bar).execute("volume_up");
break;
}
- id: !extend bar2_left_draw
then:
- lambda: |-
switch (id(actual_page)){
case 0:
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
break;
case 1:
id(music_card_bar).execute("prev");
break;
}
- id: !extend bar2_right_draw
then:
- lambda: |-
switch (id(actual_page)){
case 0:
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
break;
case 1:
id(music_card_bar).execute("next");
break;
}
- id: !extend bar3_left_draw
then:
- lambda: |-
switch (id(actual_page)){
case 0:
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
break;
case 1:
id(music_card_bar).execute("power");
break;
}
- id: !extend bar3_right_draw
then:
- lambda: |-
switch (id(actual_page)){
case 0:
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
break;
case 1:
id(music_card_bar).execute("playpause");
break;
}
event:
- id: !extend bar1_btn_left_event
on_event:
then:
- lambda: |-
ESP_LOGD("main", "BAR1LEFT event %s triggered.", event_type.c_str());
- lambda: |-
if (event_type == "click page 1"){
id(music_card_vol_down).execute();
ESP_LOGD("main", "VOL DOWN");
}
- id: !extend bar1_btn_right_event
on_event:
then:
- lambda: |-
ESP_LOGD("main", "BAR1RIGHT event %s triggered.", event_type.c_str());
- lambda: |-
if (event_type == "click page 1"){
id(music_card_vol_up).execute();
ESP_LOGD("main", "VOL UP");
}
- id: !extend bar2_btn_left_event
on_event:
then:
- lambda: |-
ESP_LOGD("main", "BAR2LEFT event %s triggered.", event_type.c_str());
- lambda: |-
if (event_type == "click page 1"){
id(music_card_prev).execute();
ESP_LOGD("main", "PREV");
}
- id: !extend bar2_btn_right_event
on_event:
then:
- lambda: |-
ESP_LOGD("main", "BAR2RIGHT event %s triggered.", event_type.c_str());
- lambda: |-
if (event_type == "click page 1"){
id(music_card_next).execute();
ESP_LOGD("main", "NEXT");
}
- id: !extend bar3_btn_left_event
on_event:
then:
- lambda: |-
ESP_LOGD("main", "BAR3LEFT event %s triggered.", event_type.c_str());
- lambda: |-
if (event_type == "click page 1"){
id(music_card_power).execute();
ESP_LOGD("main", "POWER");
}
- id: !extend bar3_btn_right_event
on_event:
then:
- lambda: |-
ESP_LOGD("main", "BAR3RIGHT event %s triggered.", event_type.c_str());
- lambda: |-
if (event_type == "click page 1"){
id(music_card_playpause).execute();
ESP_LOGD("main", "PLAY PAUSE");
}
+549
View File
@@ -0,0 +1,549 @@
## Events for 3 pages
substitutions:
nr_of_pages: '3'
display_events:
- double_click page 0
- triple_click page 0
- hold page 0
- double_click page 1
- triple_click page 1
- hold page 1
- double_click page 2
- triple_click page 2
- hold page 2
button_events:
- click page 0
- double_click page 0
- triple_click page 0
- hold page 0
- click page 1
- double_click page 1
- triple_click page 1
- hold page 1
- click page 2
- double_click page 2
- triple_click page 2
- hold page 2
script:
- id: trigger_with_feedback
parameters:
event_id: esphome::template_::TemplateEvent*
event_msg: std::string
led_id: light::LightState*
r: float
g: float
b: float
then:
- lambda: event_id->trigger(event_msg);
- if:
condition:
lambda: return led_id != nullptr;
then:
- lambda: |-
auto call = led_id->make_call();
call.set_state(true);
call.set_rgb(r, g, b);
call.set_brightness(1.0);
call.set_flash_length(200); // Returns to previous state automatically
call.perform();
event:
- platform: template
name: DISPLAY Button Left
id: display_btn_left_event
device_class: button
event_types: ${display_events}
- platform: template
name: DISPLAY Button Right
id: display_btn_right_event
device_class: button
event_types: ${display_events}
- platform: template
name: BAR1 Button Left
id: bar1_btn_left_event
device_class: button
event_types: ${button_events}
- platform: template
name: BAR1 Button Right
id: bar1_btn_right_event
device_class: button
event_types: ${button_events}
- platform: template
name: BAR2 Button Left
id: bar2_btn_left_event
device_class: button
event_types: ${button_events}
- platform: template
name: BAR2 Button Right
id: bar2_btn_right_event
device_class: button
event_types: ${button_events}
- platform: template
name: BAR3 Button Left
id: bar3_btn_left_event
device_class: button
event_types: ${button_events}
- platform: template
name: BAR3 Button Right
id: bar3_btn_right_event
device_class: button
event_types: ${button_events}
binary_sensor:
- id: !extend 'main_display_btn_left'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute: prev_page
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: display_btn_left_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: !lambda "return nullptr;"
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: display_btn_left_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: !lambda "return nullptr;"
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: display_btn_left_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: !lambda "return nullptr;"
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'main_display_btn_right'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute: next_page
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: display_btn_right_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: !lambda "return nullptr;"
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: display_btn_right_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: !lambda "return nullptr;"
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: display_btn_right_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: !lambda "return nullptr;"
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'bar1_btn_left'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_left_event
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
led_id: bar1_left_rgb_front
r: 0.0
g: 1.0
b: 0.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_left_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: bar1_left_rgb_front
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_left_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: bar1_left_rgb_front
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_left_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: bar1_left_rgb_front
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'bar1_btn_right'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_right_event
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
led_id: bar1_right_rgb_front
r: 0.0
g: 1.0
b: 0.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_right_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: bar1_right_rgb_front
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_right_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: bar1_right_rgb_front
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar1_btn_right_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: bar1_right_rgb_front
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'bar2_btn_left'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_left_event
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
led_id: bar2_left_rgb_front
r: 0.0
g: 1.0
b: 0.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_left_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: bar2_left_rgb_front
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_left_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: bar2_left_rgb_front
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_left_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: bar2_left_rgb_front
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'bar2_btn_right'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_right_event
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
led_id: bar2_right_rgb_front
r: 0.0
g: 1.0
b: 0.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_right_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: bar2_right_rgb_front
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_right_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: bar2_right_rgb_front
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar2_btn_right_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: bar2_right_rgb_front
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'bar3_btn_left'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_left_event
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
led_id: bar3_left_rgb_front
r: 0.0
g: 1.0
b: 0.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_left_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: bar3_left_rgb_front
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_left_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: bar3_left_rgb_front
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_left_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: bar3_left_rgb_front
r: 1.0
g: 0.5
b: 0.0
- id: !extend 'bar3_btn_right'
filters:
- delayed_off: 10ms
internal: true
on_multi_click:
- timing:
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_right_event
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
led_id: bar3_right_rgb_front
r: 0.0
g: 1.0
b: 0.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_right_event
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
led_id: bar3_right_rgb_front
r: 0.0
g: 0.0
b: 1.0
- timing:
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at most 0.2s
- ON for at most 300ms
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_right_event
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
led_id: bar3_right_rgb_front
r: 1.0
g: 0.0
b: 1.0
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- script.execute:
id: trigger_with_feedback
event_id: bar3_btn_right_event
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
led_id: bar3_right_rgb_front
r: 1.0
g: 0.5
b: 0.0
+161
View File
@@ -0,0 +1,161 @@
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_right_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();
####################################
### setup mini display's scripts ###
####################################
- id: setup_bar_displays
then:
- lambda: |-
id(cs_pin_bar1_left).turn_on();
id(bar_display).setup();
delay(5);
id(cs_pin_bar1_left).turn_off();
id(cs_pin_bar1_right).turn_on();
id(bar_display).setup();
delay(5);
id(cs_pin_bar1_right).turn_off();
id(cs_pin_bar2_left).turn_on();
id(bar_display).setup();
delay(5);
id(cs_pin_bar2_left).turn_off();
id(cs_pin_bar2_right).turn_on();
id(bar_display).setup();
delay(5);
id(cs_pin_bar2_right).turn_off();
id(cs_pin_bar3_left).turn_on();
id(bar_display).setup();
delay(5);
id(cs_pin_bar3_left).turn_off();
id(cs_pin_bar3_right).turn_on();
id(bar_display).setup();
delay(5);
id(cs_pin_bar3_right).turn_off();
###############################
### pre-define draw scripts ###
###############################
- id: bar1_left_draw
then:
- id: bar1_right_draw
then:
- id: bar2_left_draw
then:
- id: bar2_right_draw
then:
- id: bar3_left_draw
then:
- id: bar3_right_draw
then:
######################
### update scripts ###
######################
- id: update_main
then:
- component.update: main_display
- id: update_all
then:
- component.update: main_display
- delay: 0.1s
- script.execute: update_bar1_left
- delay: 0.1s
- script.execute: update_bar1_right
- delay: 0.1s
- script.execute: update_bar2_left
- delay: 0.1s
- script.execute: update_bar2_right
- delay: 0.1s
- script.execute: update_bar3_left
- delay: 0.1s
- script.execute: update_bar3_right