esphome icon indicating copy to clipboard operation
esphome copied to clipboard

Implement i80 bus for ili9xxx displays

Open clydebarrow opened this issue 1 year ago • 15 comments

What does this implement/fix?

NOTE

This PR has been changed to draft status, since it is going to be replaced by 3 separate PRs. In the meantime you can use this PR as an external component, e.g. for the W32-SC01-Plus display:

external_components:
 - source: github://pr#6537
   components: [ i80, io_bus, ili9xxx, spi ]

i80:
  dc_pin:
    ignore_strapping_warning: true
    number: 0
  data_pins:
    - 9
    - ignore_strapping_warning: true
      number: 46
    - ignore_strapping_warning: true
      number: 3
    - 8
    - 18
    - 17
    - 16
    - 15
  wr_pin: 47

display:
  - platform: ili9xxx
    bus_type: i80
    id: w32_disp
    model: st7796
    dimensions:
      height: 320
      width: 480
    transform:
      mirror_y: false
      mirror_x: false
      swap_xy: true
    reset_pin: 4
    data_rate: 4MHz
    color_order: bgr
    invert_colors: true

Types of changes

Add a new bus parallel type - i80 - used for interfacing LCD display controllers. This is used in a similar way to the spi component, and is utilised by the ili9xxx display driver, enabling support for the Seeed W32-SC01-Plus and the LilyGo T-Display S3.

The changes have been tested on the above as well as numerous SPI interfaced displays previously supported by ili9xxx to ensure that nothing has been broken in the process.

  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Other

Related issue or feature (if applicable): fixes

  • https://github.com/esphome/feature-requests/issues/2387
  • https://github.com/esphome/feature-requests/issues/901

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3761

Test Environment

  • [x] ESP32
  • [x] ESP32 IDF
  • [ ] ESP8266
  • [x] RP2040
  • [ ] BK72xx
  • [ ] RTL87xx

Example entry for config.yaml:

# Example config.yaml
i80:
  dc_pin: 7
  wr_pin: 8
  rd_pin: 9
  data_pins:
    - 39
    - 40
    - 41
    - 42
    -
      ignore_strapping_warning: true
      number: 45
    -
      ignore_strapping_warning: true
      number: 46
    - 47
    - 48
    
display:
  - platform: ili9xxx
    bus_type: i80
    cs_pin: 6
    reset_pin: 5
    model: st7789v

Checklist:

  • [x] The code change is tested and works locally.
  • [x] Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

clydebarrow avatar Apr 15 '24 09:04 clydebarrow

Hey there @nielsnl68, mind taking a look at this pull request as it has been labeled with an integration (ili9xxx) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

probot-esphome[bot] avatar Apr 15 '24 09:04 probot-esphome[bot]

Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration (spi) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

probot-esphome[bot] avatar Apr 15 '24 09:04 probot-esphome[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 53.90%. Comparing base (4d8b5ed) to head (af200fa). Report is 720 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6537      +/-   ##
==========================================
+ Coverage   53.70%   53.90%   +0.19%     
==========================================
  Files          50       50              
  Lines        9408     9623     +215     
  Branches     1654     1698      +44     
==========================================
+ Hits         5053     5187     +134     
- Misses       4056     4112      +56     
- Partials      299      324      +25     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 15 '24 10:04 codecov-commenter

In case this ends up being mentioned in documentation: Seeed is only a distributor for the WT32-SC01 and WT32-SC01 Plus boards. They're developed & made by Wireless-Tag, which makes a few things that'd be compatible with ESPHome.

Unfocused avatar Apr 17 '24 00:04 Unfocused

Also on the topic of documentation, to avoid confusion the docs should probably mention that i80 is also commonly called 8080 (or more rarely Intel 8080, or Intel Parallel, or some combination of those words). And some specs call it DBI Type B, just for fun.

And worth mentioning this is only only supporting 8bit bus width for now. Someone will inevitably end up trying to use a display that only supports 16bit.

Unfocused avatar Apr 17 '24 00:04 Unfocused

The name is discussed in the docs, and it does specifically say it requires 8 data lines, so one would hope that no-one will try it with 16 (which will fail config validation anyway.)

clydebarrow avatar Apr 17 '24 01:04 clydebarrow

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

esphome[bot] avatar Apr 18 '24 10:04 esphome[bot]

