22#ifdef USE_GRAPHICAL_DISPLAY_MENU
176class DisplayOnPageChangeTrigger;
195 DisplayWriter(F f)
requires std::invocable<F, T &> && std::convertible_to<F, void (*)(T &)>
204 this->
f_ =
new std::function<void(T &)>(std::move(f));
209 if (type_ == LAMBDA) {
210 this->f_ =
new std::function<void(T &)>(*other.
f_);
211 }
else if (type_ == STATELESS_LAMBDA) {
218 if (type_ == LAMBDA) {
221 }
else if (type_ == STATELESS_LAMBDA) {
222 this->stateless_f_ = other.stateless_f_;
229 if (
this != &other) {
237 if (
this != &other) {
245 if (type_ == LAMBDA) {
254 switch (this->type_) {
255 case STATELESS_LAMBDA:
256 this->stateless_f_(display);
259 (*this->f_)(display);
282 std::function<void(T &)> *
f_;
283 void (*stateless_f_)(T &);
290#define LOG_DISPLAY(prefix, type, obj) \
291 if ((obj) != nullptr) { \
294 "%s Rotations: %d °\n" \
295 "%s Dimensions: %dpx x %dpx", \
296 prefix, (obj)->rotation_, prefix, (obj)->get_width(), (obj)->get_height()); \
314 virtual void measure(
const char *str,
int *width,
int *x_offset,
int *baseline,
int *height) = 0;
320 virtual void fill(
Color color);
322 virtual void clear();
325 virtual int get_width() {
return this->get_width_internal(); }
327 virtual int get_height() {
return this->get_height_internal(); }
359 virtual void draw_pixels_at(
int x_start,
int y_start,
int w,
int h,
const uint8_t *ptr,
ColorOrder order,
360 ColorBitness bitness,
bool big_endian,
int x_offset,
int y_offset,
int x_pad);
365 this->draw_pixels_at(x_start, y_start, w,
h, ptr, order, bitness, big_endian, 0, 0, 0);
369 void line(
int x1,
int y1,
int x2,
int y2,
Color color = COLOR_ON);
372 void line_at_angle(
int x,
int y,
int angle,
int length,
Color color = COLOR_ON);
376 void line_at_angle(
int x,
int y,
int angle,
int start_radius,
int stop_radius,
Color color = COLOR_ON);
379 void horizontal_line(
int x,
int y,
int width,
Color color = COLOR_ON);
382 void vertical_line(
int x,
int y,
int height,
Color color = COLOR_ON);
386 void rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
389 void filled_rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
392 void circle(
int center_x,
int center_xy,
int radius,
Color color = COLOR_ON);
395 void filled_circle(
int center_x,
int center_y,
int radius,
Color color = COLOR_ON);
399 void filled_ring(
int center_x,
int center_y,
int radius1,
int radius2,
Color color = COLOR_ON);
402 void filled_gauge(
int center_x,
int center_y,
int radius1,
int radius2,
int progress,
Color color = COLOR_ON);
405 void triangle(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color = COLOR_ON);
408 void filled_triangle(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color = COLOR_ON);
418 void get_regular_polygon_vertex(
int vertex_id,
int *vertex_x,
int *vertex_y,
int center_x,
int center_y,
int radius,
420 float rotation_degrees = ROTATION_0_DEGREES);
429 float rotation_degrees = ROTATION_0_DEGREES,
Color color = COLOR_ON,
433 void regular_polygon(
int x,
int y,
int radius,
int edges,
Color color,
440 void filled_regular_polygon(
int x,
int y,
int radius,
int edges,
442 float rotation_degrees = ROTATION_0_DEGREES,
Color color = COLOR_ON);
444 void filled_regular_polygon(
int x,
int y,
int radius,
int edges,
Color color);
457 Color background = COLOR_OFF);
666#ifdef USE_GRAPHICAL_DISPLAY_MENU
689 void get_text_bounds(
int x,
int y,
const char *text,
BaseFont *font,
TextAlign align,
int *x1,
int *y1,
int *width,
696 void show_next_page();
697 void show_prev_page();
699 void set_pages(std::vector<DisplayPage *> pages);
709 void set_auto_clear(
bool auto_clear_enabled) { this->auto_clear_enabled_ = auto_clear_enabled; }
724 void start_clipping(
Rect rect);
726 start_clipping(
Rect(left, top, right - left, bottom - top));
734 void extend_clipping(
Rect rect);
736 this->extend_clipping(
Rect(left, top, right - left, bottom - top));
744 void shrink_clipping(
Rect rect);
746 this->shrink_clipping(
Rect(left, top, right - left, bottom - top));
757 Rect get_clipping()
const;
759 bool is_clipping()
const {
return !this->clipping_rectangle_.empty(); }
763 bool clip(
int x,
int y);
769 bool clamp_x_(
int x,
int w,
int &min_x,
int &max_x);
770 bool clamp_y_(
int y,
int h,
int &min_y,
int &max_y);
775 void clear_clipping_();
786 void filled_flat_side_triangle_(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color);
787 void sort_triangle_points_by_y_(
int *x1,
int *y1,
int *x2,
int *y2,
int *x3,
int *y3);
794 bool auto_clear_enabled_{
true};
796 bool show_test_card_{
false};
805 void set_parent(
Display *parent);
821 void play(
const Ts &...
x)
override {
822 auto *page = this->page_.value(
x...);
823 if (page !=
nullptr) {
833 void play(
const Ts &...
x)
override { this->buffer_->show_next_page(); }
842 void play(
const Ts &...
x)
override { this->buffer_->show_prev_page(); }
852 bool check(
const Ts &...
x)
override {
return this->parent_->get_active_page() == this->page_; }
871const LogString *text_align_to_string(TextAlign textalign);
Base class for all automation conditions.
This class simplifies creating components that periodically check a state.
virtual void measure(const char *str, int *width, int *x_offset, int *baseline, int *height)=0
virtual void print(int x, int y, Display *display, Color color, const char *text, Color background)=0
virtual int get_height() const =0
virtual int get_width() const =0
virtual void draw(int x, int y, Display *display, Color color_on, Color color_off)=0
void shrink_clipping(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
const DisplayPage * get_active_page() const
int get_native_width()
Get the native (original) width of the display in pixels.
virtual int get_height()
Get the calculated height of the display in pixels with rotation applied.
void add_on_page_change_trigger(DisplayOnPageChangeTrigger *t)
virtual int get_width()
Get the calculated width of the display in pixels with rotation applied.
virtual void draw_pixel_at(int x, int y, Color color)=0
Set a single pixel at the specified coordinates to the given color.
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order, ColorBitness bitness, bool big_endian)
Convenience overload for base case where the pixels are packed into the buffer with no gaps (e....
virtual DisplayType get_display_type()=0
Get the type of display that the buffer corresponds to.
void start_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom)
DisplayRotation get_rotation() const
virtual int get_width_internal()=0
void draw_pixel_at(int x, int y)
Set a single pixel at the specified coordinates to default color.
int get_native_height()
Get the native (original) height of the display in pixels.
virtual int get_height_internal()=0
void set_auto_clear(bool auto_clear_enabled)
std::vector< DisplayOnPageChangeTrigger * > on_page_change_triggers_
void extend_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom)
std::vector< Rect > clipping_rectangle_
bool check(const Ts &...x) override
void set_page(DisplayPage *page)
DisplayIsDisplayingPageCondition(Display *parent)
void set_from(DisplayPage *p)
DisplayOnPageChangeTrigger(Display *parent)
void set_to(DisplayPage *p)
TEMPLATABLE_VALUE(DisplayPage *, page) void play(const Ts &...x) override
DisplayPageShowNextAction(Display *buffer)
void play(const Ts &...x) override
DisplayPageShowPrevAction(Display *buffer)
void play(const Ts &...x) override
Optimized display writer that uses function pointers for stateless lambdas.
DisplayWriter(DisplayWriter &&other) noexcept
std::function< void(T &)> * f_
DisplayWriter & operator=(DisplayWriter &&other) noexcept
void operator()(T &display) const
enum esphome::display::DisplayWriter::@73 type_
DisplayWriter & operator=(const DisplayWriter &other)
DisplayWriter(const DisplayWriter &other)
const DisplayWriter & operator*() const
DisplayWriter & operator*()
void call(T &display) const
void(* stateless_f_)(T &)
struct @65::@66 __attribute__
Wake the main loop task from an ISR. ISR-safe.
@ DISPLAY_ROTATION_0_DEGREES
@ DISPLAY_ROTATION_270_DEGREES
@ DISPLAY_ROTATION_180_DEGREES
@ DISPLAY_ROTATION_90_DEGREES
constexpr Color COLOR_ON(255, 255, 255, 255)
Turn the pixel ON.
constexpr Color COLOR_OFF(0, 0, 0, 0)
Turn the pixel OFF.
const int EDGES_PENTADECAGON
const int EDGES_HEXADECAGON
const int EDGES_DODECAGON
const float ROTATION_45_DEGREES
ImageAlign
ImageAlign is used to tell the display class how to position a image.
const int EDGES_QUADRILATERAL
const int EDGES_TETRADECAGON
const float ROTATION_270_DEGREES
const float ROTATION_180_DEGREES
const int EDGES_HENDECAGON
const int EDGES_TRIDECAGON
TextAlign
TextAlign is used to tell the display class how to position a piece of text.
const float ROTATION_90_DEGREES
const float ROTATION_0_DEGREES
A more user-friendly version of struct tm from time.h.