M5Stack Dial - ESP32-S3 Smart Rotary Knob

I made some progress on LVGL component, and this is FASTEEEEEEEEEER than lambdas, and even look better to me!

Here's the LVGL code part (WIP):
lvgl:

  # -------------------------------------------------------------------- general
  displays:
    - my_display
  touchscreens:
    - my_touchscreen
  rotary_encoders:
    sensor: rotaryencoder
    enter_button: m5_button
  theme:
    obj:
      scrollbar_mode: "OFF"
      scrollable: false
      bg_color: pri_color
      border_width: 0
      border_color: orange_color
      radius: 10
    arc:
      arc_color: pri_color
      knob:
        bg_color: nova_color
      indicator:
        arc_color: dark_nova_color
    btn:
      bg_color: pri_color
      checked:
        bg_color: nova_color
    label:
      align: CENTER
      text_font: montserrat_18
      text_color: text_color
      clickable: false
  on_idle:
    timeout: !lambda "return (id(backlight_timeout).state * 1000);"
    then:
      - logger.log: "LVGL is idle"
      - light.turn_off: backlight
      - lvgl.pause:

  # ------------------------------------------------------------------ top layer
  top_layer:
    widgets:
      - obj:
          id: boot_screen
          width: SIZE_CONTENT 
          height: SIZE_CONTENT 
          bg_color: 0x000000
          bg_opa: COVER
          radius: 0
          pad_all: 0
          border_width: 0
          on_press:
            - lvgl.widget.hide: boot_screen
          widgets:

            - img:
                align: CENTER
                src: boot_logo
                y: -30

            - spinner:
                align: CENTER
                y: 70
                height: 50
                width: 50
                spin_time: 2s
                arc_length: 60deg
                arc_rounded: true
                arc_color: sec_color
                arc_width: 7
                indicator:
                  arc_color: blue_color
                  arc_width: 7

  # ---------------------------------------------------------------------- pages
  pages:
  
    # _____________________________________________________ page welcome
    - id: page_welcome
      <<: &page_config
        bg_color: sec_color
        scrollbar_mode: "OFF"
        scrollable: false
      widgets:
        # time
        - label:
            id: label_rtc_time
            align: TOP_MID
            text: "Heure"
            y: 5

        # date
        - label:
            id: label_rtc_date
            align: TOP_MID
            text_font: montserrat_16
            text: "Date"
            y: 28

        # MIDDLE_CONTAINER
        - obj:
            id: object_alarm_state
            align: BOTTOM_MID
            x: 0
            y: -150
            width: 250
            height: 36
            # clickable: true
            # on_press:
            #   - lvgl.page.show: page_alarm
            #   - homeassistant.service:
            #       service: input_select.select_option
            #       data:
            #         entity_id: $ha_page_selector
            #         option: page_alarm
            widgets:
              - label:
                  id: label_alarm_text
                  
                  text: "Alarme"
                  text_color: sec_color

        # LEFT_CONTAINER_1
        - obj:
            width: 150
            height: 95
            align: TOP_RIGHT
            x: -101
            y: 98
            widgets:

              ######################### COLUMN 01
              # garage
              - label:
                  id: icon_garage_state
                  <<: &icon_40_config
                    clickable: true
                    text_font: grandstander_40_regular
                    text: "x"
                  <<: &column_01
                    x: -60
                  <<: &row_01
                    align: TOP_RIGHT
                    y: -8
                  clickable: false
                  # on_long_press:
                  #   - <<: &bip
                  #       rtttl.play: 'one_short:d=32,o=4,b=900:a'

              # cargate
              - label:
                  id: icon_cargate_text
                  <<: *icon_40_config
                  <<: *column_01
                  <<: &row_02
                    align: BOTTOM_RIGHT
                    y: 2
                  clickable: false
                  # on_long_press:
                  #   - <<: *bip

              ######################### COLUMN 02
              # light
              - label:
                  id: icon_light_cour
                  <<: *icon_40_config
                  <<: &column_02
                    x: 0
                  <<: *row_01
                  on_long_press:
                    - <<: &bip
                        rtttl.play: 'one_short:d=24,o=5,b=100:g'
                    - homeassistant.service:
                        service: light.toggle
                        data:
                          entity_id: $ha_light_cour

              # handgate
              - label:
                  id: icon_handgate_text
                  <<: *icon_40_config
                  <<: *column_02
                  <<: *row_02
                  y: 4 # SPE handgate
                  on_long_press:
                    - <<: *bip
                    - homeassistant.service:
                        service: lock.unlock
                        data_template:
                          entity_id: lock.gate

        # LEFT_CONTAINER_2                          
        - obj:
            bg_opa: TRANSP
            border_opa: TRANSP
            width: 150
            height: 45
            align: TOP_RIGHT
            x: -100
            y: 195
            widgets:

              # outside temperature
              - label:
                  id: label_outside_temperature
                  x: 41
                  text_font: montserrat_20
                  text: "Temp"

              # meteo
              - label:
                  id: icon_weather_sensor
                  x: 41
                  text_font: grandstander_36_regular
                  text: "x"

        # RIGHT_1_CONTAINER
        - obj:
            bg_opa: TRANSP
            border_opa: TRANSP
            width: 110
            height: 45
            align: TOP_LEFT
            x: 147
            y: 98
            widgets:

              - label:
                  id: icon_front_door
                  <<: &icon_36_config
                    text_font: grandstander_36_regular
                    text: "x"
                  align: LEFT_MID
                  x: -5

              - label:
                  id: icon_window_group
                  <<: *icon_36_config
                  align: LEFT_MID
                  x: 40

        # RIGHT_2_CONTAINER
        - obj:
            width: 110
            height: 100
            align: TOP_LEFT
            x: 147
            y: 151
            on_long_press:
              - <<: *bip
              - lvgl.page.show: page_thermostat
              - homeassistant.service:
                  service: input_select.select_option
                  data:
                    entity_id: $ha_page_selector
                    option: page_thermostat
              - homeassistant.service:
                  service: climate.set_hvac_mode
                  data:
                    entity_id: $ha_climate_heating
                    hvac_mode: heat
            widgets:

              # temp
              - label:
                  id: label_climate_heating_current_0
                  y: -5
                  align: TOP_LEFT
                  text_font: montserrat_20
                  text: "Temp"

              # climate icon
              - label:
                  id: icon_climate_heating
                  align: TOP_LEFT
                  x: -3
                  y: 22
                  text_font: grandstander_32_regular
                  text: "x"
                    
    # __________________________________________________ page thermostat
    - id: page_thermostat
      <<: *page_config
      widgets:
        - meter:
            id: meter_climate_heating_target
            width: 210
            height: 210
            align: CENTER
            bg_opa: TRANSP
            border_width: 0
            text_color: text_color
            scales:
              range_from: 16 # = template_sensor, and arc values
              range_to: 24 # = template_sensor, and arc values
              angle_range: 250
              rotation: 145 # = arc start_angle
              ticks:
                count: 9
                width: 1
                length: 3
                color: sec_color
                major:
                  stride: 1
                  length: 1
                  color: dark_nova_color
                  label_gap: 18

        - arc:
            id: arc_climate_heating_target
            width: 210
            height: 210
            align: CENTER
            start_angle: 145 # = meter rotation value
            end_angle: 35
            min_value: 160 # idem meter range_from value * 10
            max_value: 240 # idem meter range_to value * 10
            adjustable: false

        - obj:
            id: button_climate_state_off
            align: CENTER
            width: 60
            height: 60
            radius: 60
            on_long_press:
              - <<: *bip
              - lvgl.page.show: page_welcome
              - homeassistant.service:
                  service: input_select.select_option
                  data:
                    entity_id: $ha_page_selector
                    option: page_welcome
              - homeassistant.service:
                  service: climate.set_hvac_mode
                  data:
                    entity_id: $ha_climate_heating
                    hvac_mode: "off"
            widgets:
              - label:
                  <<: *icon_36_config
                  text: "\U000F0425" # mdi:power

        - label:
            id: label_climate_heating_current_1
            text: ""
            y: 70
            text_font: montserrat_26

image
image

Have to work on the alarm page now.
EDIT : Done

6 Likes