22 #ifdef USE_GRAPHICAL_DISPLAY_MENU 141 #define PI 3.1415926535897932384626433832795 183 #define LOG_DISPLAY(prefix, type, obj) \ 184 if ((obj) != nullptr) { \ 185 ESP_LOGCONFIG(TAG, prefix type); \ 186 ESP_LOGCONFIG(TAG, "%s Rotations: %d °", prefix, (obj)->rotation_); \ 187 ESP_LOGCONFIG(TAG, "%s Dimensions: %dpx x %dpx", prefix, (obj)->get_width(), (obj)->get_height()); \ 198 virtual int get_width()
const = 0;
199 virtual int get_height()
const = 0;
204 virtual void print(
int x,
int y,
Display *display,
Color color,
const char *text,
Color background) = 0;
205 virtual void measure(
const char *str,
int *width,
int *x_offset,
int *baseline,
int *height) = 0;
211 virtual void fill(
Color color);
216 virtual int get_width() {
return this->get_width_internal(); }
218 virtual int get_height() {
return this->get_height_internal(); }
229 virtual void draw_pixel_at(
int x,
int y,
Color color) = 0;
250 virtual void draw_pixels_at(
int x_start,
int y_start,
int w,
int h,
const uint8_t *ptr,
ColorOrder order,
251 ColorBitness bitness,
bool big_endian,
int x_offset,
int y_offset,
int x_pad);
256 this->draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, 0, 0, 0);
260 void line(
int x1,
int y1,
int x2,
int y2,
Color color = COLOR_ON);
263 void line_at_angle(
int x,
int y,
int angle,
int length,
Color color = COLOR_ON);
267 void line_at_angle(
int x,
int y,
int angle,
int start_radius,
int stop_radius,
Color color = COLOR_ON);
270 void horizontal_line(
int x,
int y,
int width,
Color color = COLOR_ON);
273 void vertical_line(
int x,
int y,
int height,
Color color = COLOR_ON);
277 void rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
280 void filled_rectangle(
int x1,
int y1,
int width,
int height,
Color color = COLOR_ON);
283 void circle(
int center_x,
int center_xy,
int radius,
Color color = COLOR_ON);
286 void filled_circle(
int center_x,
int center_y,
int radius,
Color color = COLOR_ON);
289 void triangle(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color = COLOR_ON);
292 void filled_triangle(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color = COLOR_ON);
302 void get_regular_polygon_vertex(
int vertex_id,
int *vertex_x,
int *vertex_y,
int center_x,
int center_y,
int radius,
304 float rotation_degrees = ROTATION_0_DEGREES);
313 float rotation_degrees = ROTATION_0_DEGREES,
Color color = COLOR_ON,
317 void regular_polygon(
int x,
int y,
int radius,
int edges,
Color color,
324 void filled_regular_polygon(
int x,
int y,
int radius,
int edges,
326 float rotation_degrees = ROTATION_0_DEGREES,
Color color = COLOR_ON);
328 void filled_regular_polygon(
int x,
int y,
int radius,
int edges,
Color color);
341 Color background = COLOR_OFF);
352 void print(
int x,
int y,
BaseFont *font,
Color color,
const char *text,
Color background = COLOR_OFF);
371 void print(
int x,
int y,
BaseFont *font,
const char *text);
420 void printf(
int x,
int y,
BaseFont *font,
TextAlign align,
const char *format, ...)
431 void printf(
int x,
int y,
BaseFont *font,
const char *format, ...)
__attribute__((format(printf, 5, 6)));
488 void image(
int x,
int y,
BaseImage *image,
Color color_on = COLOR_ON,
Color color_off = COLOR_OFF);
536 #ifdef USE_GRAPHICAL_DISPLAY_MENU 545 #endif // USE_GRAPHICAL_DISPLAY_MENU 559 void get_text_bounds(
int x,
int y,
const char *text,
BaseFont *font,
TextAlign align,
int *x1,
int *y1,
int *width,
566 void show_next_page();
567 void show_prev_page();
569 void set_pages(std::vector<DisplayPage *> pages);
579 void set_auto_clear(
bool auto_clear_enabled) { this->auto_clear_enabled_ = auto_clear_enabled; }
594 void start_clipping(
Rect rect);
596 start_clipping(
Rect(left, top, right - left, bottom - top));
604 void extend_clipping(
Rect rect);
606 this->extend_clipping(
Rect(left, top, right - left, bottom - top));
614 void shrink_clipping(
Rect rect);
616 this->shrink_clipping(
Rect(left, top, right - left, bottom - top));
627 Rect get_clipping()
const;
629 bool is_clipping()
const {
return !this->clipping_rectangle_.empty(); }
633 bool clip(
int x,
int y);
639 bool clamp_x_(
int x,
int w,
int &min_x,
int &max_x);
640 bool clamp_y_(
int y,
int h,
int &min_y,
int &max_y);
645 void clear_clipping_();
647 virtual int get_height_internal() = 0;
648 virtual int get_width_internal() = 0;
656 void filled_flat_side_triangle_(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color);
657 void sort_triangle_points_by_y_(
int *x1,
int *y1,
int *x2,
int *y2,
int *x3,
int *y3);
664 bool auto_clear_enabled_{
true};
666 bool show_test_card_{
false};
675 void set_parent(
Display *parent);
691 void play(Ts...
x)
override {
692 auto *page = this->page_.value(
x...);
693 if (page !=
nullptr) {
703 void play(Ts...
x)
override { this->buffer_->show_next_page(); }
712 void play(Ts...
x)
override { this->buffer_->show_prev_page(); }
722 bool check(Ts...
x)
override {
return this->parent_->get_active_page() == this->page_; }
void play(Ts... x) override
const int EDGES_HEXADECAGON
std::vector< DisplayOnPageChangeTrigger * > on_page_change_triggers_
DisplayRotation get_rotation() const
const int EDGES_QUADRILATERAL
const float ROTATION_45_DEGREES
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...
int get_native_height()
Get the native (original) height of the display in pixels.
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)
This class simplifies creating components that periodically check a state.
const DisplayPage * get_active_page() const
const int EDGES_TETRADECAGON
DisplayOnPageChangeTrigger(Display *parent)
virtual int get_width()
Get the calculated width of the display in pixels with rotation applied.
const float ROTATION_270_DEGREES
DisplayPageShowPrevAction(Display *buffer)
int get_native_width()
Get the native (original) width of the display in pixels.
DisplayPageShowNextAction(Display *buffer)
const float ROTATION_180_DEGREES
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.
const float ROTATION_90_DEGREES
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)
const float ROTATION_0_DEGREES
const int EDGES_TRIDECAGON
void play(Ts... x) override
const int EDGES_PENTADECAGON
enum esphome::EntityCategory __attribute__
const int EDGES_DODECAGON
virtual int get_height()
Get the calculated height of the display in pixels with rotation applied.
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
const LogString * text_align_to_string(TextAlign textalign)
const int EDGES_HENDECAGON
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)