Any way to get the new T-Display-S3 AMOLED to work with ESPHome?

I can see the pin usage now in the schematic, but Lilygo stuff is never easy to read, and yes, it seems to not be used in the demo code which is weird.

I have the CST226 mostly working. It’s quite different to the 816. I’ve just worked from the Lilygo demo code, can not find a datasheet. Standby for that.

WRT to brightness, you won’t be able to get the brightness, only set it. That code should have failed to compile.

1 Like

Touchscreen config for the T4-S3:

external_components:
  - source: github://clydebarrow/esphome@cst226
    refresh: 10min
    components: [ cst226 ]

i2c:
  sda: 6
  scl: 7

touchscreen:
  - platform: cst226
    id: my_touchscreen
    interrupt_pin: 8
    reset_pin: 17

@clydebarrow did anything change for the T-Display-S3 AMOLED version? Tried to compile for a new module and was informed I needed to specify the model for qspi_amoled. Used model: T-DISP-AMOLED. Then it would compile and flash, but device got stuck in a boot loop


Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x420ad50a
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x1658
load:0x403c9700,len:0xbc0
load:0x403cc700,len:0x2f3c
entry 0x403c9950
I (24) boot: ESP-IDF 4.4.6 2nd stage bootloader
I (24) boot: compile time 13:21:17
I (24) boot: Multicore bootloader
I (26) boot: chip revision: v0.1
I (30) boot.esp32s3: Boot SPI Speed : 80MHz
I (35) boot.esp32s3: SPI Mode       : DIO
I (39) boot.esp32s3: SPI Flash Size : 4MB
I (44) boot: Enabling RNG early entropy source...
I (50) boot: Partition Table:
I (53) boot: ## Label            Usage          Type ST Offset   Length
I (60) boot:  0 otadata          OTA data         01 00 00009000 00002000
I (68) boot:  1 phy_init         RF data          01 01 0000b000 00001000
I (75) boot:  2 app0             OTA app          00 10 00010000 001c0000
I (83) boot:  3 app1             OTA app          00 11 001d0000 001c0000
I (90) boot:  4 nvs              WiFi data        01 02 00390000 0006d000
I (98) boot: End of partition table
I (102) esp_image: segment 0: paddr=00010020 vaddr=3c0c0020 size=5e5cch (386508) map
I (180) esp_image: segment 1: paddr=0006e5f4 vaddr=3fc97a00 size=01a24h (  6692) load
I (182) esp_image: segment 2: paddr=00070020 vaddr=42000020 size=b2868h (731240) map
I (317) esp_image: segment 3: paddr=00122890 vaddr=3fc99424 size=026ech (  9964) load
I (320) esp_image: segment 4: paddr=00124f84 vaddr=40374000 size=139f8h ( 80376) load
I (349) boot: Loaded app from partition at offset 0x10000
I (349) boot: Disabling RNG early entropy source...
I (349) cpu_start: Multicore app
I (353) opi psram: vendor id : 0x0d (AP)
I (357) opi psram: dev id    : 0x02 (generation 3)
I (363) opi psram: density   : 0x03 (64 Mbit)
I (368) opi psram: good-die  : 0x01 (Pass)
I (373) opi psram: Latency   : 0x01 (Fixed)
I (378) opi psram: VCC       : 0x01 (3V)
I (382) opi psram: SRF       : 0x01 (Fast Refresh)
I (388) opi psram: BurstType : 0x01 (Hybrid Wrap)
I (393) opi psram: BurstLen  : 0x01 (32 Byte)
I (398) opi psram: Readlatency  : 0x02 (10 cycles@Fixed)
I (404) opi psram: DriveStrength: 0x00 (1/1)
I (409) spiram: Found 64MBit SPI RAM device
I (414) spiram: SPI RAM mode: sram 40m
I (418) spiram: PSRAM initialized, cache is in normal (1-core) mode.
I (425) cpu_start: Pro cpu up.
I (429) cpu_start: Starting app cpu, entry point is 0x403769ec
I (418) cpu_start: App cpu up.
I (1167) spiram: SPI SRAM memory test OK
I (1175) cpu_start: Pro cpu start user code
I (1175) cpu_start: cpu freq: 160000000
I (1176) cpu_start: Application information:
I (1176) cpu_start: Project name:     tdisplay-s3-amoled-temp
I (1176) cpu_start: App version:      2024.1.0-dev
I (1176) cpu_start: Compile time:     Jan 28 2024 13:20:22
I (1177) cpu_start: ELF file SHA256:  677e59f3e373982f...
I (1177) cpu_start: ESP-IDF:          4.4.6
I (1177) cpu_start: Min chip rev:     v0.0
I (1177) cpu_start: Max chip rev:     v0.99 
I (1177) cpu_start: Chip rev:         v0.1
I (1178) heap_init: Initializing. RAM available for dynamic allocation:
I (1178) heap_init: At 3FCA0FE8 len 00048728 (289 KiB): D/IRAM
I (1178) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DIRAM
I (1179) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (1179) heap_init: At 600FE000 len 00002000 (8 KiB): RTCRAM
I (1179) spiram: Adding pool of 8192K of external SPI memory to heap allocator
I (1180) spi_flash: detected chip: winbond
I (1181) spi_flash: flash io: dio
W (1181) spi_flash: Detected size(16384k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (1184) sleep: Configure to isolate all GPIO pins in sleep state
I (1184) sleep: Enable automatic switching of GPIO sleep configuration
I (1185) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
[I][logger:351]: Log initialized
[C][ota:483]: There have been 4 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[D][spi:039]: Setting up SPI bus...
[D][esp-idf:000]: I (162) gpio: GPIO[21]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[D][binary_sensor:034]: 'button_1': Sending initial state OFF
[C][adc:047]: Setting up ADC 'VBatt'...
[D][esp-idf:000]: I (167) gpio: GPIO[4]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[C][adc:093]: ADC 'VBatt' setup finished!
[C][display.qspi_amoled:074]: Setting up QSPI_AMOLED
[D][spi_device:379]: mode 0, data_rate 10000kHz
[D][esp-idf:000]: I (171) gpio: GPIO[6]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[D][esp-idf:000]: I (173) gpio: GPIO[38]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[D][esp-idf:000]: I (175) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

[D][sensor:094]: 'Battery Percentage': Sending state nan % with 2 decimals of accuracy
[D][sensor:094]: 'VBatt': Sending state 4.21082 V with 2 decimals of accuracy
Guru Meditation Error: Core  1 panic'ed (IntegerDivideByZero). Exception was unhandled.

Core  1 register dump:
PC      : 0x420097ae  PS      : 0x00060830  A0      : 0x82008371  A1      : 0x3fcede00  
A2      : 0x3fcf39cc  A3      : 0x3fcf3af4  A4      : 0xffffffff  A5      : 0x00000000  
A6      : 0x3fcf3a18  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x00000000  
A10     : 0x3fcf3af4  A11     : 0x00000217  A12     : 0x00000217  A13     : 0x00727f00  
A14     : 0x00000381  A15     : 0x420085d0  SAR     : 0x00000007  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x40055601  LEND    : 0x4005560e  LCOUNT  : 0xfffffffd  


Backtrace: 0x420097ab:0x3fcede00 0x4200836e:0x3fcede80 0x420125ed:0x3fcedea0 0x42008563:0x3fcedf10 0x42008581:0x3fcedf30 0x4200bb71:0x3fcedf50 0x420ac9b9:0x3fcedfa0 0x42012403:0x3fcedfc0 0x4201129a:0x3fcee010 0x42013ad9:0x3fcee040 0x4200871f:0x3fcee140

my code:

esphome:
  name: tdisplay-s3-amoled-temp
  friendly_name: tdisplay-s3-amoled-temp
  platformio_options:
    build_unflags: -Werror=all
    board_build.flash_mode: dio

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf

external_components:
  source: github://clydebarrow/esphome@amoled
  components: [ qspi_amoled ]
  refresh: 10min

spi:
  - id: quad_spi
    clk_pin: 47
    data_pins:
      - 18
      - 7
      - 48
      - 5

psram:
  mode: octal

# Enable logging
logger:
  hardware_uart: USB_SERIAL_JTAG
  
display:
  - platform: qspi_amoled
    id: my_display
    model: T-DISP-AMOLED
    dimensions:
      height: 240
      width: 536
      offset_height: 0
      offset_width: 0
    transform:
      mirror_x: true
      mirror_y: false
      swap_xy: true
    color_order: rgb
    invert_colors: false
    brightness: 175
    cs_pin: 6
    reset_pin: 17
    enable_pin: 38
    pages:
      - id: page1
        lambda: |-

etc.

Yes, the model requirement is new, but the divide by zero exception is unlikely to be anything to do with the AMOLED driver, more likely it’s something in a lambda on a sensor or whatever.

Note that I have just changed the model requirements, now it’s a choice of RM67162 (for the T-Display-S3) or RM690B0 for the T4-S3. These are the names of the driver chips.

I did build and run the abbreviated yaml you provided without any problem. Since you didn’t provide the full yaml I can’t help with your problem.

I have found what seems to be a hardware bug in the T4-S3 AMOLED driver chip, which is an RM690B0 for which I cannot find a datasheet. Full details here:

If using LVGL on this chip, this can be worked around with a new full_refresh setting:

external_components:
  - source: github://clydebarrow/esphome@cst226
    refresh: 10min
    components: [ cst226 ]
  - source: github://clydebarrow/esphome@lvgl
    refresh: 10min
    components: [ lvgl, font, image, qspi_amoled ]

lvgl:
  full_refresh: true

Which will force a full redraw of the screen each update. This is not ideal, but it works for now.

Also I have found the T4-S3 display will run at 40MHz 80MHz which helps somewhat.

Update: could not post this as another reply due to board limitations:

I have been able to remove the need for the full refresh - LVGL already had a mechanism to round redraw areas to specific boundaries, which I have added to the ESPHome LVGL code to ensure only areas with even coordinates are redrawn.

So full_refresh: true is not needed any more.

@clydebarrow Sweet, cst226 touchscreen is working great – thanks!

I’m able to run my T4-S3 at 80Mhz :slight_smile:

The display component is still slow – which impacts touch screen responsiveness when refreshing (eg Component display took a long time for an operation (1.34 s).)

Do you happen to have any LVGL examples?

Are you able to share an example of your config for the T4-S3? I am able to successfully compile and flash, but no display.

LVGL docs: https://deploy-preview-3510–esphome.netlify.app/components/lvgl

Configs including LVGL stuff are here:

https://gist.github.com/clydebarrow/ef89e9a93bd44771483b9144ae9042a1

1 Like

The driver is not optimised for the clunky ESPHome graphics stuff (turn off auto_clear_enabled - that will help.)

LVGL will be much better, although still hampered by the need to have full_refresh on. I’ve got some ideas on working-around that.

Also the T4 display is offset by 15 pixels, but 15 is unusable as it triggers the driver chip issue with odd redraw boundaries, so 16 works, and you will need this config for the display:

display:
  - platform: qspi_amoled
    model: RM690B0
    data_rate: 80MHz
    dimensions:
      width: 450
      height: 600
      offset_width: 16

Oh I’m sorry, it’s a bit of a mess I didn’t want to bother you with. Didn’t think the other parts would be relevant :wink:

This is the entire yaml:

esphome:
  name: tdisplay-s3-amoled-temp
  friendly_name: tdisplay-s3-amoled-temp
  platformio_options:
    build_unflags: -Werror=all
    board_build.flash_mode: dio

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf

external_components:
  source: github://clydebarrow/esphome@amoled
  components: [ qspi_amoled ]
  refresh: 10min

spi:
  id: quad_spi
  clk_pin: 47
  data_pins:
    - ignore_strapping_warning: false
      number: 18
    - 7
    - 48
    - 5

psram:
  mode: octal

# Enable logging
logger:
  level: DEBUG

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

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "AP ${node_name}"
    password: !secret wifi_ap_password

font:
  - file: "fonts/Oswald-Light.ttf"
    id: font_oswald_120
    size: 96
  - file: "fonts/Oswald-Light.ttf"
    id: font_oswald_70
    size: 70
  - file: "fonts/Oswald-Light.ttf"
    id: font_oswald_30
    size: 30
  - file: 'fonts/slkscr.ttf'
    id: font_slkscr_8
    size: 8
    glyphs: "!%()+,-/_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
  - file: 'fonts/slkscr.ttf'
    id: font_slkscr_16
    size: 16
    glyphs: "!%()+,-/_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
  - file: 'fonts/BebasNeue-Regular.ttf'
    id: font_bebas_120
    size: 120
  - file: 'fonts/BebasNeue-Regular.ttf'
    id: font_bebas_160
    size: 160
  - file: 'fonts/arial.ttf'
    id: font_arial_16
    size: 16
  - file: 'fonts/arial.ttf'
    id: font_arial_20
    size: 20

color:
  - id: color_red
    red: 1
    green: 0
    blue: 0
  - id: color_green
    red: 0
    green: 1
    blue: 0
  - id: color_blue
    red: 0
    green: 0
    blue: 1
  - id: color_orange
    red: 1
    green: 0.6
    blue: 0
  - id: color_teal_blue
    red: 0
    green: 0.5
    blue: 0.45
  - id: color_grey
    red: 0.3
    green: 0.3
    blue: 0.3
  - id: color_black
    red: 0
    green: 0
    blue: 0
  - id: color_white
    red: 1
    green: 1
    blue: 1

time:
  - platform: homeassistant
    id: esptime
    
sensor:
  - platform: adc
    pin: GPIO04
    attenuation: auto
    filters:
      - multiply: 2
    name: VBatt
    id: vcc
    update_interval: 10s

  - platform: template
    name: "Battery Percentage"
    update_interval: 30s
    accuracy_decimals: 2
    lambda: |-
      return (id(vcc).state - 3.5) / 0.7 * 100.00;
    id: battery_percentage
    entity_category: diagnostic
    unit_of_measurement: '%'
    device_class: battery

  - platform: homeassistant
    id: dsmr_power_production
    entity_id: sensor.electricity_meter_power_production
    unit_of_measurement: 'W'
    filters:
      - multiply: 1000
      - heartbeat: 5s

  - platform: homeassistant
    id: dsmr_power_consumption
    entity_id: sensor.electricity_meter_power_consumption
    unit_of_measurement: 'W'
    filters:
      - multiply: 1000
      - heartbeat: 5s

  - platform: homeassistant
    id: dsmr_total_power
    entity_id: sensor.dsmr_total_sl
    unit_of_measurement: 'W'

  - platform: homeassistant
    id: solar_power
    entity_id: sensor.dds238_2_solar_energy_power
    unit_of_measurement: 'W'

binary_sensor:
  # Button to cycle through pages on the display
  - platform: gpio
    pin:
      number: GPIO21
      inverted: true
    id: button_1
    on_press:
      then:
        - display.page.show_next: my_display
       # - component.update: my_display
graph:
  - id: dsmr_power_graph
    duration: 30min
    x_grid: 5min
    y_grid: 500
    width: 535
    height: 80
    border: false
    traces:
      - sensor: dsmr_power_consumption
        line_type: SOLID
        line_thickness: 3
        color: color_red
      - sensor: dsmr_power_production
        line_type: SOLID
        line_thickness: 2
        color: color_green

display:
  - platform: qspi_amoled
    id: my_display
    model: T-DISP-AMOLED
    dimensions:
      height: 240
      width: 536
      offset_height: 0
      offset_width: 0
    transform:
      mirror_x: true
      mirror_y: false
      swap_xy: true
    color_order: rgb
    invert_colors: false
    brightness: 175
    cs_pin: 6
    reset_pin: 17
    enable_pin: 38
    pages:
      - id: page1
        lambda: |-
          auto white = Color(255, 255, 255);
          auto test = Color(40, 40, 255);
          auto purple = Color(102, 0, 204);
          it.filled_rectangle(0, 0, 535, 20, test);
          it.strftime(268, -2, id(font_arial_20), id(color_white), TextAlign::CENTER_HORIZONTAL, "%c", id(esptime).now());

          //if (id(vcc).has_state()) {
            //it.printf(4, 0, id(font_arial_16), id(color_teal_blue), "%.2f V (%.2f %%)", id(vcc).state, id(batterylevel).state);
          //}

          if (id(dsmr_total_power).has_state()) 
            {
            float pwr = id(dsmr_total_power).state;
              if (pwr > 1000.0) 
                {
                it.printf(268, 0, id(font_bebas_160), id(color_red), TextAlign::CENTER_HORIZONTAL, "%.0f W", id(dsmr_total_power).state);
                } 
              else
                {
                if (pwr > 750.0) 
                  {
                  it.printf(268, 0, id(font_bebas_160), id(color_orange), TextAlign::CENTER_HORIZONTAL, "%.0f W", id(dsmr_total_power).state);
                  } 
              else 
                {
                if (pwr < 0.0)
                  {
                  it.printf(268, 0, id(font_bebas_160), id(color_blue), TextAlign::CENTER_HORIZONTAL, "%.0f W", id(dsmr_total_power).state);
                  }
              else
                  {
                  it.printf(268, 0, id(font_bebas_160), id(color_green), TextAlign::CENTER_HORIZONTAL, "%.0f W", id(dsmr_total_power).state);
                  }
                }
              }
            }
          // Draw the graph
          it.graph(1, 160, id(dsmr_power_graph), color_teal_blue);
      - id: page2
        lambda: |-
          auto white = Color(255, 255, 255);
          auto test = Color(40, 40, 255);
          auto purple = Color(102, 0, 204);
          it.filled_rectangle(0, 0, 535, 20, test);
          it.strftime(268, -2, id(font_arial_20), id(color_white), TextAlign::CENTER_HORIZONTAL, "%c", id(esptime).now());

          it.printf(268, 0, id(font_bebas_160), id(color_blue), TextAlign::CENTER_HORIZONTAL, "%.0f W", id(solar_power).state);
          
          // Draw the graph
          it.graph(1, 160, id(dsmr_power_graph), color_teal_blue);

ps removed the only calculation I was doing for battery percentage, but issue remains the same. Hope you see what the cause might be. Afaik nothing changed in my yaml compared to the previous working state where I cloned your entire repo as opposed to using the official esphome-dev now.

Here’s my T4-S3 config:

esphome:
  name: t-amoled
  platformio_options:
    build_unflags: -Werror=all
    board_build.flash_mode: dio

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf

logger:
  level: DEBUG

api:
ota:
  password: ""
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Dashboard Fallback Hotspot"
    password: ""

external_components:
  - source: github://clydebarrow/esphome@amoled
    components: [ qspi_amoled ]
    refresh: 10min
  - source: github://clydebarrow/esphome@cst226
    refresh: 10min
    components: [ cst226 ]

i2c:
  sda: 6
  scl: 7

spi:
  id: quad_spi
  clk_pin: 15
  data_pins:
    - 14
    - 10
    - 16
    - 12

touchscreen:
  - platform: cst226
    id: my_touchscreen
    interrupt_pin: 8
    reset_pin: 17
    transform:
      mirror_x: true
      swap_xy: true      
    on_touch:
      - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );
              #    on_update:
              #      - lambda: |-
              #          for (auto touch: touches)  {
              #              if (touch.state <= 2) {
              #                 ESP_LOGI("Touch points:", "id=%d x=%d, y=%d", touch.id, touch.x, touch.y);
              #              }
              #          }        
