Issue with sample code from ESPHome website for TFT display!

Hi

I just received a Nixie display from Lilygo that is basically an ESP32 with a nice little color TFT display. So far I have been able to manage the display with ESPhome but I have a little issue with the complete sample code given on ESPhome website: ST7789V TFT LCD — ESPHome
I simplified code for my own use and editor doesn’t detect any errors but it fails pretty well at compilation. Any ideas what’s wrong there ?
My sketch:

substitutions:
  friendly_name: nixie

esphome:
  name: $friendly_name
  platform: ESP32
  board: esp32dev

wifi:
  networks:
  - ssid: !secret wifi
    password: !secret wifi_passwd
  - ssid: !secret wifi_puppy
    password: !secret wifi_puppy_passwd 
  ap:
    ssid: $friendly_name

logger:

api:

ota:

web_server:

captive_portal:

font:
  - file: "UbuntuMono-R.ttf"
    id: my_font
    size: 14

time:
  - platform: homeassistant
    id: esptime
    
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23

color:
  - id: my_red
    red: 100%
    green: 0%
    blue: 0%
  - id: my_yellow
    red: 100%
    green: 100%
    blue: 0%
  - id: my_green
    red: 0%
    green: 100%
    blue: 0%
  - id: my_blue
    red: 0%
    green: 0%
    blue: 100%
  - id: my_gray
    red: 50%
    green: 50%
    blue: 50%
    
display:
  - platform: st7789v
    backlight_pin: GPIO33
    cs_pin: GPIO5
    dc_pin: GPIO19
    reset_pin: GPIO04
    lambda: |-
      it.print(0, 0, id(my_font), "Hello World!");
      it.strftime((240 / 2), (140 / 3) * 1 + 5, id(my_red), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());
      it.strftime((240 / 2), (140 / 3) * 2 + 5, id(my_green), id(my_gray), TextAlign::CENTER, "%H:%M:%S", id(esptime).now());

and when I compile what I get as errors:

Library Manager: Installing Hash
Library Manager: Already installed, built-in library
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <FS> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <AsyncTCP-esphome> 1.2.2
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|   |-- <ArduinoJson-esphomelib> 5.13.3
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <DNSServer> 1.1.0
|   |-- <WiFi> 1.0
|-- <Update> 1.0
|-- <WiFi> 1.0
|-- <SPI> 1.0
Compiling /data/nixie/.pioenvs/nixie/src/main.cpp.o
/config/esphome/nixie.yaml: In lambda function:
/config/esphome/nixie.yaml:71:111: error: no matching function for call to 'esphome::display::DisplayBuffer::strftime(int, int, esphome::Color&, esphome::Color&, esphome::display::TextAlign, const char [9], esphome::time::ESPTime)'
       it.strftime((240 / 2), (140 / 3) * 1 + 5, id(my_red), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());
                                                                                                               ^
In file included from src/esphome.h:14:0,
                 from src/main.cpp:3:
src/esphome/components/display/display_buffer.h:227:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::Color, esphome::display::TextAlign, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, Color color, TextAlign align, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:227:8: note:   no known conversion for argument 3 from 'esphome::Color' to 'esphome::display::Font*'
src/esphome/components/display/display_buffer.h:239:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::Color, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, Color color, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:239:8: note:   candidate expects 6 arguments, 7 provided
src/esphome/components/display/display_buffer.h:251:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::display::TextAlign, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, TextAlign align, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:251:8: note:   candidate expects 6 arguments, 7 provided
src/esphome/components/display/display_buffer.h:262:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:262:8: note:   candidate expects 5 arguments, 7 provided
/config/esphome/nixie.yaml:72:113: error: no matching function for call to 'esphome::display::DisplayBuffer::strftime(int, int, esphome::Color&, esphome::Color&, esphome::display::TextAlign, const char [9], esphome::time::ESPTime)'
       it.strftime((240 / 2), (140 / 3) * 2 + 5, id(my_green), id(my_gray), TextAlign::CENTER, "%H:%M:%S", id(esptime).now());
                                                                                                                 ^
In file included from src/esphome.h:14:0,
                 from src/main.cpp:3:
src/esphome/components/display/display_buffer.h:227:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::Color, esphome::display::TextAlign, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, Color color, TextAlign align, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:227:8: note:   no known conversion for argument 3 from 'esphome::Color' to 'esphome::display::Font*'
src/esphome/components/display/display_buffer.h:239:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::Color, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, Color color, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:239:8: note:   candidate expects 6 arguments, 7 provided
src/esphome/components/display/display_buffer.h:251:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, esphome::display::TextAlign, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, TextAlign align, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:251:8: note:   candidate expects 6 arguments, 7 provided
src/esphome/components/display/display_buffer.h:262:8: note: candidate: void esphome::display::DisplayBuffer::strftime(int, int, esphome::display::Font*, const char*, esphome::time::ESPTime)
   void strftime(int x, int y, Font *font, const char *format, time::ESPTime time)
        ^
src/esphome/components/display/display_buffer.h:262:8: note:   candidate expects 5 arguments, 7 provided
*** [/data/nixie/.pioenvs/nixie/src/main.cpp.o] Error 1
========================= [FAILED] Took 12.16 seconds =========================

Thanks for your ideas or suggestions :wink:

Vincèn

Hi

It seems that you have put the wrong argument in strftime.

it.strftime((240 / 2), (140 / 3) * 1 + 5, id(my_red), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());

The third argument should be the font and not a color.

Compare it from the example.

it.strftime((240 / 2), (140 / 3) * 1 + 5, id(helvetica_24), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());

So change it to

it.strftime((240 / 2), (140 / 3) * 1 + 5, id(my_font), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());

This is what I see now.

/Mattias