Help making ESP32-3248S035 work

Hi all,

I recently bought ESP32-3248S035 (https://tinyurl.com/nwttm4xw) and trying to get the right configuration to get it up and running (screen/touch).

Did anyone have any success in that?

Thank you so much!

Try Googling the board name and doing some digging. This page platformio-espressif32-sunton/esp32-3248S035C.json at 59ec63edd07c4d5d75d5b1e46083c2ab6446ab46 · rzeldent/platformio-espressif32-sunton · GitHub suggests that’s an ST7796 display driver, which is supported by the ili9xxx ESPHome component, so you just need to set up the correct pins for SPI and the display control lines.

There is no PSRAM so it’s unlikely the ESPHome display drawing functions will work, but LVGL with a 25% buffer_size should be ok.

The capacitive touch version appears to use a GT911 which is also supported in ESPHome.

There is some info here, and it does say they have psram. ESP32-3248S035 - openHASP

That page says 8MB PSRAM at the top, but later in 2 places it says no PSRAM.

1 Like

Thanks for the help, I’ve tried setting the configuration, and get the following:

[23:40:00][C][logger:185]: Logger:
[23:40:00][C][logger:186]:   Level: DEBUG
[23:40:00][C][logger:188]:   Log Baud Rate: 115200
[23:40:00][C][logger:189]:   Hardware UART: UART0
[23:40:00][C][spi:068]: SPI bus:
[23:40:00][C][spi:069]:   CLK Pin: GPIO14
[23:40:00][C][spi:070]:   SDI Pin: GPIO12
[23:40:00][C][spi:071]:   SDO Pin: GPIO13
[23:40:00][C][spi:076]:   Using HW SPI: SPI
[23:40:00][C][spi:068]: SPI bus:
[23:40:00][C][spi:069]:   CLK Pin: GPIO18
[23:40:00][C][ledc.output:181]:   Bit depth: 16
[23:40:00][C][ledc.output:176]: LEDC Output:
[23:40:00][C][ledc.output:177]:   Pin GPIO4
[23:40:00][C][ledc.output:178]:   LEDC Channel: 1
[23:40:00][C][ledc.output:179]:   PWM Frequency: 1000.0 Hz
[23:40:00][C][ledc.output:180]:   Phase angle: 0.0°
[23:40:00][C][ledc.output:181]:   Bit depth: 16
[23:40:00][C][ledc.output:176]: LEDC Output:
[23:40:00][C][ledc.output:177]:   Pin GPIO16
[23:40:00][C][ledc.output:178]:   LEDC Channel: 2
[23:40:00][C][ledc.output:179]:   PWM Frequency: 1000.0 Hz
[23:40:00][C][ledc.output:180]:   Phase angle: 0.0°
[23:40:00][C][ledc.output:181]:   Bit depth: 16
[23:40:00][C][ledc.output:176]: LEDC Output:
[23:40:00][C][ledc.output:177]:   Pin GPIO17
[23:40:00][C][ili9xxx:094]:   Dimensions: 320px x 480px
[23:40:00][C][ili9xxx:095]:   Width Offset: 0
[23:40:00][C][ili9xxx:105]:   Color mode: 8bit 332 mode
[23:40:00][C][ili9xxx:111]:   Data rate: 40MHz
[23:40:00][C][ili9xxx:114]:   CS Pin: GPIO15
[23:40:00][C][ili9xxx:115]:   DC Pin: GPIO2
[23:40:00][C][ili9xxx:117]:   Color order: BGR
[23:40:00][C][ili9xxx:118]:   Swap_xy: NO
[23:40:00][C][ili9xxx:119]:   Mirror_x: YES
[23:40:00][C][ili9xxx:120]:   Mirror_y: NO
[23:40:00][C][ili9xxx:123]:   => Failed to init Memory: YES!
[23:40:00][C][ili9xxx:125]:   Update Interval: 1.0s
[23:40:00][E][component:082]:   Component display is marked FAILED
[23:40:00][C][light:103]: Light 'LED'
[23:40:00][C][light:105]:   Default Transition Length: 1.0s
[23:40:00][C][light:106]:   Gamma Correct: 2.80
[23:40:00][C][esp32_improv.component:261]: ESP32 Improv:
[23:40:00][C][esp32_improv.component:266]:   Status Indicator: 'NO'
[23:40:00][C][captive_portal:088]: Captive Portal:
[23:40:00][C][web_server:173]: Web Server:
[23:40:00][C][web_server:174]:   Address: esphome-web-4560ec.local:80
[23:40:00][C][mdns:115]: mDNS:
[23:40:00][C][mdns:116]:   Hostname: esphome-web-4560ec
[23:40:00][C][esphome.ota:073]: Over-The-Air updates:
[23:40:00][C][esphome.ota:074]:   Address: esphome-web-4560ec.local:3232
[23:40:00][C][esphome.ota:075]:   Version: 2
[23:40:00][C][safe_mode:018]: Safe Mode:
[23:40:00][C][api:140]:   Address: esphome-web-4560ec.local:6053

The configuration I’m using is:

spi:
  - id: tft
    clk_pin: GPIO14
    mosi_pin: GPIO13
    miso_pin: GPIO12
  - id: touch
    clk_pin: GPIO18
    mosi_pin: GPIO23
    miso_pin: GPIO19

display:
  - platform: ili9xxx
    model: ST7796
    cs_pin: GPIO15
    dc_pin: GPIO2
    spi_id: tft

Any thoughts what I still might be missing?

Thanks!

Yes, you are right, that needs fixing doesn’t it, and careful reading.

Like I said, it won’t work with the standard display operations due to insufficient memory. You’ll need update_interval: never and auto_clear_enabled: false then use LVGL - LVGL implementation for ESPHome by clydebarrow · Pull Request #6363 · esphome/esphome · GitHub - read the docs linked there and make sure to set buffer_size: 25%

Also best to log via UART so you capture all the messages after startup.

I struggled getting this to work as well, but it works fine with Openhasp if you want it to just work. I’ve realised I’m not a big fan of that software though and I also plan to add some controls to the device which would be easier using Esphome.

[edit]: I forgot to change the buffer size, now it works!

So I tried @clydebarrow’s suggestions and that works. I used the following yaml for a hello world example:

esphome:
  name: tv-controller
  friendly_name: TV-controller

external_components:
  - source: github://pr#6363
    refresh: 10min
    components: [lvgl]

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: "xxx"

ota:
  platform: esphome
  password: "xxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

i2c:
  sda: 33
  scl: 32
  scan: true
  id: bus_a

spi:
  clk_pin: 14
  mosi_pin: 13
  miso_pin: 12

light:
  - platform: rgb
    name: "Status Light"
    red: red_GPIO
    green: green_GPIO
    blue: blue_GPIO
  - platform: monochromatic
    output: backlight_pin
    name: "Display Backlight"
    id: back_light
    restore_mode: ALWAYS_ON

output:
  - platform: ledc
    pin: 4
    id: red_GPIO
    inverted: True
  - platform: ledc
    pin: 16
    id: green_GPIO
    inverted: True
  - platform: ledc
    pin: 17
    id: blue_GPIO
    inverted: True
  - platform: ledc
    pin: 27
    id: backlight_pin


display:
  - platform: ili9xxx
    id: my_display
    model: ST7796
    dc_pin: 2
    cs_pin: 15
    dimensions: 320x480
    update_interval: never
    auto_clear_enabled: false

touchscreen:
  platform: gt911
  id: my_touch
  update_interval: 50ms
#  interrupt_pin: 21 # maybe not connected?
#  reset_pin: 25 # From a openhasp config, appears to be the 'normal' esp32 reset pin?

color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%

# font:
#   - file: "gfonts://Martian+Mono"
#     id: large
#     size: 40
#   - file: "gfonts://Martian+Mono"
#     id: small
#     size: 20

lvgl:
  touchscreens:
    - my_touch
  buffer_size: 25%
  pages:
    - id: main_page
      widgets:
        - label:
            align: CENTER
            text: 'Hello World!'

Yatush,

I was having all sorts of problems with the ESP32-3248S035C until I happened on the Annex RDS site and after that (if you know BASIC) it is easy - it does all the hard work for you just set the Config to ESP32-3248S035C and voila. The Annex RDS puts the BASIC in the chip and uses your WiFi to communicate with it.

Starraker

For all attempting to use the ESP32-3248S035C (or ESP32-3248S035R)

For Touch on these boards the following applies (GPIO Pins):

Resistive Touch : INT = 36, SCLK = 14, MOSI = 13, MISO =12, CS = 33 (XPT2046)

Capacitative Touch: INT = 21, SCL = 32, SDA = 33, RST = 25 (GT911)

The Resistive Touch needs to align the touchscreen before it can be used whereas the Capacitive Touch does not need this Step as it is prealigned.

LED1 has three GPIO pins : RED = 4, GREEN = 16, BLUE = 17

BACKLIGHT = GPIO 27

AUDIO AMP : GPIO 26 - Careful when using a speaker an 8 ohm speaker needs to have a series resistor to prevent overloading the amp.

GPIO 39 is unwired but can still be used

Careful with Capacitive Touch - pin 21 has two other definitions (min)

SCREEN SPI: DC = 2, SCLK = 14, MOSI = 13, MISO = 12, CS = 15 RST = EN(-1) - Please note the Screen SPI and Resistive Touch share SCLK, MOSI, & MISO

This board does not act like other ESP32 boards as many of the pins are hard wired and predefined. However , If you prefer easier manipulation / programming of this board go to Annex 32 Rapid Development Suite and use the BASIC Language where this board and its large number of capabilities are all accessible.

This is great board have fun.

I hope that this helps

1 Like

Hello,
Thanks for your valuable input, I got the display to work but have no contact at all to the touch functionality.

It does not output anything to the log when touching the screen and it does not react, og clicking a button.

This is not a hardware issue as it worked fine with default sw.

I wonder what I am missing.

Here is the relevant config part


i2c:
  sda: GPIO33
  scl: GPIO32
  scan: true
  id: bus_a

touchscreen:
  - platform: gt911
    id: my_touch
    display: my_display
    interrupt_pin: GPIO21
#   reset_pin: GPIO25
#   i2c_id: bus_a
#   address: 0x5D
    update_interval: 50ms

    on_touch: 
      - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%0d, y_raw=%d",
            touch.x,
            touch.y,
            touch.x_raw,
            touch.y_raw
            );
      - light.turn_on: 
          id: backlight
          brightness: 100%
    on_release:
      then:
        - if:
            condition: lvgl.is_paused
            then:
              - lvgl.resume:
              - lvgl.widget.redraw:

