diff --git a/package/3bar_1display_scripts.yaml b/package/3bar_1display_scripts.yaml index 326ee04..3aac20d 100644 --- a/package/3bar_1display_scripts.yaml +++ b/package/3bar_1display_scripts.yaml @@ -134,6 +134,7 @@ script: ### pre-define draw scripts ### ############################### - id: bar1_left_draw + then: - id: bar1_right_draw then: - id: bar2_left_draw @@ -159,22 +160,3 @@ script: - script.execute: update_bar2_right - script.execute: update_bar3_left - script.execute: update_bar3_right -###################### -### paging scripts ### -###################### - - 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 diff --git a/package/base.yaml b/package/base.yaml index c348239..9ea7c2a 100644 --- a/package/base.yaml +++ b/package/base.yaml @@ -23,6 +23,16 @@ spi: clk_pin: GPIO36 mosi_pin: GPIO35 +global: + - id: nr_of_pages + type: int + restore_value: no + initial_value: '1' + - id: actual_page + type: int + restore_value: no + initial_value: '0' + output: - platform: ledc pin: GPIO3 @@ -68,3 +78,26 @@ light: time: - platform: homeassistant id: datetime + +script: +###################### +### paging scripts ### +###################### + - id: next_page + then: + - lambda: |- + id(actual_page) = id(actual_page) + 1; + if(id(actual_page) >= id(nr_of_pages)) { + id(actual_page) = 0; + } + - display.page.show_next: main_display + - script.execute: update_all + - id: prev_page + then: + - lambda: |- + id(actual_page) = id(actual_page) - 1; + if(id(actual_page) <= 0 { + id(actual_page) = id(nr_of_pages); + } + - display.page.show_previous: main_display + - script.execute: update_all