|
ESPHome 2026.10.0-dev
|
Base for anything that can hand over the picture it is showing so it can be written to a file. More...
#include <snapshot.h>
Public Member Functions | |
| virtual | ~Snapshot ()=default |
| void | set_snapshot_prefix (const char *prefix) |
| Set the word generated names start with. | |
| bool | take_snapshot (const char *filename) |
| Write the current picture to a BMP file in the snapshot directory. | |
Static Public Member Functions | |
| static void | log_action_failed () |
| Log that an action-triggered snapshot did not write a file. | |
Protected Member Functions | |
| virtual int | snapshot_width ()=0 |
| Width of the picture in pixels. | |
| virtual int | snapshot_height ()=0 |
| Height of the picture in pixels. | |
| virtual bool | capture_bgr (uint8_t *dest, size_t row_stride)=0 |
Fill in the picture: three bytes per pixel in blue, green, red order, topmost row first, with row_stride bytes from the start of one row to the start of the next. | |
Protected Attributes | |
| const char * | snapshot_prefix_ {"snapshot"} |
Base for anything that can hand over the picture it is showing so it can be written to a file.
A subclass says how big the picture is and fills in the pixels. Everything else - picking a name, staying inside the snapshot directory, not writing over anything, and encoding the file - is done here, so every component that can take a snapshot behaves the same way.
Definition at line 23 of file snapshot.h.
|
virtualdefault |
|
protectedpure virtual |
Fill in the picture: three bytes per pixel in blue, green, red order, topmost row first, with row_stride bytes from the start of one row to the start of the next.
Returns false, having logged why, if the picture could not be read.
Implemented in esphome::sdl::Sdl, and esphome::snapshot::SnapshotDisplay.
|
static |
Log that an action-triggered snapshot did not write a file.
Definition at line 196 of file snapshot.cpp.
|
inline |
Set the word generated names start with.
Codegen passes the component id, so with more than one display in a device it is clear which one a file came from.
Definition at line 29 of file snapshot.h.
|
protectedpure virtual |
Height of the picture in pixels.
Implemented in esphome::sdl::Sdl, and esphome::snapshot::SnapshotDisplay.
|
protectedpure virtual |
Width of the picture in pixels.
Implemented in esphome::sdl::Sdl, and esphome::snapshot::SnapshotDisplay.
| bool esphome::snapshot::Snapshot::take_snapshot | ( | const char * | filename | ) |
Write the current picture to a BMP file in the snapshot directory.
Pass nullptr to have a name made up from the prefix and the current time. A file that is already there is never written over. Returns true if a file was written.
Definition at line 198 of file snapshot.cpp.
|
protected |
Definition at line 50 of file snapshot.h.