lvgl:
  displays:
    - my_display
  touchscreens:
    - my_touch
  buffer_size: 25%
  color_depth: 16
  bg_color: room_bg_color #0
  pad_all: 0
  border_width: 0
  border_color: HA_blue
  outline_width: 0
  shadow_width: 0
  text_font: font_s
  align: center
  style_definitions:
    - id: default_style      # choose an ID for your definition
      border_color: default_border_color
      border_width: 0
      align: CENTER
      text_align: CENTER
  pages:
    - id: main_page
      pad_all: 0
      widgets:
        - obj:
            width: 480
            height: 320
            layout:
              type: grid
              grid_row_align: end
              grid_columns: [fr(1)]
              grid_rows: [fr(1), fr(2),fr(2),fr(2), fr(1)]
              pad_row: 0px
              pad_column: 0px
            pad_all: 0px
            outline_pad: 0px
            widgets:
              - label:
                  id: lbl_header
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 0
                  grid_cell_x_align: CENTER
                  grid_cell_y_align: CENTER
                  styles: default_style
                  text_font: font_l
                  pad_all: 0px
                  outline_pad: 0px
                  text: "Hello World"
              - button:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 1
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
                  id: my_main_climate2
                  pad_all: 0px
                  outline_pad: 0px
                  bg_color: default_button_bg_color
                  bg_grad_color: default_button_bg_grad_color
                  widgets:
                    - label:
                        id: my_main_climate2_target
                        text: "Test touch"
                        text_font: font_xs
                  on_click:
                    then:
                      - lvgl.label.update:
                          id: lbl_header
                          text: "Button pushed"

