|
ESPHome 2026.11.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 | |
| Snapshot () | |
| virtual | ~Snapshot () |
| 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. | |
| bool | take_animation (const char *filename, uint32_t frames, float frame_rate) |
| Record what is shown as an animated GIF file in the snapshot directory. | |
| void | take_snapshot_or_log (const char *filename, uint32_t frames, float frame_rate) |
| Take a snapshot for an automation: an empty name means a generated one, and a snapshot that wrote nothing is logged. | |
| void | take_snapshot_or_log (const std::string &filename, uint32_t frames, float frame_rate) |
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, encoding the file, and timing the frames of an animation - is done here, so every component that can take a snapshot behaves the same way.
Definition at line 24 of file snapshot.h.
|
default |
|
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.
|
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 32 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_animation | ( | const char * | filename, |
| uint32_t | frames, | ||
| float | frame_rate ) |
Record what is shown as an animated GIF file in the snapshot directory.
The first frame is taken now and the rest follow at frame_rate frames a second, in the background. Names work as for take_snapshot(), with ".gif" in place of ".bmp". Only one recording can run at a time. Returns true if the recording started.
Definition at line 325 of file snapshot.cpp.
| 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 305 of file snapshot.cpp.
| void esphome::snapshot::Snapshot::take_snapshot_or_log | ( | const char * | filename, |
| uint32_t | frames, | ||
| float | frame_rate ) |
Take a snapshot for an automation: an empty name means a generated one, and a snapshot that wrote nothing is logged.
A frames of 0 takes a single picture; otherwise an animation is recorded.
Definition at line 297 of file snapshot.cpp.
|
inline |
Definition at line 51 of file snapshot.h.
|
protected |
Definition at line 65 of file snapshot.h.