screenraspberry-pi-picoesphome

ESPHome display lambda issues (st7789v)


I'm unable to get anything meaningful rendered in my st7789v 2inch waveshare display.

I've wired the pico (not the wireless version) and the screen as shown in this page. Sure enough, when I run the code in that page it works without a problem (discarding this is a wiring issue).

When I try with ESPHome, however, I get nothing rendered at all (black screen). I thought it could be a problem with a mismatching driver version so I started to code my own component based on the st7789v platform. I quickly realised the coding in ESPHome should be fine as it follows the screen's specification.

I then attempted to get anything rendered so during the screen setup function, I added the following line:

this->draw_filled_rect_(0, 0, 100, 100, 0x00FF);

This does indeed render a blue square in the screen (discarding this is a GPIO or SPI issue).

Since it has been ignoring anything inside the lambda, my last attempt has been to add the following line at the end of the draw_absolute_pixel_internal function:

this->write_display_data();

This makes the screen to render a Christmas tree of colours (like a colourful version of the old static signal in the old analog TVs).

From this, I can only conclude that either the internal buffer is not being filled correctly, the lambda is not working at all, or a combination of the both of them.

I've also tried every solution proposed in the ESPHome issues repository that seemed vaguely related plus the mandatory internet searches. Both unsuccessfully.

In addition to this, I also tried with the st7735 component to keep discarding options (in this case, to use a different implementation even it was buggy). Of course it didn't work either.

For the record, this is my display's YAML configuration (please, bear in mind that the rest of the IDs and components are also present. You can get a full copy of my YAML file in here):

spi:
  clk_pin: 14
  mosi_pin: 15

display:
  - platform: st7789v
    model: Custom
    height: 320
    width: 240
    offset_height: 0
    offset_width: 0
    cs_pin: 13
    dc_pin: 12
    reset_pin: 11
    backlight_pin: 10
    lambda: |-
      it.print(0, 0, id(roboto_20), "Hello World!");
      it.filled_rectangle(0,  0, 100, 100, id(my_yellow));

Do you guys have any suggestion for what I could try next?


Solution

  • I've found the problem!

    It seems like ESPHome isn't clever enough to know that I'm using a Raspberry Pi Pico (not the wireless version) so when it sees the network component, it happily compiles it. At this time I don't know how this affects the board but my guess is that it sets all the peripherals up (so I could render the blue square during setup) and then it tries to connect to some network which, in my case, it was surely failing so it got stuck somehow. This also prevented the logging from working.

    In summary, removing the network component (which forces you to remove the ota and api components too) fixes the issue and the lambda is beautifully executed.

    The reason why I had those components was because they came already set when I selected the pico board (not the W).

    The interesting bit is that I created this device with a pre-2023.11.2 version. On the new version, the new devices are created with the wifi component instead. This component is equally silly on a non-wifi device but, at least, it fails the firmware compilation so the issue is prevented before runtime (not ideal but way better than before).