The name is discussed in the docs, and it does specifically say it requires 8 data lines, so one would hope that no-one will try it with 16 (which will fail config validation anyway.)

We can always change the doc's so it could also be used with 16 bit data busses.

nielsnl68 avatar Apr 18 '24 12:04 nielsnl68

Arguably the convenience methods that the SPI bus interface has should be pushed out to the higher level abstraction layer..

I assume you mean things like single-byte writes? There is a case for that, but but beyond single bytes, and a data-less command operation (which should be default arguments, but C++ won't allow that on a virtual function) anything more I think is best left to be implemented when and where it's actually needed. I'm looking at you, write_array16().

clydebarrow avatar Apr 21 '24 20:04 clydebarrow

Hey there @esphome/core, mind taking a look at this pull request as it has been labeled with an integration (spi) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

probot-esphome[bot] avatar Apr 23 '24 09:04 probot-esphome[bot]

Please split up this PR into PRs for the separate component changes?

Started - I have a PR for the i80 bus. Will have to wait for that to be merged before generating the others since they will fail against the dev branch until then. So have left the original PR in place as a draft, to support early adopters using it via external components, given this could be a drawn-out process.

clydebarrow avatar May 21 '24 02:05 clydebarrow

Hello @clydebarrow ! Thank you for your work! I finally got my WT32-SC01 Plus display working with esphome with the following config:

external_components:
  - source: github://pr#6537
    components: [ io_bus, i80, spi, ili9xxx ]

i80:
  - id: i80bus
    dc_pin: GPIO0
    wr_pin: GPIO47
    data_pins:
      - GPIO9
      - GPIO46
      - GPIO3
      - GPIO8
      - GPIO18
      - GPIO17
      - GPIO16
      - GPIO15

display:
  - platform: ili9xxx
    model: ST7789V
    bus_type: i80
    reset_pin: GPIO4
    data_rate: 20MHZ
    pixel_mode: 18bit
    color_order: bgr
    invert_colors: true
    dimensions:
      width: 480
      height: 320
    transform:
      swap_xy: true
    auto_clear_enabled: false

But I am a little confused about the fact that it can't work with 40mHz data rate (as with ArduinoGFX and LovyanGFX) and the 250ms full redraw time (when doing strftimewith auto_clear_enabled: true).. Is there a way to somehow speed up the drawing?

bearpawmaxim avatar May 26 '24 08:05 bearpawmaxim

Use LVGL for fast drawing: https://github.com/esphome/esphome/pull/6363

And I'm pretty sure LoyanGFX doesn't actually drive it at 40MHz, I believe the ESP32 maxes out at 20MHz I/O clock for parallel transfers. Just because someone wrote 40MHz in the setup doesn't mean it actually achieves that.

clydebarrow avatar May 26 '24 09:05 clydebarrow

Use LVGL for fast drawing

Actually, I'm now drawing the UI with it. Thanks!

bearpawmaxim avatar May 26 '24 10:05 bearpawmaxim

Wow

nagyrobi avatar May 28 '24 20:05 nagyrobi

@clydebarrow Apologies if this is a daft question - I'm not at a stage yet where I know the difference yet! I've managed to make a Lilygo T-Display-S3 Touch work with your code - thanks for saving me after buying it assuming it would just work! I'm trying to get I²S Audio Media Player working on this unit (idea is a sort of media-player alarm clock) but that requires the Arduino framework (docs don't mention it but editor and compiler do). Conversely your i80 bus requires IDF framework. Is there anything I can do here or do I need to find a different base unit that has a more supported screen?

Many thanks, Gareth

Cenedd avatar Aug 04 '24 16:08 Cenedd

General support questions are best directed to the Discord channel, but do you need the media player? Can you use the i2s speaker or rtttl buzzer for audio output?

clydebarrow avatar Aug 04 '24 19:08 clydebarrow

General support questions are best directed to the Discord channel, but do you need the media player? Can you use the i2s speaker or rtttl buzzer for audio output?

Thanks Clyde. I think I've found the Discord channel now so I'll take this there. I'm not sure I can use i2s speaker....I'm not entirely sure I can use i2s media player to be honest. I'd like to be able to announce to it and also use it as a Spotify Connect. I'm not sure the latter is possible currently but local streaming seemed at least a step closer!

Cenedd avatar Aug 05 '24 08:08 Cenedd