Skip to content

Instantly share code, notes, and snippets.

@nazt
Created October 27, 2024 09:48
Show Gist options
  • Save nazt/ba86c9f891a86d21c6f1543a8548ebb4 to your computer and use it in GitHub Desktop.
Save nazt/ba86c9f891a86d21c6f1543a8548ebb4 to your computer and use it in GitHub Desktop.

Revisions

  1. @clydebarrow clydebarrow revised this gist Apr 5, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions t-embed.yaml
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Before asking any questions - read the docs!: https://deploy-preview-3510--esphome.netlify.app/components/lvgl.html

    esphome:
    name: t-embed
    friendly_name: LVGL Test on T-Embed
  2. @clydebarrow clydebarrow revised this gist Apr 4, 2024. No changes.
  3. @clydebarrow clydebarrow revised this gist Mar 12, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion t-embed.yaml
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ wifi: !include wifi.yaml

    external_components:
    - source: github://clydebarrow/esphome@lvgl
    components: [ rotary_encoder, ili9xxx, image, lvgl ]
    components: [ lvgl ]

    power_supply:
    - id: power_on
  4. @clydebarrow clydebarrow revised this gist Mar 12, 2024. 2 changed files with 122 additions and 89 deletions.
    7 changes: 7 additions & 0 deletions .gitignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@

    # Gitignore settings for ESPHome
    # This is an example and may include too much for your use-case.
    # You can modify this file to suit your needs.
    /.esphome/
    /secrets.yaml
    /wifi.yaml
    204 changes: 115 additions & 89 deletions t-embed.yaml
    Original file line number Diff line number Diff line change
    @@ -78,10 +78,6 @@ sensor:
    pin_b: 1
    internal: true

    time:
    - platform: sntp
    id: time_comp

    binary_sensor:
    - platform: gpio
    id: pushbutton
    @@ -91,6 +87,44 @@ binary_sensor:
    inverted: true
    ignore_strapping_warning: true

    time:
    - platform: sntp
    id: time_comp
    on_time_sync:
    then:
    - script.execute: time_update

    script:
    - id: time_update
    then:
    - lvgl.indicator.line.update:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    - lvgl.indicator.line.update:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    - lvgl.label.update:
    id: date_label
    text: !lambda |-
    static const char * const mon_names[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    static char date_buf[8];
    auto now = id(time_comp).now();
    snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[now.month-1], now.day_of_month);
    return date_buf;
    - lvgl.label.update:
    id: day_label
    text: !lambda |-
    static const char * const day_names[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    return day_names[id(time_comp).now().day_of_week-1];
    interval:
    - interval: 1min
    then:
    - script.execute: time_update

    lvgl:
    log_level: INFO
    rotary_encoders:
    @@ -110,95 +144,87 @@ lvgl:
    radius: 4
    pad_all: 2
    widgets:
    - meter:
    height: 160
    width: 160
    align: center
    bg_color: 0
    scales: # Color bars
    angle_range: 360
    rotation: 255
    range_from: 0
    range_to: 12
    ticks:
    width: 35
    count: 13
    length: 8
    indicators:
    - ticks:
    local: true
    start_value: 0
    end_value: 12
    color_start: 0xFF0000
    color_end: 0x0000FF
    - meter:
    height: 160
    width: 160
    align: center
    - obj: # Clock container
    height: size_content
    width: size_content
    widgets:
    - meter: # Gradient color arc
    height: 160
    width: 160
    align: center
    bg_color: 0
    scales:
    angle_range: 360
    rotation: 255
    range_from: 0
    range_to: 12
    ticks:
    width: 35
    count: 13
    length: 8
    indicators:
    - ticks:
    local: true
    start_value: 0
    end_value: 12
    color_start: 0xFF0000
    color_end: 0x0000FF
    - meter:
    height: 160
    width: 160
    align: center

    bg_opa: TRANSP
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0xFFFFFF
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    -
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    width: 4
    length: 8
    color: 0xC0C0C0
    label_gap: 6

    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - line:
    id: hour_hand
    width: 4
    color: 0xA0A0A0
    r_mod: -20
    - label:
    styles: date_style
    id: day_label
    y: -20
    text: !lambda |-
    static const char * const day_names[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    return day_names[id(time_comp).now().day_of_week-1];
    - label:
    id: date_label
    styles: date_style
    y: +20
    text: !lambda |-
    static const char * const mon_names[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    static char date_buf[8];
    auto now = id(time_comp).now();
    snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[now.month-1], now.day_of_month);
    return date_buf;
    bg_opa: TRANSP
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0xFFFFFF
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    -
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    width: 4
    length: 8
    color: 0xC0C0C0
    label_gap: 6

    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - line:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    width: 4
    color: 0xA0A0A0
    r_mod: -20

  5. @clydebarrow clydebarrow revised this gist Jan 26, 2024. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions t-embed.yaml
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    esphome:
    name: t-embed
    friendly_name: LVGL Test on T-Embed
    platformio_options:
    board_build.flash_mode: dio

    esp32:
    board: esp32-s3-devkitc-1
    variant: esp32s3
    framework:
    type: esp-idf
    version: 5.0.2
    platform_version: 6.3.2

    logger:
    level: DEBUG
    @@ -21,11 +21,11 @@ wifi: !include wifi.yaml

    external_components:
    - source: github://clydebarrow/esphome@lvgl
    components: [ lvgl, display, ili9xxx , image, power_supply, rotary_encoder ]
    components: [ rotary_encoder, ili9xxx, image, lvgl ]

    power_supply:
    - id: power_on
    enable_at_startup: true
    enable_on_boot: true
    pin:
    ignore_strapping_warning: true
    number: GPIO46
    @@ -51,13 +51,14 @@ light:

    display:
    - platform: ili9xxx
    id: lcd_display
    model: st7789v
    dimensions:
    height: 170
    width: 320
    offset_height: 35
    offset_width: 0
    rotation:
    transform:
    swap_xy: true
    mirror_x: false
    mirror_y: true
    @@ -67,7 +68,7 @@ display:
    reset_pin: GPIO9
    update_interval: never
    auto_clear_enabled: false
    invert_display: true
    invert_colors: true

    sensor:
    - platform: rotary_encoder
  6. @clydebarrow clydebarrow revised this gist Nov 20, 2023. 1 changed file with 72 additions and 75 deletions.
    147 changes: 72 additions & 75 deletions t-embed.yaml
    Original file line number Diff line number Diff line change
    @@ -20,8 +20,8 @@ ota:
    wifi: !include wifi.yaml

    external_components:
    # - source: github://clydebarrow/esphome@lvgl
    # components: [display, power_supply, ili9xxx, lvgl ]
    - source: github://clydebarrow/esphome@lvgl
    components: [ lvgl, display, ili9xxx , image, power_supply, rotary_encoder ]

    power_supply:
    - id: power_on
    @@ -108,8 +108,6 @@ lvgl:
    bg_opa: cover
    radius: 4
    pad_all: 2


    widgets:
    - meter:
    height: 160
    @@ -132,75 +130,74 @@ lvgl:
    end_value: 12
    color_start: 0xFF0000
    color_end: 0x0000FF
    widgets:
    - meter:
    height: 160
    width: 160
    align: center
    widgets:
    - label:
    styles: date_style
    y: -20
    text: !lambda |-
    static const char * const day_names[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    return day_names[id(time_comp).now().day_of_week-1];
    - label:
    styles: date_style
    y: +20
    text: !lambda |-
    static const char * const mon_names[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    static char date_buf[8];
    auto now = id(time_comp).now();
    snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[now.month-1], now.day_of_month);
    return date_buf;
    bg_opa: TRANSP
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0xFFFFFF
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    -
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    - meter:
    height: 160
    width: 160
    align: center
    widgets:
    - label:
    styles: date_style
    y: -20
    text: !lambda |-
    static const char * const day_names[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    return day_names[id(time_comp).now().day_of_week-1];
    - label:
    styles: date_style
    y: +20
    text: !lambda |-
    static const char * const mon_names[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    static char date_buf[8];
    auto now = id(time_comp).now();
    snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[now.month-1], now.day_of_month);
    return date_buf;
    bg_opa: TRANSP
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0xFFFFFF
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    -
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    width: 4
    length: 8
    color: 0xC0C0C0
    label_gap: 6

    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - line:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    width: 4
    length: 8
    color: 0xC0C0C0
    label_gap: 6

    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - line:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    width: 4
    color: 0xA0A0A0
    r_mod: -20
    color: 0xA0A0A0
    r_mod: -20
  7. @clydebarrow clydebarrow revised this gist Nov 20, 2023. 1 changed file with 104 additions and 131 deletions.
    235 changes: 104 additions & 131 deletions t-embed.yaml
    Original file line number Diff line number Diff line change
    @@ -20,8 +20,8 @@ ota:
    wifi: !include wifi.yaml

    external_components:
    - source: github://clydebarrow/esphome@lvgl
    components: [ ili9xxx, lvgl ]
    # - source: github://clydebarrow/esphome@lvgl
    # components: [display, power_supply, ili9xxx, lvgl ]

    power_supply:
    - id: power_on
    @@ -49,10 +49,6 @@ light:
    restore_mode: ALWAYS_ON
    default_transition_length: 0s

    time:
    - platform: sntp
    id: time_comp

    display:
    - platform: ili9xxx
    model: st7789v
    @@ -65,7 +61,6 @@ display:
    swap_xy: true
    mirror_x: false
    mirror_y: true
    color_order: bgr
    data_rate: 80MHz
    cs_pin: 10
    dc_pin: GPIO13
    @@ -80,6 +75,11 @@ sensor:
    id: encoder
    pin_a: 2
    pin_b: 1
    internal: true

    time:
    - platform: sntp
    id: time_comp

    binary_sensor:
    - platform: gpio
    @@ -98,136 +98,109 @@ lvgl:
    group: general
    color_depth: 16
    bg_color: 0x0F0F0F
    text_font: unscii_8
    align: center
    style_definitions:
    - id: date_style
    text_font: unscii_8
    align: center
    text_color: 0x000000
    bg_opa: cover
    radius: 4
    pad_all: 2


    widgets:
    - meter:
    height: 160
    width: 160
    align: center
    widgets:
    - label:
    text_font: unscii_8
    align: center
    y: -20
    text_color: 0x000000
    text: 'SUN'
    bg_color: 0xFFFFFF
    bg_opa: cover
    - label:
    text_font: unscii_8
    align: center
    y: +20
    text_color: 0x000000
    text: '19 NOV'
    bg_color: 0xFFFFFF
    bg_opa: cover
    bg_color: 0
    text_font: unscii_8
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0x0
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    - ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    width: 4
    length: 8
    color: 0x0C0C0C
    label_gap: 6
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - arc:
    start_value: 0
    end_value: 60
    width: 8
    color: 0xE00000
    - arc:
    start_value: 60
    end_value: 120
    width: 8
    color: 0xE0B000
    - arc:
    start_value: 120
    end_value: 180
    width: 8
    color: 0xFFFF80
    - arc:
    start_value: 180
    end_value: 240
    width: 8
    color: 0xF0F0F0
    - arc:
    start_value: 240
    end_value: 300
    width: 8
    color: 0xE0E0FF
    - arc:
    start_value: 300
    end_value: 360
    width: 8
    color: 0xC0C0FF
    - arc:
    start_value: 360
    end_value: 420
    width: 8
    color: 0xB0B0FF
    - arc:
    start_value: 420
    end_value: 480
    width: 8
    color: 0x9090FF
    - arc:
    start_value: 480
    end_value: 540
    width: 8
    color: 0x7070FF
    - arc:
    start_value: 540
    end_value: 600
    width: 8
    color: 0x6060FF
    - arc:
    start_value: 600
    end_value: 660
    width: 8
    color: 0x4040FF
    - arc:
    start_value: 660
    end_value: 720
    width: 8
    color: 0xE080FF
    - line:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    scales: # Color bars
    angle_range: 360
    rotation: 255
    range_from: 0
    range_to: 12
    ticks:
    width: 35
    count: 13
    length: 8
    indicators:
    - ticks:
    local: true
    start_value: 0
    end_value: 12
    color_start: 0xFF0000
    color_end: 0x0000FF
    widgets:
    - meter:
    height: 160
    width: 160
    align: center
    widgets:
    - label:
    styles: date_style
    y: -20
    text: !lambda |-
    static const char * const day_names[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    return day_names[id(time_comp).now().day_of_week-1];
    - label:
    styles: date_style
    y: +20
    text: !lambda |-
    static const char * const mon_names[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
    static char date_buf[8];
    auto now = id(time_comp).now();
    snprintf(date_buf, sizeof(date_buf), "%s %2d", mon_names[now.month-1], now.day_of_month);
    return date_buf;
    bg_opa: TRANSP
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0xFFFFFF
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    -
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    width: 4
    color: 0xA0A0A0
    r_mod: -20
    length: 8
    color: 0xC0C0C0
    label_gap: 6

    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - line:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    width: 4
    color: 0xA0A0A0
    r_mod: -20
  8. @clydebarrow clydebarrow renamed this gist Nov 19, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. @clydebarrow clydebarrow created this gist Nov 19, 2023.
    233 changes: 233 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,233 @@
    esphome:
    name: t-embed
    friendly_name: LVGL Test on T-Embed

    esp32:
    board: esp32-s3-devkitc-1
    variant: esp32s3
    framework:
    type: esp-idf
    version: 5.0.2
    platform_version: 6.3.2

    logger:
    level: DEBUG
    hardware_uart: USB_SERIAL_JTAG

    ota:
    password: !secret ota_password

    wifi: !include wifi.yaml

    external_components:
    - source: github://clydebarrow/esphome@lvgl
    components: [ ili9xxx, lvgl ]

    power_supply:
    - id: power_on
    enable_at_startup: true
    pin:
    ignore_strapping_warning: true
    number: GPIO46

    spi:
    clk_pin: GPIO12
    mosi_pin: GPIO11
    interface: hardware

    output:
    - platform: ledc
    pin:
    number: GPIO15
    id: backlight_output

    light:
    - platform: monochromatic
    output: backlight_output
    name: LCD Backlight
    id: led
    restore_mode: ALWAYS_ON
    default_transition_length: 0s

    time:
    - platform: sntp
    id: time_comp

    display:
    - platform: ili9xxx
    model: st7789v
    dimensions:
    height: 170
    width: 320
    offset_height: 35
    offset_width: 0
    rotation:
    swap_xy: true
    mirror_x: false
    mirror_y: true
    color_order: bgr
    data_rate: 80MHz
    cs_pin: 10
    dc_pin: GPIO13
    reset_pin: GPIO9
    update_interval: never
    auto_clear_enabled: false
    invert_display: true

    sensor:
    - platform: rotary_encoder
    name: "Rotary Encoder"
    id: encoder
    pin_a: 2
    pin_b: 1

    binary_sensor:
    - platform: gpio
    id: pushbutton
    name: Pushbutton
    pin:
    number: 0
    inverted: true
    ignore_strapping_warning: true

    lvgl:
    log_level: INFO
    rotary_encoders:
    sensor: encoder
    binary_sensor: pushbutton
    group: general
    color_depth: 16
    bg_color: 0x0F0F0F
    align: center
    widgets:
    - meter:
    height: 160
    width: 160
    align: center
    widgets:
    - label:
    text_font: unscii_8
    align: center
    y: -20
    text_color: 0x000000
    text: 'SUN'
    bg_color: 0xFFFFFF
    bg_opa: cover
    - label:
    text_font: unscii_8
    align: center
    y: +20
    text_color: 0x000000
    text: '19 NOV'
    bg_color: 0xFFFFFF
    bg_opa: cover
    bg_color: 0
    text_font: unscii_8
    text_color: 0xFFFFFF
    scales:
    - ticks:
    width: 1
    count: 61
    length: 10
    color: 0x0
    range_from: 0
    range_to: 60
    angle_range: 360
    rotation: 270
    indicators:
    - line:
    id: minute_hand
    value: !lambda |-
    return id(time_comp).now().minute;
    width: 3
    color: 0xE0E0E0
    r_mod: -1

    - ticks:
    width: 1
    count: 12
    length: 1
    major:
    stride: 1
    width: 4
    length: 8
    color: 0x0C0C0C
    label_gap: 6
    angle_range: 330
    rotation: 300
    range_from: 1
    range_to: 12
    - angle_range: 360
    rotation: 270
    range_from: 0
    range_to: 720
    indicators:
    - arc:
    start_value: 0
    end_value: 60
    width: 8
    color: 0xE00000
    - arc:
    start_value: 60
    end_value: 120
    width: 8
    color: 0xE0B000
    - arc:
    start_value: 120
    end_value: 180
    width: 8
    color: 0xFFFF80
    - arc:
    start_value: 180
    end_value: 240
    width: 8
    color: 0xF0F0F0
    - arc:
    start_value: 240
    end_value: 300
    width: 8
    color: 0xE0E0FF
    - arc:
    start_value: 300
    end_value: 360
    width: 8
    color: 0xC0C0FF
    - arc:
    start_value: 360
    end_value: 420
    width: 8
    color: 0xB0B0FF
    - arc:
    start_value: 420
    end_value: 480
    width: 8
    color: 0x9090FF
    - arc:
    start_value: 480
    end_value: 540
    width: 8
    color: 0x7070FF
    - arc:
    start_value: 540
    end_value: 600
    width: 8
    color: 0x6060FF
    - arc:
    start_value: 600
    end_value: 660
    width: 8
    color: 0x4040FF
    - arc:
    start_value: 660
    end_value: 720
    width: 8
    color: 0xE080FF
    - line:
    id: hour_hand
    value: !lambda |-
    auto now = id(time_comp).now();
    return std::fmod(now.hour, 12) * 60 + now.minute;
    width: 4
    color: 0xA0A0A0
    r_mod: -20