By the way, I am not able to set the RST pin for the touch. when compiling I get the error:

  [reset_pin] is an invalid option for [touchscreen.gt911]. Please check the indentation.

Update your ESPHome version. reset_pin is valid, and is important. Check the serial logs for errors relating to the touchscreen and i2c.

Hi @clydebarrow,

Thanks for your input.

I updated to latest HA and ESPHome, then I was allowed to set the reset_pin. But it did not fix my problem.

After several trials, It started working when I removed the interrupt_pin.
Then I ended up removing both interrupt and reset pin as in @sophof example and it still works.

So, maybe there is an issue with Pin 21 (the interrupt pint) as it is used by other things as @Starraker1 mentioned “Careful with Capacitive Touch - pin 21 has two other definitions (min)”

Finally, I did not use github://pr#6363, as LVGL is natively supported by ESPHome now.

So, now it looks like I have the basics to work, then I go further with custom configuration to my use case.

Thanks :blush:

so how do we define both LCD and resistive touchscreen in esphome project?

figured: we shall assign same spi_id to both

Would you mind sharing your code if you have a working version?

1 Like

Hi @TommySharpNZ ,
Yes I got it to work and here is a full working version:

esphome:
  name: display3-5
  friendly_name: display3_5

esp32:
  board: esp32dev
  framework:
    type: arduino #esp-idf #

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${Myfriendly_name}
    password: !secret ap_password

