141 #define LOG_DISPLAY(prefix, type, obj) \ 142 if ((obj) != nullptr) { \ 143 ESP_LOGCONFIG(TAG, prefix type); \ 144 ESP_LOGCONFIG(TAG, "%s Rotations: %d °", prefix, (obj)->rotation_); \ 145 ESP_LOGCONFIG(TAG, "%s Dimensions: %dpx x %dpx", prefix, (obj)->get_width(), (obj)->get_height()); \ 156 virtual int get_width()
const = 0;
157 virtual int get_height()
const = 0;
162 virtual void print(
int x,
int y,
Display *display,
Color color,
const char *text) = 0;
163 virtual void measure(
const char *str,
int *width,
int *x_offset,
int *baseline,
int *height) = 0;
169 virtual void fill(
Color color);
174 virtual int get_width() = 0;
176 virtual int get_height() = 0;
182 virtual void draw_pixel_at(
int x,
int y,
Color color) = 0;
185 void line(
int x1,
int y1,
int x2,
int y2,
Color color = COLOR_ON);
188 void horizontal_line(
int x,
int y,
int width,
Color color = COLOR_ON);
191 void vertical_line(
int x,
int y,
int height,
Color color = COLOR_ON);
195 void rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
198 void filled_rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
201 void circle(
int center_x,
int center_xy,
int radius,
Color color = COLOR_ON);
204 void filled_circle(
int center_x,
int center_y,
int radius,
Color color = COLOR_ON);
225 void print(
int x,
int y,
BaseFont *font,
Color color,
const char *text);
244 void print(
int x,
int y,
BaseFont *font,
const char *text);
279 void printf(
int x,
int y,
BaseFont *font,
TextAlign align,
const char *format, ...)
290 void printf(
int x,
int y,
BaseFont *font,
const char *format, ...)
__attribute__((format(printf, 5, 6)));
347 void image(
int x,
int y,
BaseImage *image,
Color color_on = COLOR_ON,
Color color_off = COLOR_OFF);
407 void get_text_bounds(
int x,
int y,
const char *text,
BaseFont *font,
TextAlign align,
int *x1,
int *y1,
int *width,
414 void show_next_page();
415 void show_prev_page();
417 void set_pages(std::vector<DisplayPage *> pages);
427 void set_auto_clear(
bool auto_clear_enabled) { this->auto_clear_enabled_ = auto_clear_enabled; }
442 void start_clipping(
Rect rect);
444 start_clipping(
Rect(left, top, right - left, bottom - top));
452 void extend_clipping(
Rect rect);
454 this->extend_clipping(
Rect(left, top, right - left, bottom - top));
462 void shrink_clipping(
Rect rect);
464 this->shrink_clipping(
Rect(left, top, right - left, bottom - top));
475 Rect get_clipping()
const;
477 bool is_clipping()
const {
return !this->clipping_rectangle_.empty(); }
481 bool clip(
int x,
int y);
484 bool clamp_x_(
int x,
int w,
int &min_x,
int &max_x);
485 bool clamp_y_(
int y,
int h,
int &min_y,
int &max_y);
486 void vprintf_(
int x,
int y,
BaseFont *font,
Color color,
TextAlign align,
const char *format, va_list arg);
489 void clear_clipping_();
496 bool auto_clear_enabled_{
true};
506 void set_parent(
Display *parent);
522 void play(Ts...
x)
override {
523 auto *page = this->page_.value(
x...);
524 if (page !=
nullptr) {
534 void play(Ts...
x)
override { this->buffer_->show_next_page(); }
543 void play(Ts...
x)
override { this->buffer_->show_prev_page(); }
553 bool check(Ts...
x)
override {
return this->parent_->get_active_page() == this->page_; }
void play(Ts... x) override
std::vector< DisplayOnPageChangeTrigger * > on_page_change_triggers_
DisplayRotation get_rotation() const
void set_page(DisplayPage *page)
A more user-friendly version of struct tm from time.h.
void set_to(DisplayPage *p)
const Color COLOR_OFF(0, 0, 0, 0)
Turn the pixel OFF.
void extend_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom)
const DisplayPage * get_active_page() const
DisplayOnPageChangeTrigger(Display *parent)
DisplayPageShowPrevAction(Display *buffer)
DisplayPageShowNextAction(Display *buffer)
TextAlign
TextAlign is used to tell the display class how to position a piece of text.
std::function< void(Display &)> display_writer_t
Base class for all automation conditions.
void shrink_clipping(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
ImageAlign
ImageAlign is used to tell the display class how to position a image.
void set_from(DisplayPage *p)
void start_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom)
void play(Ts... x) override
enum esphome::EntityCategory __attribute__
bool check(Ts... x) override
const Color COLOR_ON(255, 255, 255, 255)
Turn the pixel ON.
TEMPLATABLE_VALUE(DisplayPage *, page) void play(Ts... x) override
void draw_pixel_at(int x, int y)
Set a single pixel at the specified coordinates to default color.
void add_on_page_change_trigger(DisplayOnPageChangeTrigger *t)
Implementation of SPI Controller mode.
void set_auto_clear(bool auto_clear_enabled)
std::vector< Rect > clipping_rectangle_
DisplayIsDisplayingPageCondition(Display *parent)