diff --git a/esphome/components/waveshare_epaper/waveshare_4_24in.cpp b/esphome/components/waveshare_epaper/waveshare_4_24in.cpp index 4e2110d3ce..f54b2fb73a 100644 --- a/esphome/components/waveshare_epaper/waveshare_4_24in.cpp +++ b/esphome/components/waveshare_epaper/waveshare_4_24in.cpp @@ -10,13 +10,13 @@ static const char *const TAG = "waveshare_epaper_4.26in"; WaveshareEPaper4P26In::WaveshareEPaper4P26In() : WaveshareEPaper() { reset_duration_ = 20; } -void WaveshareEPaper4P26In::init_display_async_(bool fast_update, const std::function f) { +void WaveshareEPaper4P26In::init_display_async_(bool fast_update, const std::function &&f) { // Reset the display this->reset_(); - wait_until_idle_async_([this, fast_update, f] { + wait_until_idle_async_([this, fast_update, f(std::move(f))] { this->command(0x12); // SWRESET - wait_until_idle_async_([this, fast_update, f] { + wait_until_idle_async_([this, fast_update, f(std::move(f))] { // Use the internal temperature sensor this->command(0x18); this->data(0x80); @@ -66,7 +66,7 @@ void WaveshareEPaper4P26In::init_display_async_(bool fast_update, const std::fun this->data(0x00); if (fast_update) { - this->wait_until_idle_async_([this, f] { + this->wait_until_idle_async_([this, f(std::move(f))] { this->command(0x1A); this->data(0x5A); diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index ec056713c7..a5bd3d0a54 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -164,12 +164,12 @@ bool WaveshareEPaperBase::wait_until_idle_() { return true; } -void WaveshareEPaperBase::wait_until_idle_async_(const std::function f) { +void WaveshareEPaperBase::wait_until_idle_async_(const std::function &&f) { if (this->busy_pin_ == nullptr || !this->busy_pin_->digital_read()) { return f(); } - this->set_timeout(20, [this, f] { this->wait_until_idle_async_(std::move(f)); }); + this->set_timeout(20, [this, f(std::move(f))] { this->wait_until_idle_async_(std::move(f)); }); } void WaveshareEPaperBase::update() { diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index f4e1f8d434..bca886d2c3 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -36,7 +36,7 @@ class WaveshareEPaperBase : public display::DisplayBuffer, protected: bool wait_until_idle_(); - void wait_until_idle_async_(const std::function f); + void wait_until_idle_async_(const std::function &&f); void setup_pins_(); @@ -167,7 +167,7 @@ class WaveshareEPaper4P26In : public WaveshareEPaper { void set_full_update_every(uint32_t full_update_every); protected: - void init_display_async_(bool fast_update, const std::function f); + void init_display_async_(bool fast_update, const std::function &&f); int get_width_internal() override; int get_height_internal() override;