font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 40

      #image:
      #  - file: cat.jpg
      #    id: cat_image
      #    resize: 180x75
      #    type: RGB565

display:
  - platform: qspi_amoled
    data_rate: 80MHz
    model: RM690B0 # T4-S3
    dimensions:
      height: 450
      width: 600
    transform:
      mirror_x: true
      swap_xy: true
    color_order: rgb
    brightness: 128
    cs_pin: 11
    reset_pin: 13
    enable_pin: 9
    update_interval: 10s

    lambda: |-
      auto rand_col = Color::random_color();
      it.filled_rectangle(0, 0, it.get_width(), it.get_height(), rand_col);
      it.print(it.get_width()/2, it.get_height()/2, id(roboto), TextAlign::CENTER, "ESPHome");

psram:
  mode: octal
2 Likes

This is the offending line:

          it.graph(1, 160, id(dsmr_power_graph), color_teal_blue);

So not my department.

I suggest asking for help in the Discord General Support channel.

Stack trace below. I suspect your history data is empty at the time the function is called.

[08:43:14][D][sensor:094]: 'Battery Percentage': Sending state nan % with 2 decimals of accuracy
[08:43:14][D][sensor:094]: 'VBatt': Sending state 4.15102 V with 2 decimals of accuracy
[08:43:15]Guru Meditation Error: Core  1 panic'ed (IntegerDivideByZero). Exception was unhandled.
[08:43:15]
[08:43:15]Core  1 register dump:
[08:43:15]PC      : 0x42008f82  PS      : 0x00060830  A0      : 0x82007ae5  A1      : 0x3fcedf90
WARNING Decoded 0x42008f82: esphome::graph::HistoryData::get_value(int) const at /Users/clyde/dev/opensourceprojects/esp/my-devices/.esphome/build/tdisplay-s3-amoled-temp/src/esphome/components/graph/graph.h:93
 (inlined by) esphome::graph::Graph::draw(esphome::display::Display*, unsigned short, unsigned short, esphome::Color) at /Users/clyde/dev/opensourceprojects/esp/my-devices/.esphome/build/tdisplay-s3-amoled-temp/src/esphome/components/graph/graph.cpp:173
