issues icon indicating copy to clipboard operation
issues copied to clipboard

LVGL + i2s audio media player corrupt display

Open ijc opened this issue 8 months ago • 0 comments

The problem

If I enable LVGL on top of a ili9xxx/ST7735 display at the same time as having an i2s audio speaker stack configured then the display is corrupted.

If I disable LVGL and just use the display component's lambda to draw some simple text then that seems to work (see the commented out lambda in the supplied yaml). I've not tried anything complex though (nor with LVGL to be honest).

If I disable the speaker components then LVGL seems fine (but I'm building a media player so if anything is going to give it's the display).

I'm using the ESP-IDF framework because it supports FLAC. I'm streaming from a Music Assistant installation

There is some similarity with https://github.com/esphome/issues/issues/3421 but in that one the audio doesn't work. In my case the audio is fine (bar a bit of crackling for a second or two when playback starts).

Which version of ESPHome has the issue?

2025.06

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

2025.06

What platform are you using?

ESP32-IDF

Board

Adafruit ESP32 Feather V2

Component causing the issue

LVGL

YAML Config

esphome:
  name: study-music-player
  friendly_name: Study Music Player

esp32:
  board: adafruit_feather_esp32_v2
  framework:
    type: esp-idf

# Enable logging
logger:

i2s_audio:
  id: i2s
  # AKA WS / WSEL
  i2s_lrclk_pin: GPIO33
  i2s_bclk_pin: GPIO32

speaker:
  - platform: i2s_audio
    id: i2s_speaker
    i2s_audio_id: i2s
    dac_type: external
    i2s_dout_pin: GPIO15
    channel: stereo
    sample_rate: 44100
    buffer_duration: 500ms
  - platform: mixer
    output_speaker: i2s_speaker
    source_speakers:
      - id: announcement_mixer_input_speaker_id
      - id: media_mixer_input_speaker_id

media_player:
  name: Media Player
  platform: speaker
  announcement_pipeline:
    speaker: announcement_mixer_input_speaker_id
  media_pipeline:
    speaker: media_mixer_input_speaker_id
    num_channels: 2
    sample_rate: 44100
  on_mute:
    then:
      - logger.log: Muted
  on_unmute:
    then:
      - logger.log: Unmuted
  on_volume:
    then:
      - logger.log: Volume Changed

spi:
  clk_pin: GPIO5
  mosi_pin: GPIO19

lvgl:
  widgets:
  - label:
      align: CENTER
      text: 'Hello World!'
  - line:
      line_color: 0xff0000
      line_width: 4
      points:
        - 1, 1
        - 1, 128
        - 160, 128
        - 160, 1
        - 1, 1
display:
  - platform: ili9xxx
    model: ST7735
    dc_pin: GPIO21
    cs_pin: GPIO14
    reset_pin: GPIO27
    transform:
      swap_xy: true
      mirror_x: true
      mirror_y: false
    dimensions: 
      width: 160
      height: 128
    invert_colors: false
    show_test_card: false
    
    update_interval: never
    #lambda: |-
    #  it.print(0, 10, id(dejavusans), "Hello World!");

#font:
#  - file: '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
#    id: dejavusans

switch:
  - platform: output
    name: Mute
    output: mute
    icon: mdi:volume-mute

light:
  - platform: monochromatic
    output: lcd_backlight
    name: "Display Backlight"
    restore_mode: ALWAYS_ON

output:
  - platform: gpio
    pin: GPIO13
    id: mute
  - platform: ledc
    pin: GPIO4
    id: lcd_backlight

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

ota:
  - platform: esphome
    password: "redacted"

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

Anything in the logs that might be useful for us?

There's no error messages or anything unusual in the logs.

Additional information

Board is a Adafruit ESP32 Feather V2 attached to an AZ Delivery TFT display.

With everything enabled the screen looks like this:

It's supposed to look like this (and does if I remove the speaker and media player stuff)

(obviously not the final UI..)

ijc avatar Jun 21 '25 14:06 ijc