captive_portal:
    
color:   
  - id: room_bg_color
    hex: CCFFCC #lygrøn
  - id: room_image_color
    hex: ff3399 #4d30ed #03a9f4 #4D30ED #mørkeblå
  - id: room_image_bg_color
    hex: ff4e03 #FF4E03 #mørke orange
  - id: room_image_bg_grad_color
    hex: FFFF00 #lys gul
#Generik colors
  - id: HA_blue
    hex: 03a9f4
  - id: color_grey
    hex: D1D0CE
  - id: color_dark_grey
    hex: A0A0A0

  - id: default_border_color
    hex: FF0000
  - id: default_button_text_color
    hex: FFFFFF
  - id: sub_page_border_color
    hex: FFFFFF
  - id: sub_page_button_border_color
    hex: FFFFFF
  - id: default_button_bg_color
    hex: 2F8CD8
  - id: default_button_check_bg_color
    hex: 1d5f96
  - id: default_button_check_bg_grad_color
    hex: 03324A
  - id: default_button_check_text_color
    hex: fff300
  - id: sub_page_footer_pressed_button_bg_color
    hex: FFFF00
  - id: default_button_pressed_bg_color
    hex: 006699
  - id: default_button_pressed_bg_grad_color
    hex: 00334d
  - id: default_button_bg_grad_color
    hex: 005782
  - id: default_button_border_color
    hex: 0077b3

font:
  - file: "gfonts://Roboto"
    id: font_xs
    size: 20
  - file: "gfonts://Roboto"
    id: font_s
    size: 25 
  - file: "gfonts://Roboto"
    id: font_m
    size: 35
  - file: "gfonts://Roboto"
    id: font_l
    size: 55
  - file: "gfonts://Roboto"
    id: font_xl
    size: 70

output:
  - platform: ledc
    pin: GPIO27
    id: backlight_pwm

  - platform: ledc
    pin: GPIO4
    id: led_red
    inverted: true

  - platform: ledc
    pin: GPIO16
    id: led_green
    inverted: true

  - platform: ledc
    pin: GPIO17
    id: led_blue
    inverted: true

light:
  - platform: monochromatic
    output: backlight_pwm
    name: '"Display Backlight"'
    id: backlight
    restore_mode: ALWAYS_ON
    internal: True
    on_turn_on:
      then:
        - light.turn_on:
            id: backlight
            brightness: 75%
            red: 100%
            green: 100%
            blue: 100%

  - platform: rgb
    name: "Rear LED"
    id: rear_led
    restore_mode: ALWAYS_OFF
    red: led_red
    green: led_green
    blue: led_blue
    internal: True

spi:
  - id: spi_tft
    clk_pin: GPIO14
    mosi_pin: GPIO13
    miso_pin: GPIO12

display:
  - platform: ili9xxx  
    id: my_display
    model: ST7796
    spi_id: spi_tft
    dc_pin: GPIO2
    cs_pin: GPIO15
    dimensions: 
      width: 480
      height: 320
    data_rate: 80MHz   #40MHz
    color_order: RGB
    invert_colors: false
    update_interval: never
    auto_clear_enabled: false
    show_test_card: false     
    transform:
      swap_xy: true 
      mirror_y: false
      mirror_x: false

i2c:
  id: bus_a
  sda: 33
  scl: 32
  scan: true

touchscreen:
  - platform: gt911  #xpt2046
    id: my_touch
    display: my_display
#    reset_pin: 25
#    interrupt_pin: GPIO21
#    threshold: 400

    i2c_id: bus_a
    update_interval: 50ms
    transform:
      swap_xy: true
      mirror_x: true
      mirror_y: false

    on_touch: 
      - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%0d, y_raw=%d",
            touch.x,
            touch.y,
            touch.x_raw,
            touch.y_raw
            );
      - light.turn_on: 
          id: backlight
          brightness: 100%
    on_release:
      then:
        - if:
            condition: lvgl.is_paused
            then:
              - lvgl.resume:
              - lvgl.widget.redraw:
        - delay: 10s
        - light.control: 
            id: backlight
            brightness: 50%
        - delay: 5s
        - light.control: 
            id: backlight
            brightness: 5%