[08:43:15]A2      : 0x3fcf3b20  A3      : 0x3fcf3c38  A4      : 0xffffffff  A5      : 0x00000000
[08:43:15]A6      : 0x3fcf3b6c  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x00000000
[08:43:15]A10     : 0x3fcf3c38  A11     : 0x00000217  A12     : 0x00000217  A13     : 0x00727f00
[08:43:15]A14     : 0x00000381  A15     : 0x42007d44  SAR     : 0x00000007  EXCCAUSE: 0x00000006
[08:43:15]EXCVADDR: 0x00000000  LBEG    : 0x40055601  LEND    : 0x4005560e  LCOUNT  : 0xfffffffd
[08:43:15]
[08:43:15]
[08:43:15]Backtrace: 0x42008f7f:0x3fcedf90 0x42007ae2:0x3fcee010 0x42011d71:0x3fcee030 0x42007cd7:0x3fcee0a0 0x42007cf5:0x3fcee0c0 0x4200b319:0x3fcee0e0 0x420a44cd:0x3fcee130 0x42011b87:0x3fcee150 0x42010a36:0x3fcee1a0 0x42013211:0x3fcee1d0 0x42007e93:0x3fcee2c0
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x42008f7f: esphome::graph::HistoryData::get_value(int) const at /Users/clyde/dev/opensourceprojects/esp/my-devices/.esphome/build/tdisplay-s3-amoled-temp/src/esphome/components/graph/graph.h:93
 (inlined by) esphome::graph::Graph::draw(esphome::display::Display*, unsigned short, unsigned short, esphome::Color) at /Users/clyde/dev/opensourceprojects/esp/my-devices/.esphome/build/tdisplay-s3-amoled-temp/src/esphome/components/graph/graph.cpp:173
WARNING Decoded 0x42007ae2: esphome::display::Display::graph(int, int, esphome::graph::Graph*, esphome::Color) at /Users/clyde/dev/opensourceprojects/esp/my-devices/.esphome/build/tdisplay-s3-amoled-temp/src/esphome/components/display/display.cpp:310
WARNING Decoded 0x42011d71: std::_Function_handler<void (esphome::display::Display&), setup()::{lambda(esphome::display::Display&)#2}>::_M_invoke(std::_Any_data const&, esphome::display::Display&) at /Users/clyde/dev/opensourceprojects/esp/my-devices/.esphome/build/tdisplay-s3-amoled-temp/my.yaml:254

Indeed, without the graph on page 1 it works. Strange thing is the exact same graph does work on page 2. And the same code with only different display on a regular T-Display-S3 also works… Weird eh?

I suspect it’s a timing issue - the display is being initialised and tries to draw stuff before the graph data is available. It’s also a bug in the graph component since it should check for zero before trying to divide!

Thank you for the detailed research & explanation.
Has this device still a free SPI interface available? Or are they all occupied (by the QSPI display)?
I ask because I have a SPI slave device which doesn’t allow other slaves on the same SPI interface.
Thanks!

Yes, the ESP has two user-available SPI interfaces. Just configure a second one.

1 Like

Ah, great. So I assume the available one is HSPI, and VSPI is used by the AMLED display?
I was under the wrong assumption that QSPI used both user SPI interfaces…

Thanks!

No, the interfaces available on the ESP32-S3 are SPI2 and SPI3. Either can work in quad SPI mode. You don’t need to worry about which is in use, just configure two SPI buses, one quad which will be used by the display, the other 1-bit as per usual. Add interface: hardware if you like. If you need any more they can only be software, which is speed limited, but still fine for a lot of things.

2 Likes

Thanks for the work that has been done to make the Lilygo displays work. I was able to get the t-display s3 amoled v2.0 with touch to work. I was making a remote display to show my blood glucose levels on my night stand next to the bed. It uses the blood sugar level from the NightScout integration of Home Assistant. I am attaching the code that I am using.
substitutions:

substitutions:
  disp_name: CGM Display Amoled

esphome:
  name: cgm-display-amoled
  friendly_name: CGM Display Amoled
  platformio_options:
    build_unflags: -Werror=all
    board_build.flash_mode: dio

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  framework:
    type: esp-idf

logger:
  level: error

api:

ota:

web_server:
  port: 80

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.0.139
    gateway: 192.168.0.1
    subnet: 255.255.255.0
  ap:
    ssid: "CDM Display Amoled"

switch:
  - platform: restart
    name: ${disp_name} Restart  

external_components:
  - source: github://clydebarrow/esphome@amoled
    components: [ qspi_amoled ]
    refresh: 10min
  - source: github://clydebarrow/esphome@cst226
    refresh: 10min
    components: [ cst226 ]

i2c:
  sda: 2
  scl: 3

spi:
  id: quad_spi
  clk_pin: 47
  data_pins:
    - ignore_strapping_warning: false
      number: 18
    - 7
    - 48
    - 5

touchscreen:
  - platform: cst226
    id: my_touchscreen
    interrupt_pin: 21
    # reset_pin: 17
    transform:
      mirror_x: true
      swap_xy: true      
    on_touch:
      - lambda: |-
          ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
              touch.x,
              touch.y,
              touch.x_raw,
              touch.y_raw
              );

