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);
290 void filled_ring(
int center_x,
int center_y,
int radius1,
int radius2,
Color color = COLOR_ON);
293 void filled_gauge(
int center_x,
int center_y,
int radius1,
int radius2,
int progress,
Color color = COLOR_ON);
296 void triangle(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color = COLOR_ON);
299 void filled_triangle(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color = COLOR_ON);
309 void get_regular_polygon_vertex(
int vertex_id,
int *vertex_x,
int *vertex_y,
int center_x,
int center_y,
int radius,
311 float rotation_degrees = ROTATION_0_DEGREES);
320 float rotation_degrees = ROTATION_0_DEGREES,
Color color = COLOR_ON,
324 void regular_polygon(
int x,
int y,
int radius,
int edges,
Color color,
331 void filled_regular_polygon(
int x,
int y,
int radius,
int edges,
333 float rotation_degrees = ROTATION_0_DEGREES,
Color color = COLOR_ON);
335 void filled_regular_polygon(
int x,
int y,
int radius,
int edges,
Color color);
348 Color background = COLOR_OFF);
359 void print(
int x,
int y,
BaseFont *font,
Color color,
const char *text,
Color background = COLOR_OFF);
378 void print(
int x,
int y,
BaseFont *font,
const char *text);
427 void printf(
int x,
int y,
BaseFont *font,
TextAlign align,
const char *format, ...)
438 void printf(
int x,
int y,
BaseFont *font,
const char *format, ...)
__attribute__((format(printf, 5, 6)));
509 void image(
int x,
int y,
BaseImage *image,
Color color_on = COLOR_ON,
Color color_off = COLOR_OFF);
557 #ifdef USE_GRAPHICAL_DISPLAY_MENU 566 #endif // USE_GRAPHICAL_DISPLAY_MENU 580 void get_text_bounds(
int x,
int y,
const char *text,
BaseFont *font,
TextAlign align,
int *x1,
int *y1,
int *width,
587 void show_next_page();
588 void show_prev_page();
590 void set_pages(std::vector<DisplayPage *> pages);
600 void set_auto_clear(
bool auto_clear_enabled) { this->auto_clear_enabled_ = auto_clear_enabled; }
615 void start_clipping(
Rect rect);
617 start_clipping(
Rect(left, top, right - left, bottom - top));
625 void extend_clipping(
Rect rect);
627 this->extend_clipping(
Rect(left, top, right - left, bottom - top));
635 void shrink_clipping(
Rect rect);
637 this->shrink_clipping(
Rect(left, top, right - left, bottom - top));
648 Rect get_clipping()
const;
650 bool is_clipping()
const {
return !this->clipping_rectangle_.empty(); }
654 bool clip(
int x,
int y);
660 bool clamp_x_(
int x,
int w,
int &min_x,
int &max_x);
661 bool clamp_y_(
int y,
int h,
int &min_y,
int &max_y);
666 void clear_clipping_();
668 virtual int get_height_internal() = 0;
669 virtual int get_width_internal() = 0;
677 void filled_flat_side_triangle_(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
Color color);
678 void sort_triangle_points_by_y_(
int *x1,
int *y1,
int *x2,
int *y2,
int *x3,
int *y3);
685 bool auto_clear_enabled_{
true};
687 bool show_test_card_{
false};
696 void set_parent(
Display *parent);
712 void play(Ts...
x)
override {
713 auto *page = this->page_.value(
x...);
714 if (page !=
nullptr) {
724 void play(Ts...
x)
override { this->buffer_->show_next_page(); }
733 void play(Ts...
x)
override { this->buffer_->show_prev_page(); }
743 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)