102 static const int16_t VALUE_NO_SET = 32766;
111 Rect() : x(VALUE_NO_SET), y(VALUE_NO_SET), w(VALUE_NO_SET), h(VALUE_NO_SET) {}
112 inline Rect(int16_t x, int16_t y, int16_t w, int16_t h) ALWAYS_INLINE : x(x), y(y), w(w),
h(h) {}
113 inline int16_t
x2() {
return this->x + this->w; };
114 inline int16_t
y2() {
return this->y + this->
h; };
116 inline bool is_set() ALWAYS_INLINE {
return (this->h != VALUE_NO_SET) && (this->w != VALUE_NO_SET); }
118 void expand(int16_t horizontal, int16_t vertical);
120 void extend(
Rect rect);
121 void shrink(
Rect rect);
123 bool inside(
Rect rect,
bool absolute =
true);
124 bool inside(int16_t test_x, int16_t test_y,
bool absolute =
true);
125 bool equal(
Rect rect);
126 void info(
const std::string &prefix =
"rect info:");
137 #define LOG_DISPLAY(prefix, type, obj) \ 138 if ((obj) != nullptr) { \ 139 ESP_LOGCONFIG(TAG, prefix type); \ 140 ESP_LOGCONFIG(TAG, "%s Rotations: %d °", prefix, (obj)->rotation_); \ 141 ESP_LOGCONFIG(TAG, "%s Dimensions: %dpx x %dpx", prefix, (obj)->get_width(), (obj)->get_height()); \ 147 virtual void fill(
Color color);
157 void draw_pixel_at(
int x,
int y,
Color color = COLOR_ON);
160 void line(
int x1,
int y1,
int x2,
int y2,
Color color = COLOR_ON);
163 void horizontal_line(
int x,
int y,
int width,
Color color = COLOR_ON);
166 void vertical_line(
int x,
int y,
int height,
Color color = COLOR_ON);
170 void rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
173 void filled_rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
176 void circle(
int center_x,
int center_xy,
int radius,
Color color = COLOR_ON);
179 void filled_circle(
int center_x,
int center_y,
int radius,
Color color = COLOR_ON);
200 void print(
int x,
int y,
Font *font,
Color color,
const char *text);
210 void print(
int x,
int y,
Font *font,
TextAlign align,
const char *text);
219 void print(
int x,
int y,
Font *font,
const char *text);
231 void printf(
int x,
int y,
Font *font,
Color color,
TextAlign align,
const char *format, ...)
243 void printf(
int x,
int y,
Font *font,
Color color,
const char *format, ...)
__attribute__((format(printf, 6, 7)));
264 void printf(
int x,
int y,
Font *font,
const char *format, ...)
__attribute__((format(printf, 5, 6)));
324 void image(
int x,
int y,
Image *image,
Color color_on = COLOR_ON,
Color color_off = COLOR_OFF);
373 void get_text_bounds(
int x,
int y,
const char *text,
Font *font,
TextAlign align,
int *x1,
int *y1,
int *width,
380 void show_next_page();
381 void show_prev_page();
383 void set_pages(std::vector<DisplayPage *> pages);
393 void set_auto_clear(
bool auto_clear_enabled) { this->auto_clear_enabled_ = auto_clear_enabled; }
395 virtual int get_height_internal() = 0;
396 virtual int get_width_internal() = 0;
410 void start_clipping(
Rect rect);
412 start_clipping(
Rect(left, top, right - left, bottom - top));
420 void extend_clipping(
Rect rect);
422 this->extend_clipping(
Rect(left, top, right - left, bottom - top));
430 void shrink_clipping(
Rect rect);
432 this->shrink_clipping(
Rect(left, top, right - left, bottom - top));
445 bool is_clipping()
const {
return !this->clipping_rectangle_.empty(); }
448 void vprintf_(
int x,
int y,
Font *font,
Color color,
TextAlign align,
const char *format, va_list arg);
450 virtual void draw_absolute_pixel_internal(
int x,
int y,
Color color) = 0;
452 void init_internal_(uint32_t buffer_length);
456 uint8_t *buffer_{
nullptr};
462 bool auto_clear_enabled_{
true};
497 bool get_pixel(
int x,
int y)
const;
499 const char *get_char()
const;
501 bool compare_to(
const char *str)
const;
503 int match_length(
const char *str)
const;
505 void scan_area(
int *x1,
int *y1,
int *width,
int *height)
const;
522 Font(
const GlyphData *data,
int data_nr,
int baseline,
int height);
524 int match_next_glyph(
const char *str,
int *match_length);
526 void measure(
const char *str,
int *width,
int *x_offset,
int *baseline,
int *height);
530 const std::vector<Glyph, ExternalRAMAllocator<Glyph>> &
get_glyphs()
const {
return glyphs_; }
533 std::vector<Glyph, ExternalRAMAllocator<Glyph>>
glyphs_;
541 virtual bool get_pixel(
int x,
int y)
const;
542 virtual Color get_color_pixel(
int x,
int y)
const;
543 virtual Color get_rgb565_pixel(
int x,
int y)
const;
544 virtual Color get_grayscale_pixel(
int x,
int y)
const;
545 int get_width()
const;
546 int get_height()
const;
549 virtual int get_current_frame()
const;
560 Animation(
const uint8_t *data_start,
int width,
int height, uint32_t animation_frame_count,
ImageType type);
561 bool get_pixel(
int x,
int y)
const override;
562 Color get_color_pixel(
int x,
int y)
const override;
563 Color get_rgb565_pixel(
int x,
int y)
const override;
564 Color get_grayscale_pixel(
int x,
int y)
const override;
566 int get_animation_frame_count()
const;
567 int get_current_frame()
const override;
575 void set_frame(
int frame);
586 void play(Ts... x)
override {
587 auto *page = this->page_.value(x...);
588 if (page !=
nullptr) {
598 void play(Ts... x)
override { this->buffer_->show_next_page(); }
607 void play(Ts... x)
override { this->buffer_->show_prev_page(); }
617 bool check(Ts... x)
override {
return this->parent_->get_active_page() == this->page_; }
void play(Ts... x) override
DisplayIsDisplayingPageCondition(DisplayBuffer *parent)
void extend_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom)
void set_auto_clear(bool auto_clear_enabled)
std::vector< Glyph, ExternalRAMAllocator< Glyph > > glyphs_
DisplayPageShowPrevAction(DisplayBuffer *buffer)
int16_t x
X coordinate of corner.
void set_page(DisplayPage *page)
void set_to(DisplayPage *p)
const Color COLOR_OFF(0, 0, 0, 0)
Turn the pixel OFF.
DisplayRotation get_rotation() const
int16_t h
Height of region.
const uint8_t * data_start_
int16_t y
Y coordinate of corner.
Glyph(const GlyphData *data)
int animation_frame_count_
DisplayPageShowNextAction(DisplayBuffer *buffer)
TextAlign
TextAlign is used to tell the display class how to position a piece of text.
A more user-friendly version of struct tm from time.h.
Base class for all automation conditions.
const DisplayPage * get_active_page() const
Rect(int16_t x, int16_t y, int16_t w, int16_t h) ALWAYS_INLINE
void set_from(DisplayPage *p)
void play(Ts... x) override
bool is_set() ALWAYS_INLINE
Y coordinate of corner.
std::vector< DisplayOnPageChangeTrigger * > on_page_change_triggers_
enum esphome::EntityCategory __attribute__
const std::vector< Glyph, ExternalRAMAllocator< Glyph > > & get_glyphs() const
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
int16_t y2()
X coordinate of corner.
const GlyphData * glyph_data_
void shrink_clipping(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
void start_clipping(int16_t left, int16_t top, int16_t right, int16_t bottom)
std::function< void(DisplayBuffer &)> display_writer_t
DisplayOnPageChangeTrigger(DisplayBuffer *parent)
std::vector< Rect > clipping_rectangle_
void add_on_page_change_trigger(DisplayOnPageChangeTrigger *t)
int16_t w
Width of region.