lvgl:
  displays:
    - my_display
  touchscreens:
    - my_touch
  buffer_size: 25%
  color_depth: 16
  bg_color: room_bg_color #0
  pad_all: 0
  border_width: 0
  border_color: HA_blue
  outline_width: 0
  shadow_width: 0
  text_font: font_s
  align: center
  style_definitions:
    - id: default_style      # choose an ID for your definition
      border_color: default_border_color
      border_width: 0
      align: CENTER
      text_align: CENTER
  pages:
    - id: main_page
      pad_all: 0
      widgets:
        - obj:
            width: 480
            height: 320
            layout:
              type: grid
              grid_row_align: end
              grid_columns: [fr(1), fr(1)]
              grid_rows: [fr(1), fr(2),fr(2),fr(2), fr(1)]
#              pad_row: 0px
#              pad_column: 0px
            pad_all: 0px
            outline_pad: 0px
            widgets:
              - label:
                  id: lbl_header
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 1
                  grid_cell_x_align: CENTER
                  grid_cell_y_align: CENTER
                  styles: default_style
                  text_font: font_m
                  pad_all: 0px
                  outline_pad: 0px
                  text: "Hello World"
              - button:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 2
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
                  id: my_main_climate2
                  pad_all: 0px
                  outline_pad: 0px
                  bg_color: default_button_bg_color
                  bg_grad_color: default_button_bg_grad_color
                  widgets:
                    - label:
                        id: my_main_climate2_target
                        text: "Test touch"
                        text_font: font_m
                        align: center
                  on_click:
                    then:
                      - lvgl.label.update:
                          id: lbl_header
                          text: "Button pushed"
              - dropdown:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 3
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
                  id: dropdown_id
                  width: 90
                  align: CENTER
                  options:
                    - Violin
                    - Piano
                    - Bassoon
                    - Chello
                    - Drums
                  selected_index: 2
                  dropdown_list:
                    selected:
                      checked:
                        text_color: 0xFF0000

Please let me know if you have any question

/Ghassan

Tommy,
Just noticed your question. I only check with this forum about once or twice a month

Happy to share but I mainly write in Annex32 RDS Basic these days - more powerful and much much quicker to program in. If you are still interested join the Annex RDS Forum (free to join) where I have placed the code already.

Since I have placed the code on this forum all sorts of improvement has taken place in the underlying BASIC including full support for the ESP32-3248S035C and R and many other screen based modules. If I see you there you can ask any questions.

I get an error when I try to install this with my display:

xtensa-esp32-elf-g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
*** [.pioenvs/display3-5/src/main.cpp.o] Error 1

ChatGPT says this is a RAM error, but I’m not sure of a way around it. Any thoughts?

Ok, I’ve made progress.

For reference, I’m using this board: Board: Amazon.com: AITRIP 1PACK 3.5" inch ESP-32 ESP32S ESP32 Display ESP-WROOM-32 Resistive Touch Screen TFT LCD Module 320x480 ST7796 ESP32-3248S035C Development Board for Arduino IDE : Electronics

Info: 3.5inch ESP32-32E Display - LCD wiki

Anyway, my current configuration is below. It works, but no entities show up in HA. I had to modify @ghassan 's code as my display is a resistive touchscreen, not capacitive.

esphome:
  name: display3-5
  friendly_name: display3_5

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:

api:
  encryption:
    key: !secret api_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: ${Myfriendly_name}
    password: !secret ap_password

captive_portal:

color:
  - id: room_bg_color
    hex: CCFFCC
  - id: room_image_color
    hex: ff3399
  - id: room_image_bg_color
    hex: ff4e03
  - id: room_image_bg_grad_color
    hex: FFFF00
  - id: HA_blue
    hex: 03a9f4
  - id: color_grey
    hex: D1D0CE
  - id: color_dark_grey
    hex: A0A0A0
  - id: default_border_color
    hex: FF0000
  - id: default_button_text_color
    hex: FFFFFF
  - id: sub_page_border_color
    hex: FFFFFF
  - id: sub_page_button_border_color
    hex: FFFFFF
  - id: default_button_bg_color
    hex: 2F8CD8
  - id: default_button_check_bg_color
    hex: 1d5f96
  - id: default_button_check_bg_grad_color
    hex: 03324A
  - id: default_button_check_text_color
    hex: fff300
  - id: sub_page_footer_pressed_button_bg_color
    hex: FFFF00
  - id: default_button_pressed_bg_color
    hex: 006699
  - id: default_button_pressed_bg_grad_color
    hex: 00334d
  - id: default_button_bg_grad_color
    hex: 005782
  - id: default_button_border_color
    hex: 0077b3

