12 namespace online_image {
16 HTTP_CODE_NOT_MODIFIED = 304,
17 HTTP_CODE_NOT_FOUND = 404,
39 public Parented<esphome::http_request::HttpRequestComponent> {
51 uint32_t buffer_size);
95 bool resize_(
int width,
int height);
115 std::shared_ptr<http_request::HttpContainer>
downloader_{
nullptr};
157 void play(Ts...
x)
override {
bool resize_(int width, int height)
bool validate_url_(const std::string &url)
void draw_pixel_(int x, int y, Color color)
Draw a pixel into the buffer.
void set_placeholder(image::Image *placeholder)
Set the image that needs to be shown as long as the downloaded image is not available.
int buffer_width_
Actual width of the current image.
void add_on_finished_callback(std::function< void()> &&callback)
const int fixed_height_
height requested on configuration, or 0 if non specified.
std::unique_ptr< ImageDecoder > decoder_
void set_url(const std::string &url)
Set the URL to download the image from.
int buffer_height_
Actual height of the current image.
This class simplifies creating components that periodically check a state.
void play(Ts... x) override
const int fixed_width_
width requested on configuration, or 0 if non specified.
Download an image from a given URL, and decode it using the specified decoder.
DownloadBuffer download_buffer_
ESPHOME_ALWAYS_INLINE bool auto_resize_() const
std::shared_ptr< http_request::HttpContainer > downloader_
void add_on_error_callback(std::function< void()> &&callback)
esphome::http_request::HttpRequestComponent * parent_
Automatically detect from MIME type.
CallbackManager< void()> download_error_callback_
OnlineImage(const std::string &url, int width, int height, ImageFormat format, image::ImageType type, uint32_t buffer_size)
Construct a new OnlineImage object.
DownloadErrorTrigger(OnlineImage *parent)
OnlineImageSetUrlAction(OnlineImage *parent)
TEMPLATABLE_VALUE(std::string, url) void play(Ts... x) override
DownloadFinishedTrigger(OnlineImage *parent)
void draw(int x, int y, int w, int h, const Color &color)
Draw a rectangle on the display_buffer using the defined color.
CallbackManager< void()> download_finished_callback_
void release()
Release the buffer storing the image.
int get_position_(int x, int y) const
int get_buffer_size_(int width, int height) const
image::Image * placeholder_
void set_size(int width, int height)
Request the image to be resized once the actual dimensions are known.
Implementation of SPI Controller mode.
const ImageFormat format_
enum { HTTP_CODE_OK=200, HTTP_CODE_NOT_MODIFIED=304, HTTP_CODE_NOT_FOUND=404, } t_http_codes
void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override
ImageFormat
Format that the image is encoded with.
OnlineImageReleaseAction(OnlineImage *parent)
An STL allocator that uses SPI or internal RAM.
uint32_t get_buffer_size_() const
Helper class to easily give an object a parent of type T.