##############################################
##                                          ##
##   filename: 1bar_1display_scripts.yaml   ##
##   description: Specific pre-defined      ##
##   scripts for 1 BAR 1 Display setup      ##
##                                          ##
##############################################

image:
  - file: mdi:lightbulb
    id: lightbulb_script
    resize: 80x80
  - file: mdi:alert
    id: alert_script
    resize: 80x80

color:
  - id: orange_script
    hex: FF7F00

script:
  - id: update_display_1
    then:
      - lambda: |-
          id(cs_pin_3).turn_off();  // CS actief voor Display 1
          id(cs_pin_4).turn_on();
          // id(cs_pin_3).write(true);
          // id(cs_pin_4).write(true);

          id(bar1_left_page1).execute();
          id(bar_display).update();
          delay(10);  // Optioneel voor stabiliteit
          id(cs_pin_3).turn_on();  // CS inactief na update
  - id: update_display_2
    then:
      - lambda: |-
          id(cs_pin_3).turn_on();
          id(cs_pin_4).turn_off();  // CS actief voor Display 2
          // id(cs_pin_3).write(true);
          // id(cs_pin_4).write(true);

          id(bar1_right_page1).execute();
          id(bar_display).update();
          delay(10);  // Optioneel voor stabiliteit
          id(cs_pin_4).turn_on();  // CS inactief na update
  - id: bar1_left_page1
    then:
      - lambda: |-
            id(bar_display).image(80, 0, id(lightbulb_script), ImageAlign::TOP_CENTER, id(orange_script));
  - id: bar1_right_page1
    then:
      - lambda: |-
            id(bar_display).image(80, 0, id(alert_script), ImageAlign::TOP_CENTER, id(orange_script));
  - id: update_main
    then:
      - component.update: main_display
  - id: update_all
    then:
      - component.update: main_display
      - script.execute: update_display_1
      - script.execute: update_display_2
      # - script.execute: update_display_3
      # - script.execute: update_display_4
  - 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
      # - display.page.show_next: bar_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
      # - display.page.show_previous: bar_display
      - script.execute: update_all
