1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 17:22:20 +01:00

[online_image] add option to show placeholder while downloading (#7083)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
guillempages
2024-08-13 09:44:43 +02:00
committed by GitHub
parent 2a70ef05d1
commit 506e69addf
3 changed files with 25 additions and 0 deletions

View File

@@ -35,6 +35,14 @@ OnlineImage::OnlineImage(const std::string &url, int width, int height, ImageFor
this->set_url(url);
}
void OnlineImage::draw(int x, int y, display::Display *display, Color color_on, Color color_off) {
if (this->data_start_) {
Image::draw(x, y, display, color_on, color_off);
} else if (this->placeholder_) {
this->placeholder_->draw(x, y, display, color_on, color_off);
}
}
void OnlineImage::release() {
if (this->buffer_) {
ESP_LOGD(TAG, "Deallocating old buffer...");