12#ifndef ESPHOME_SNAPSHOT_DIR
13#define ESPHOME_SNAPSHOT_DIR "."
48 virtual bool capture_bgr(uint8_t *dest,
size_t row_stride) = 0;
55 TEMPLATABLE_VALUE(std::string, filename)
58 void play(
const Ts &...
x)
override {
60 if (this->filename_.has_value()) {
61 ok = this->
parent_->take_snapshot(this->filename_.value(
x...).c_str());
63 ok = this->
parent_->take_snapshot(
nullptr);
66 this->
parent_->log_action_failed();
virtual void play(const Ts &...x)=0
Helper class to easily give an object a parent of type T.
Base for anything that can hand over the picture it is showing so it can be written to a file.
virtual ~Snapshot()=default
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,...
const char * snapshot_prefix_
virtual int snapshot_width()=0
Width of the picture in pixels.
virtual int snapshot_height()=0
Height of the picture in pixels.
static void log_action_failed()
Log that an action-triggered snapshot did not write a file.
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.