font:
  - file: "gfonts://Roboto"
    id: font_xs
    size: 20
  - file: "gfonts://Roboto"
    id: font_s
    size: 25
  - file: "gfonts://Roboto"
    id: font_m
    size: 35
  - file: "gfonts://Roboto"
    id: font_l
    size: 55
  - file: "gfonts://Roboto"
    id: font_xl
    size: 70

output:
  - platform: ledc
    pin: GPIO27
    id: backlight_pwm

  - platform: ledc
    pin: GPIO22
    id: led_red
    inverted: true

  - platform: ledc
    pin: GPIO16
    id: led_green
    inverted: true

  - platform: ledc
    pin: GPIO17
    id: led_blue
    inverted: true

light:
  - platform: monochromatic
    output: backlight_pwm
    name: '"Display Backlight"'
    id: backlight
    restore_mode: ALWAYS_ON
    internal: True

  - platform: rgb
    name: "Rear LED"
    id: rear_led
    restore_mode: ALWAYS_OFF
    red: led_red
    green: led_green
    blue: led_blue
    internal: true

spi:
  - id: spi_tft
    clk_pin: GPIO14
    mosi_pin: GPIO13
    miso_pin: GPIO12

display:
  - platform: ili9xxx
    id: my_display
    model: ST7796
    spi_id: spi_tft
    dc_pin: GPIO2
    cs_pin: GPIO15
    dimensions:
      width: 480
      height: 320
    data_rate: 80MHz
    color_order: RGB
    invert_colors: false
    update_interval: never
    auto_clear_enabled: false
    show_test_card: false
    transform:
      swap_xy: true
      mirror_y: false
      mirror_x: false

touchscreen:
  - platform: xpt2046
    id: my_touch
    display: my_display
    spi_id: spi_tft
    cs_pin: GPIO33
    interrupt_pin: GPIO36
    update_interval: 50ms
    transform:
      swap_xy: true
      mirror_x: true
      mirror_y: false
    calibration:
      x_min: 200
      x_max: 3900
      y_min: 200
      y_max: 3900
    on_release:
      then:
        - if:
            condition: lvgl.is_paused
            then:
              - lvgl.resume:
              - lvgl.widget.redraw:

lvgl:
  displays:
    - my_display
  touchscreens:
    - my_touch
  buffer_size: 25%
  color_depth: 16
  bg_color: room_bg_color
  pad_all: 0
  border_width: 0
  border_color: HA_blue
  outline_width: 0
  shadow_width: 0
  text_font: font_s
  align: center
  style_definitions:
    - id: default_style
      border_color: default_border_color
      border_width: 0
      align: CENTER
      text_align: CENTER
  pages:
    - id: main_page
      pad_all: 0
      widgets:
        - obj:
            width: 480
            height: 320
            layout:
              type: grid
              grid_row_align: end
              grid_columns: [fr(1), fr(1)]
              grid_rows: [fr(1), fr(2), fr(2), fr(2), fr(1)]
            pad_all: 0px
            outline_pad: 0px
            widgets:
              - label:
                  id: lbl_header
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 1
                  grid_cell_x_align: CENTER
                  grid_cell_y_align: CENTER
                  styles: default_style
                  text_font: font_m
                  pad_all: 0px
                  outline_pad: 0px
                  text: "Hello World"
              - button:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 2
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
                  id: my_main_climate2
                  pad_all: 0px
                  outline_pad: 0px
                  bg_color: default_button_bg_color
                  bg_grad_color: default_button_bg_grad_color
                  widgets:
                    - label:
                        id: my_main_climate2_target
                        text: "Test touch"
                        text_font: font_m
                        align: center
                  on_click:
                    then:
                      - lvgl.label.update:
                          id: lbl_header
                          text: "Button pushed"
              - dropdown:
                  grid_cell_column_pos: 0
                  grid_cell_row_pos: 3
                  grid_cell_x_align: STRETCH
                  grid_cell_y_align: STRETCH
                  id: dropdown_id
                  width: 90
                  align: CENTER
                  options:
                    - Violin
                    - Piano
                    - Bassoon
                    - Chello
                    - Drums
                  selected_index: 2
                  dropdown_list:
                    selected:
                      checked:
                        text_color: 0xFF0000