############################################
##                                        ##
##   filename: 1bar_1display.yaml         ##
##   description: Specific configuration  ##
##   for the 1 BAR 1 Display setup        ##
##                                        ##
############################################

packages: 
    base: !include base.yaml
    scripts: !include 1bar_1display_scripts.yaml

mcp23008:
  - id: 'base_J2'
    i2c_id: buttons
    address: 0x22
  - id: 'base_J3'
    i2c_id: buttons
    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:
  ############################
  ### Buttons Main Display ###
  ############################
  - platform: gpio
    id: 'main_display_btn_left'
    name: "Main Display button Left"
    pin: 
      mcp23xxx: base_J2
      number: 6
      mode: INPUT_PULLUP
      inverted: true
  - platform: gpio
    id: 'main_display_btn_right'
    name: "Main Display button Right"
    pin: 
      mcp23xxx: base_J2
      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_J3
      number: 6
      mode: INPUT_PULLUP
      inverted: true
  - platform: gpio
    id: 'bar1_btn_right'
    name: "BAR 1 button Right"
    pin: 
      mcp23xxx: base_J3
      number: 2
      mode: INPUT_PULLUP
      inverted: true

light:
  - id: !extend neopixels
    num_leds: 5
  ############################
  ### RGB LED's BAR module ###
  ############################
  - 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

output:
  - id: cs_pin_3
    platform: gpio
    pin:
      mcp23xxx: base_J3
      number: 5
      mode:
        output: true
      inverted: false
  - id: cs_pin_4
    platform: gpio
    pin:
      mcp23xxx: base_J3
      number: 1
      mode:
        output: true
      inverted: false

display:
  ####################
  ### Main Display ###
  ####################
  - id: main_display
    platform: ili9xxx
    model: ili9341
    color_order: rgb
    update_interval: 30s
    invert_colors: false
    dc_pin: 
      number: GPIO37
      allow_other_uses: true
    cs_pin: 
      mcp23xxx: base_J2
      number: 5
      mode:
        output: true
      inverted: false
    show_test_card: false
    dimensions: 
      height: 240
      width: 320
    rotation: 180
  ##################
  ### 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
    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