color:
  - id: my_black
    red: 0%
    green: 0%
    blue: 0%
  - id: my_red
    hex: fc0000
  - id: my_green
    hex: 00fc4c
  - id: my_yellow
    hex: e0e637
  - id: my_orange
    hex: e19532
  - id: my_white
    hex: ffffff
  - id: my_purple
    hex: 641e78
  - id: my_cyan
    hex: 1e7878

font:
  - file: 'fonts/arialbd.ttf'
    id: font1
    size: 144
  - file: 'fonts/clock.ttf'
    id: font2
    size: 20
  - file: 'fonts/roboto.ttf'
    id: font3
    size: 45

display:
  - platform: qspi_amoled
    id: my_display
    model: RM67162
    dimensions:
      height: 240
      width: 536
      offset_height: 0
      offset_width: 0
    transform:
      mirror_x: true
      mirror_y: false
      swap_xy: true
    color_order: rgb
    invert_colors: false
    brightness: 175
    cs_pin: 6
    reset_pin: 17
    enable_pin: 38

    lambda: |-
      it.filled_rectangle(0, 0, 536, 240, my_black);
      if (id(blood_sugar).has_state()) {
        if (id(blood_sugar).state < 55.0) {
          it.printf(268, 100, id(font1), id(my_red), TextAlign::CENTER, "%.0f", id(blood_sugar).state);
        }
        if ((id(blood_sugar).state >= 55.0) && (id(blood_sugar).state < 70.0)) {
          it.printf(268, 100, id(font1), id(my_yellow), TextAlign::CENTER, "%.0f", id(blood_sugar).state);
        }
        if ((id(blood_sugar).state >= 70.0) && (id(blood_sugar).state < 180.0)) {
          it.printf(268, 100, id(font1), id(my_green), TextAlign::CENTER, "%.0f", id(blood_sugar).state);
        }
        if ((id(blood_sugar).state >= 180.0) && (id(blood_sugar).state < 260.0)) {
          it.printf(268, 100, id(font1), id(my_yellow), TextAlign::CENTER, "%.0f", id(blood_sugar).state);
        }
        if (id(blood_sugar).state > 250.0) {
          it.printf(268, 100, id(font1), id(my_red), TextAlign::CENTER, "%.0f", id(blood_sugar).state);
        }
      }
      it.strftime(10, 235, id(font3), id(my_white), TextAlign::BOTTOM_LEFT, "%I : %M %p", id(esptime).now());

 
psram:
  mode: octal

time:
  - platform: homeassistant
    id: esptime

sensor: 
  - platform: homeassistant
    id: blood_sugar
    entity_id: sensor.blood_sugar
    accuracy_decimals: 0
    unit_of_measurement: mg/dL

  - platform: wifi_signal
    name: ${disp_name} WiFi Status
    update_interval: 10s

captive_portal:
    

2 Likes