monorkin / esphome_st7565

ESPHome external component for ST7565 displays
Other
6 stars 3 forks source link

Fix compilation errors on esphome 2023-12-00 plus #5

Closed monorkin closed 7 months ago

monorkin commented 7 months ago

Since ESPHome version 2023-12 components shouldn't be explicitly registered. This causes compilation errors.

This PR adds code that conditionally registers or doesn't register the component depending on if the current version of ESPHome expects that.

This closes PR #4

tikalin2000 commented 6 months ago

hello,

When compiling with version 1.1.0, the errors that I attach appear. Could you review this version?

Thank you

INFO ESPHome 2024.2.2 INFO Reading configuration /config/esphome/solar8266.yaml... INFO Detected timezone 'Europe/Madrid' INFO Generating C++ source... INFO Compiling app... Processing solar8266 (board: nodemcuv2; framework: arduino; platform: platformio/espressif8266@3.2.0)

HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash Dependency Graph |-- ESPAsyncTCP-esphome @ 2.0.0 |-- ESPAsyncWebServer-esphome @ 3.1.0 |-- DNSServer @ 1.1.1 |-- ESP8266WiFi @ 1.0 |-- ESP8266mDNS @ 1.2 |-- noise-c @ 0.1.4 |-- SPI @ 1.0 Compiling .pioenvs/solar8266/src/main.cpp.o src/main.cpp: In function 'void setup()': src/main.cpp:2866:56: error: cannot declare parameter 'it' to be of abstract type 'esphome::display::DisplayBuffer' 2866 | st7565_st7565->set_writer([=](display::DisplayBuffer it) -> void { | ~~~~~~~^~ In file included from src/esphome.h:18, from src/main.cpp:3: src/esphome/components/display/display_buffer.h:15:7: note: because the following virtual functions are pure within 'esphome::display::DisplayBuffer': 15 | class DisplayBuffer : public Display { | ^~~~~ In file included from src/esphome/components/api/proto.h:3, from src/esphome/components/api/api_pb2.h:5, from src/esphome/components/api/api_connection.h:4, from src/esphome.h:3, from src/main.cpp:3: src/esphome/core/component.h:303:16: note: 'virtual void esphome::PollingComponent::update()' 303 | virtual void update() = 0; | ^~ In file included from src/esphome.h:17, from src/main.cpp:3: src/esphome/components/display/display.h:484:23: note: 'virtual esphome::display::DisplayType esphome::display::Display::get_display_type()' 484 | virtual DisplayType get_display_type() = 0; | ^~~~ In file included from src/esphome.h:18, from src/main.cpp:3: src/esphome/components/display/display_buffer.h:25:15: note: 'virtual int esphome::display::DisplayBuffer::get_height_internal()' 25 | virtual int get_height_internal() = 0; | ^~~~~~~ src/esphome/components/display/display_buffer.h:26:15: note: 'virtual int esphome::display::DisplayBuffer::get_width_internal()' 26 | virtual int get_width_internal() = 0; | ^~~~~~ src/esphome/components/display/display_buffer.h:29:16: note: 'virtual void esphome::display::DisplayBuffer::draw_absolute_pixel_internal(int, int, esphome::Color)' 29 | virtual void draw_absolute_pixel_internal(int x, int y, Color color) = 0; | ^~~~~~~~ /config/esphome/solar8266.yaml: In lambda function: /config/esphome/solar8266.yaml:86:3: error: expected primary-expression before '}' token 86 | | ^ /config/esphome/solar8266.yaml:85:46: warning: label 'esphome' defined but not used [-Wunused-label] 85 | it.print(0, 20, id(font10), "On ESPHome!");esphome: | ^~~ /config/esphome/solar8266.yaml: In function 'void setup()': /config/esphome/solar8266.yaml:86:4: error: cannot convert 'setup()::<lambda(esphome::display::DisplayBuffer)>' to 'esphome::display::display_writer_t&&' {aka 'std::function<void(esphome::display::Display&)>&&'} 86 | | ^ In file included from src/esphome.h:17, from src/main.cpp:3: src/esphome/components/display/display.h:461:38: note: initializing argument 1 of 'void esphome::display::Display::set_writer(esphome::display::display_writer_t&&)' 461 | void set_writer(display_writer_t &&writer); | ~~~~~^~~~ *** [.pioenvs/solar8266/src/main.cpp.o] Error 1 ========================== [FAILED] Took 5.69 seconds ==========================

monorkin commented 6 months ago

@tikalin2000 can you check your YAML file? From the error message it seems like it's malformed. Here is the relevant line from the error:

/config/esphome/solar8266.yaml: In lambda function:
/config/esphome/solar8266.yaml:86:3: error: expected primary-expression before '}' token
86 |
| ^
/config/esphome/solar8266.yaml:85:46: warning: label 'esphome' defined but not used [-Wunused-label]
85 | it.print(0, 20, id(font10), "On ESPHome!");esphome:
| ^~~~~~~
tikalin2000 commented 6 months ago

hello,

I have eliminated the errors from the .yaml and the result is the same, errors appearing in the compiler,

Thank you

logs_solar8266_run (1).txt

solar8266.yaml esphome: name: solar8266

external_components:

Project configuration - you have to configure this for your setup!

esphome:

name: my-project

platform: ESP8266

board: nodemcuv2

esp8266: board: nodemcuv2

Enable logging

logger:

Enable Home Assistant API

api: encryption: key: "wwS93a4LJYUY/LOt0uevLlzcRmL92+ah9MKoXIDVaOU="

ota: password: "73bb0628dbdab464c9c1a05ce3daa4e3"

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

captive_portal:

font:

spi:

display: