ESPHome  2024.10.2
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::display::Display Class Referenceabstract

#include <display.h>

Inheritance diagram for esphome::display::Display:
esphome::PollingComponent esphome::Component esphome::display::DisplayBuffer esphome::rpi_dpi_rgb::RpiDpiRgb esphome::sdl::Sdl esphome::st7701s::ST7701S esphome::addressable_light::AddressableLightDisplay esphome::ili9xxx::ILI9XXXDisplay esphome::inkplate6::Inkplate6 esphome::max7219digit::MAX7219Component esphome::pcd8544::PCD8544 esphome::qspi_amoled::QspiAmoLed esphome::ssd1306_base::SSD1306 esphome::ssd1322_base::SSD1322 esphome::ssd1325_base::SSD1325 esphome::ssd1327_base::SSD1327 esphome::ssd1331_base::SSD1331 esphome::ssd1351_base::SSD1351 esphome::st7567_base::ST7567 esphome::st7735::ST7735 esphome::st7789v::ST7789V esphome::st7920::ST7920 esphome::waveshare_epaper::WaveshareEPaperBase

Public Member Functions

virtual void fill (Color color)
 Fill the entire screen with the given color. More...
 
void clear ()
 Clear the entire screen by filling it with OFF pixels. More...
 
virtual int get_width ()
 Get the calculated width of the display in pixels with rotation applied. More...
 
virtual int get_height ()
 Get the calculated height of the display in pixels with rotation applied. More...
 
int get_native_width ()
 Get the native (original) width of the display in pixels. More...
 
int get_native_height ()
 Get the native (original) height of the display in pixels. More...
 
void draw_pixel_at (int x, int y)
 Set a single pixel at the specified coordinates to default color. More...
 
virtual void draw_pixel_at (int x, int y, Color color)=0
 Set a single pixel at the specified coordinates to the given color. More...
 
virtual 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, int x_offset, int y_offset, int x_pad)
 Given an array of pixels encoded in the nominated format, draw these into the display's buffer. More...
 
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.g. suits LVGL.) More...
 
void line (int x1, int y1, int x2, int y2, Color color=COLOR_ON)
 Draw a straight line from the point [x1,y1] to [x2,y2] with the given color. More...
 
void line_at_angle (int x, int y, int angle, int length, Color color=COLOR_ON)
 Draw a straight line at the given angle based on the origin [x, y] for a specified length with the given color. More...
 
void line_at_angle (int x, int y, int angle, int start_radius, int stop_radius, Color color=COLOR_ON)
 Draw a straight line at the given angle based on the origin [x, y] from a specified start and stop radius with the given color. More...
 
void horizontal_line (int x, int y, int width, Color color=COLOR_ON)
 Draw a horizontal line from the point [x,y] to [x+width,y] with the given color. More...
 
void vertical_line (int x, int y, int height, Color color=COLOR_ON)
 Draw a vertical line from the point [x,y] to [x,y+width] with the given color. More...
 
void rectangle (int x1, int y1, int width, int height, Color color=COLOR_ON)
 Draw the outline of a rectangle with the top left point at [x1,y1] and the bottom right point at [x1+width,y1+height]. More...
 
void filled_rectangle (int x1, int y1, int width, int height, Color color=COLOR_ON)
 Fill a rectangle with the top left point at [x1,y1] and the bottom right point at [x1+width,y1+height]. More...
 
void circle (int center_x, int center_xy, int radius, Color color=COLOR_ON)
 Draw the outline of a circle centered around [center_x,center_y] with the radius radius with the given color. More...
 
void filled_circle (int center_x, int center_y, int radius, Color color=COLOR_ON)
 Fill a circle centered around [center_x,center_y] with the radius radius with the given color. More...
 
void triangle (int x1, int y1, int x2, int y2, int x3, int y3, Color color=COLOR_ON)
 Draw the outline of a triangle contained between the points [x1,y1], [x2,y2] and [x3,y3] with the given color. More...
 
void filled_triangle (int x1, int y1, int x2, int y2, int x3, int y3, Color color=COLOR_ON)
 Fill a triangle contained between the points [x1,y1], [x2,y2] and [x3,y3] with the given color. More...
 
void get_regular_polygon_vertex (int vertex_id, int *vertex_x, int *vertex_y, int center_x, int center_y, int radius, int edges, RegularPolygonVariation variation=VARIATION_POINTY_TOP, float rotation_degrees=ROTATION_0_DEGREES)
 Get the specified vertex (x,y) coordinates for the regular polygon inscribed in the circle centered on [center_x,center_y] with the given radius. More...
 
void regular_polygon (int x, int y, int radius, int edges, RegularPolygonVariation variation=VARIATION_POINTY_TOP, float rotation_degrees=ROTATION_0_DEGREES, Color color=COLOR_ON, RegularPolygonDrawing drawing=DRAWING_OUTLINE)
 Draw the outline of a regular polygon inscribed in the circle centered on [x,y] with the given radius and color. More...
 
void regular_polygon (int x, int y, int radius, int edges, RegularPolygonVariation variation, Color color, RegularPolygonDrawing drawing=DRAWING_OUTLINE)
 
void regular_polygon (int x, int y, int radius, int edges, Color color, RegularPolygonDrawing drawing=DRAWING_OUTLINE)
 
void filled_regular_polygon (int x, int y, int radius, int edges, RegularPolygonVariation variation=VARIATION_POINTY_TOP, float rotation_degrees=ROTATION_0_DEGREES, Color color=COLOR_ON)
 Fill a regular polygon inscribed in the circle centered on [x,y] with the given radius and color. More...
 
void filled_regular_polygon (int x, int y, int radius, int edges, RegularPolygonVariation variation, Color color)
 
void filled_regular_polygon (int x, int y, int radius, int edges, Color color)
 
void print (int x, int y, BaseFont *font, Color color, TextAlign align, const char *text, Color background=COLOR_OFF)
 Print text with the anchor point at [x,y] with font. More...
 
void print (int x, int y, BaseFont *font, Color color, const char *text, Color background=COLOR_OFF)
 Print text with the top left at [x,y] with font. More...
 
void print (int x, int y, BaseFont *font, TextAlign align, const char *text)
 Print text with the anchor point at [x,y] with font. More...
 
void print (int x, int y, BaseFont *font, const char *text)
 Print text with the top left at [x,y] with font. More...
 
void printf (int x, int y, BaseFont *font, Color color, Color background, TextAlign align, const char *format,...) __attribute__((format(printf
 Evaluate the printf-format format and print the result with the anchor point at [x,y] with font. More...
 
void void printf (int x, int y, BaseFont *font, Color color, TextAlign align, const char *format,...) __attribute__((format(printf
 Evaluate the printf-format format and print the result with the anchor point at [x,y] with font. More...
 
void void void printf (int x, int y, BaseFont *font, Color color, const char *format,...) __attribute__((format(printf
 Evaluate the printf-format format and print the result with the top left at [x,y] with font. More...
 
void void void void printf (int x, int y, BaseFont *font, TextAlign align, const char *format,...) __attribute__((format(printf
 Evaluate the printf-format format and print the result with the anchor point at [x,y] with font. More...
 
void void void void void printf (int x, int y, BaseFont *font, const char *format,...) __attribute__((format(printf
 Evaluate the printf-format format and print the result with the top left at [x,y] with font. More...
 
void void void void void void strftime (int x, int y, BaseFont *font, Color color, TextAlign align, const char *format, ESPTime time) __attribute__((format(strftime
 Evaluate the strftime-format format and print the result with the anchor point at [x,y] with font. More...
 
void void void void void void void strftime (int x, int y, BaseFont *font, Color color, const char *format, ESPTime time) __attribute__((format(strftime
 Evaluate the strftime-format format and print the result with the top left at [x,y] with font. More...
 
void void void void void void void void strftime (int x, int y, BaseFont *font, TextAlign align, const char *format, ESPTime time) __attribute__((format(strftime
 Evaluate the strftime-format format and print the result with the anchor point at [x,y] with font. More...
 
void void void void void void void void void strftime (int x, int y, BaseFont *font, const char *format, ESPTime time) __attribute__((format(strftime
 Evaluate the strftime-format format and print the result with the top left at [x,y] with font. More...
 
void void void void void void void void void void image (int x, int y, BaseImage *image, Color color_on=COLOR_ON, Color color_off=COLOR_OFF)
 Draw the image with the top-left corner at [x,y] to the screen. More...
 
void image (int x, int y, BaseImage *image, ImageAlign align, Color color_on=COLOR_ON, Color color_off=COLOR_OFF)
 Draw the image at [x,y] to the screen. More...
 
void graph (int x, int y, graph::Graph *graph, Color color_on=COLOR_ON)
 Draw the graph with the top-left corner at [x,y] to the screen. More...
 
void legend (int x, int y, graph::Graph *graph, Color color_on=COLOR_ON)
 Draw the legend for graph with the top-left corner at [x,y] to the screen. More...
 
void qr_code (int x, int y, qr_code::QrCode *qr_code, Color color_on=COLOR_ON, int scale=1)
 Draw the qr_code with the top-left corner at [x,y] to the screen. More...
 
void menu (int x, int y, graphical_display_menu::GraphicalDisplayMenu *menu, int width, int height)
 
void get_text_bounds (int x, int y, const char *text, BaseFont *font, TextAlign align, int *x1, int *y1, int *width, int *height)
 Get the text bounds of the given string. More...
 
void set_writer (display_writer_t &&writer)
 Internal method to set the display writer lambda. More...
 
void show_page (DisplayPage *page)
 
void show_next_page ()
 
void show_prev_page ()
 
void set_pages (std::vector< DisplayPage *> pages)
 
const DisplayPageget_active_page () const
 
void add_on_page_change_trigger (DisplayOnPageChangeTrigger *t)
 
void set_rotation (DisplayRotation rotation)
 Internal method to set the display rotation with. More...
 
void set_auto_clear (bool auto_clear_enabled)
 
DisplayRotation get_rotation () const
 
virtual DisplayType get_display_type ()=0
 Get the type of display that the buffer corresponds to. More...
 
void start_clipping (Rect rect)
 Set the clipping rectangle for further drawing. More...
 
void start_clipping (int16_t left, int16_t top, int16_t right, int16_t bottom)
 
void extend_clipping (Rect rect)
 Add a rectangular region to the invalidation region. More...
 
void extend_clipping (int16_t left, int16_t top, int16_t right, int16_t bottom)
 
void shrink_clipping (Rect rect)
 substract a rectangular region to the invalidation region More...
 
void shrink_clipping (uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
 
void end_clipping ()
 Reset the invalidation region. More...
 
Rect get_clipping () const
 Get the current the clipping rectangle. More...
 
bool is_clipping () const
 
bool clip (int x, int y)
 Check if pixel is within region of display. More...
 
void test_card ()
 
void show_test_card ()
 
- Public Member Functions inherited from esphome::PollingComponent
 PollingComponent ()
 
 PollingComponent (uint32_t update_interval)
 Initialize this polling component with the given update interval in ms. More...
 
virtual void set_update_interval (uint32_t update_interval)
 Manually set the update interval in ms for this polling object. More...
 
virtual void update ()=0
 
void call_setup () override
 
virtual uint32_t get_update_interval () const
 Get the update interval in ms of this sensor. More...
 
void start_poller ()
 
void stop_poller ()
 
- Public Member Functions inherited from esphome::Component
virtual void setup ()
 Where the component's initialization should happen. More...
 
virtual void loop ()
 This method will be called repeatedly. More...
 
virtual void dump_config ()
 
virtual float get_setup_priority () const
 priority of setup(). More...
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning (const char *message="unspecified")
 
void status_set_error (const char *message="unspecified")
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 

Protected Member Functions

bool clamp_x_ (int x, int w, int &min_x, int &max_x)
 
bool clamp_y_ (int y, int h, int &min_y, int &max_y)
 
void vprintf_ (int x, int y, BaseFont *font, Color color, Color background, TextAlign align, const char *format, va_list arg)
 
void do_update_ ()
 
void clear_clipping_ ()
 
virtual int get_height_internal ()=0
 
virtual int get_width_internal ()=0
 
void filled_flat_side_triangle_ (int x1, int y1, int x2, int y2, int x3, int y3, Color color)
 This method fills a triangle using only integer variables by using a modified bresenham algorithm. More...
 
void sort_triangle_points_by_y_ (int *x1, int *y1, int *x2, int *y2, int *x3, int *y3)
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Protected Attributes

DisplayRotation rotation_ {DISPLAY_ROTATION_0_DEGREES}
 
optional< display_writer_twriter_ {}
 
DisplayPagepage_ {nullptr}
 
DisplayPageprevious_page_ {nullptr}
 
std::vector< DisplayOnPageChangeTrigger * > on_page_change_triggers_
 
bool auto_clear_enabled_ {true}
 
std::vector< Rectclipping_rectangle_
 
bool show_test_card_ {false}
 
- Protected Attributes inherited from esphome::PollingComponent
uint32_t update_interval_
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ {nullptr}
 

Detailed Description

Definition at line 208 of file display.h.

Member Function Documentation

◆ add_on_page_change_trigger()

void esphome::display::Display::add_on_page_change_trigger ( DisplayOnPageChangeTrigger t)
inline

Definition at line 573 of file display.h.

◆ circle()

void HOT esphome::display::Display::circle ( int  center_x,
int  center_xy,
int  radius,
Color  color = COLOR_ON 
)

Draw the outline of a circle centered around [center_x,center_y] with the radius radius with the given color.

Definition at line 110 of file display.cpp.

◆ clamp_x_()

bool esphome::display::Display::clamp_x_ ( int  x,
int  w,
int &  min_x,
int &  max_x 
)
protected

Definition at line 582 of file display.cpp.

◆ clamp_y_()

bool esphome::display::Display::clamp_y_ ( int  y,
int  h,
int &  min_y,
int &  max_y 
)
protected

Definition at line 597 of file display.cpp.

◆ clear()

void esphome::display::Display::clear ( )

Clear the entire screen by filling it with OFF pixels.

Definition at line 16 of file display.cpp.

◆ clear_clipping_()

void esphome::display::Display::clear_clipping_ ( )
protected

Definition at line 574 of file display.cpp.

◆ clip()

bool esphome::display::Display::clip ( int  x,
int  y 
)

Check if pixel is within region of display.

Definition at line 575 of file display.cpp.

◆ do_update_()

void esphome::display::Display::do_update_ ( )
protected

Definition at line 506 of file display.cpp.

◆ draw_pixel_at() [1/2]

void esphome::display::Display::draw_pixel_at ( int  x,
int  y 
)
inline

Set a single pixel at the specified coordinates to default color.

Definition at line 226 of file display.h.

◆ draw_pixel_at() [2/2]

virtual void esphome::display::Display::draw_pixel_at ( int  x,
int  y,
Color  color 
)
pure virtual

Set a single pixel at the specified coordinates to the given color.

Implemented in esphome::st7701s::ST7701S, esphome::rpi_dpi_rgb::RpiDpiRgb, esphome::sdl::Sdl, and esphome::display::DisplayBuffer.

◆ draw_pixels_at() [1/2]

void esphome::display::Display::draw_pixels_at ( int  x_start,
int  y_start,
int  w,
int  h,
const uint8_t *  ptr,
ColorOrder  order,
ColorBitness  bitness,
bool  big_endian,
int  x_offset,
int  y_offset,
int  x_pad 
)
virtual

Given an array of pixels encoded in the nominated format, draw these into the display's buffer.

The naive implementation here will work in all cases, but can be overridden by sub-classes in order to optimise the procedure. The parameters describe a rectangular block of pixels, potentially within a larger buffer.

Parameters
x_startThe starting destination x position
y_startThe starting destination y position
wthe width of the pixel block
hthe height of the pixel block
ptrA pointer to the start of the data to be copied
orderThe ordering of the colors
bitnessDefines the number of bits and their format for each pixel
big_endianTrue if 16 bit values are stored big-endian
x_offsetThe initial x-offset into the source buffer.
y_offsetThe initial y-offset into the source buffer.
x_padHow many pixels are in each line after the end of the pixels to be copied.

The length of each source buffer line (stride) will be x_offset + w + x_pad.

Reimplemented in esphome::qspi_amoled::QspiAmoLed, esphome::ili9xxx::ILI9XXXDisplay, esphome::st7701s::ST7701S, esphome::rpi_dpi_rgb::RpiDpiRgb, and esphome::sdl::Sdl.

Definition at line 54 of file display.cpp.

◆ draw_pixels_at() [2/2]

void esphome::display::Display::draw_pixels_at ( int  x_start,
int  y_start,
int  w,
int  h,
const uint8_t *  ptr,
ColorOrder  order,
ColorBitness  bitness,
bool  big_endian 
)
inline

Convenience overload for base case where the pixels are packed into the buffer with no gaps (e.g. suits LVGL.)

Definition at line 254 of file display.h.

◆ end_clipping()

void esphome::display::Display::end_clipping ( )

Reset the invalidation region.

Definition at line 546 of file display.cpp.

◆ extend_clipping() [1/2]

void esphome::display::Display::extend_clipping ( Rect  rect)

Add a rectangular region to the invalidation region.

  • This is usually called when an element has been modified
Parameters
[in]rectRectangle to add to the invalidation region

Definition at line 553 of file display.cpp.

◆ extend_clipping() [2/2]

void esphome::display::Display::extend_clipping ( int16_t  left,
int16_t  top,
int16_t  right,
int16_t  bottom 
)
inline

Definition at line 605 of file display.h.

◆ fill()

void esphome::display::Display::fill ( Color  color)
virtual

◆ filled_circle()

void esphome::display::Display::filled_circle ( int  center_x,
int  center_y,
int  radius,
Color  color = COLOR_ON 
)

Fill a circle centered around [center_x,center_y] with the radius radius with the given color.

Definition at line 133 of file display.cpp.

◆ filled_flat_side_triangle_()

void esphome::display::Display::filled_flat_side_triangle_ ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
Color  color 
)
protected

This method fills a triangle using only integer variables by using a modified bresenham algorithm.

It is mandatory that [x2,y2] and [x3,y3] lie on the same horizontal line, so y2 must be equal to y3.

Definition at line 181 of file display.cpp.

◆ filled_rectangle()

void esphome::display::Display::filled_rectangle ( int  x1,
int  y1,
int  width,
int  height,
Color  color = COLOR_ON 
)

Fill a rectangle with the top left point at [x1,y1] and the bottom right point at [x1+width,y1+height].

Definition at line 104 of file display.cpp.

◆ filled_regular_polygon() [1/3]

void esphome::display::Display::filled_regular_polygon ( int  x,
int  y,
int  radius,
int  edges,
RegularPolygonVariation  variation = VARIATION_POINTY_TOP,
float  rotation_degrees = ROTATION_0_DEGREES,
Color  color = COLOR_ON 
)

Fill a regular polygon inscribed in the circle centered on [x,y] with the given radius and color.

Use the edges constants (e.g.: EDGES_HEXAGON) or any integer to specify the number of edges of the polygon. Use the variation to switch between the flat-topped or the pointy-topped variation of the polygon. Use the rotation in degrees to rotate the shape clockwise.

Definition at line 325 of file display.cpp.

◆ filled_regular_polygon() [2/3]

void esphome::display::Display::filled_regular_polygon ( int  x,
int  y,
int  radius,
int  edges,
RegularPolygonVariation  variation,
Color  color 
)

Definition at line 329 of file display.cpp.

◆ filled_regular_polygon() [3/3]

void esphome::display::Display::filled_regular_polygon ( int  x,
int  y,
int  radius,
int  edges,
Color  color 
)

Definition at line 333 of file display.cpp.

◆ filled_triangle()

void esphome::display::Display::filled_triangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
Color  color = COLOR_ON 
)

Fill a triangle contained between the points [x1,y1], [x2,y2] and [x3,y3] with the given color.

Definition at line 261 of file display.cpp.

◆ get_active_page()

const DisplayPage* esphome::display::Display::get_active_page ( ) const
inline

Definition at line 571 of file display.h.

◆ get_clipping()

Rect esphome::display::Display::get_clipping ( ) const

Get the current the clipping rectangle.

return rect for active clipping region

Definition at line 567 of file display.cpp.

◆ get_display_type()

virtual DisplayType esphome::display::Display::get_display_type ( )
pure virtual

◆ get_height()

virtual int esphome::display::Display::get_height ( )
inlinevirtual

Get the calculated height of the display in pixels with rotation applied.

Reimplemented in esphome::st7701s::ST7701S, esphome::rpi_dpi_rgb::RpiDpiRgb, esphome::sdl::Sdl, and esphome::display::DisplayBuffer.

Definition at line 218 of file display.h.

◆ get_height_internal()

virtual int esphome::display::Display::get_height_internal ( )
protectedpure virtual

Implemented in esphome::waveshare_epaper::WaveshareEPaper13P3InK, esphome::waveshare_epaper::WaveshareEPaper2P13InV3, esphome::waveshare_epaper::WaveshareEPaper2P13InDKE, esphome::waveshare_epaper::WaveshareEPaper7P5InHDB, esphome::waveshare_epaper::WaveshareEPaper7P5InV2, esphome::waveshare_epaper::WaveshareEPaper7P5InBC, esphome::waveshare_epaper::WaveshareEPaper7P5InBV3, esphome::waveshare_epaper::WaveshareEPaper7P5InBV2, esphome::waveshare_epaper::WaveshareEPaper7P5In, esphome::waveshare_epaper::WaveshareEPaper5P8InV2, esphome::waveshare_epaper::WaveshareEPaper5P8In, esphome::waveshare_epaper::WaveshareEPaper4P2InBV2, esphome::waveshare_epaper::WaveshareEPaper4P2In, esphome::waveshare_epaper::WaveshareEPaper2P9InDKE, esphome::waveshare_epaper::WaveshareEPaper2P9InV2R2, esphome::waveshare_epaper::WaveshareEPaper2P9InBV3, esphome::waveshare_epaper::WaveshareEPaper2P9InB, esphome::waveshare_epaper::GDEW0154M09, esphome::waveshare_epaper::WaveshareEPaper2P7InV2, esphome::waveshare_epaper::GDEW029T5, esphome::waveshare_epaper::WaveshareEPaper2P7InBV2, esphome::waveshare_epaper::WaveshareEPaper2P7InB, esphome::waveshare_epaper::WaveshareEPaper2P7In, esphome::inkplate6::Inkplate6, esphome::st7789v::ST7789V, esphome::waveshare_epaper::WaveshareEPaperTypeA, esphome::ili9xxx::ILI9XXXDisplay, esphome::qspi_amoled::QspiAmoLed, esphome::st7567_base::ST7567, esphome::st7701s::ST7701S, esphome::st7735::ST7735, esphome::pcd8544::PCD8544, esphome::ssd1306_base::SSD1306, esphome::rpi_dpi_rgb::RpiDpiRgb, esphome::max7219digit::MAX7219Component, esphome::addressable_light::AddressableLightDisplay, esphome::ssd1325_base::SSD1325, esphome::ssd1351_base::SSD1351, esphome::ssd1322_base::SSD1322, esphome::ssd1327_base::SSD1327, esphome::sdl::Sdl, esphome::ssd1331_base::SSD1331, and esphome::st7920::ST7920.

◆ get_native_height()

int esphome::display::Display::get_native_height ( )
inline

Get the native (original) height of the display in pixels.

Definition at line 223 of file display.h.

◆ get_native_width()

int esphome::display::Display::get_native_width ( )
inline

Get the native (original) width of the display in pixels.

Definition at line 221 of file display.h.

◆ get_regular_polygon_vertex()

void HOT esphome::display::Display::get_regular_polygon_vertex ( int  vertex_id,
int *  vertex_x,
int *  vertex_y,
int  center_x,
int  center_y,
int  radius,
int  edges,
RegularPolygonVariation  variation = VARIATION_POINTY_TOP,
float  rotation_degrees = ROTATION_0_DEGREES 
)

Get the specified vertex (x,y) coordinates for the regular polygon inscribed in the circle centered on [center_x,center_y] with the given radius.

Vertex id are 0-indexed and rotate clockwise. In a pointy-topped variation of a polygon with a 0° rotation, the vertex #0 is located at the top of the polygon. In a flat-topped variation of a polygon with a 0° rotation, the vertex #0 is located on the left-side of the horizontal top edge, and the vertex #1 is located on the right-side of the horizontal top edge. Use the edges constants (e.g.: EDGES_HEXAGON) or any integer to specify the number of edges of the polygon. Use the variation to switch between the flat-topped or the pointy-topped variation of the polygon. Use the rotation in degrees to rotate the shape clockwise.

Definition at line 275 of file display.cpp.

◆ get_rotation()

DisplayRotation esphome::display::Display::get_rotation ( ) const
inline

Definition at line 581 of file display.h.

◆ get_text_bounds()

void esphome::display::Display::get_text_bounds ( int  x,
int  y,
const char *  text,
BaseFont font,
TextAlign  align,
int *  x1,
int *  y1,
int *  width,
int *  height 
)

Get the text bounds of the given string.

Parameters
xThe x coordinate to place the string at, can be 0 if only interested in dimensions.
yThe y coordinate to place the string at, can be 0 if only interested in dimensions.
textThe text to measure.
fontThe font to measure the text bounds with.
alignThe alignment of the text. Set to TextAlign::TOP_LEFT if only interested in dimensions.
x1A pointer to store the returned x coordinate of the upper left corner in.
y1A pointer to store the returned y coordinate of the upper left corner in.
widthA pointer to store the returned text width in.
heightA pointer to store the returned text height in.

Definition at line 405 of file display.cpp.

◆ get_width()

virtual int esphome::display::Display::get_width ( )
inlinevirtual

Get the calculated width of the display in pixels with rotation applied.

Reimplemented in esphome::st7701s::ST7701S, esphome::rpi_dpi_rgb::RpiDpiRgb, esphome::sdl::Sdl, and esphome::display::DisplayBuffer.

Definition at line 216 of file display.h.

◆ get_width_internal()

virtual int esphome::display::Display::get_width_internal ( )
protectedpure virtual

Implemented in esphome::waveshare_epaper::WaveshareEPaper13P3InK, esphome::waveshare_epaper::WaveshareEPaper2P13InV3, esphome::waveshare_epaper::WaveshareEPaper2P13InDKE, esphome::waveshare_epaper::WaveshareEPaper7P5InHDB, esphome::waveshare_epaper::WaveshareEPaper7P5InV2, esphome::waveshare_epaper::WaveshareEPaper7P5InBC, esphome::waveshare_epaper::WaveshareEPaper7P5InBV3, esphome::waveshare_epaper::WaveshareEPaper7P5InBV2, esphome::waveshare_epaper::WaveshareEPaper7P5In, esphome::waveshare_epaper::WaveshareEPaper5P8InV2, esphome::waveshare_epaper::WaveshareEPaper5P8In, esphome::waveshare_epaper::WaveshareEPaper4P2InBV2, esphome::waveshare_epaper::WaveshareEPaper4P2In, esphome::waveshare_epaper::WaveshareEPaper2P9InDKE, esphome::waveshare_epaper::WaveshareEPaper2P9InV2R2, esphome::waveshare_epaper::WaveshareEPaper2P9InBV3, esphome::waveshare_epaper::WaveshareEPaper2P9InB, esphome::waveshare_epaper::GDEW0154M09, esphome::waveshare_epaper::WaveshareEPaper2P7InV2, esphome::waveshare_epaper::GDEW029T5, esphome::waveshare_epaper::WaveshareEPaper2P7InBV2, esphome::waveshare_epaper::WaveshareEPaper2P7InB, esphome::waveshare_epaper::WaveshareEPaper2P7In, esphome::inkplate6::Inkplate6, esphome::st7789v::ST7789V, esphome::waveshare_epaper::WaveshareEPaperTypeA, esphome::ili9xxx::ILI9XXXDisplay, esphome::qspi_amoled::QspiAmoLed, esphome::st7567_base::ST7567, esphome::st7701s::ST7701S, esphome::st7735::ST7735, esphome::pcd8544::PCD8544, esphome::ssd1306_base::SSD1306, esphome::rpi_dpi_rgb::RpiDpiRgb, esphome::max7219digit::MAX7219Component, esphome::addressable_light::AddressableLightDisplay, esphome::ssd1325_base::SSD1325, esphome::ssd1351_base::SSD1351, esphome::ssd1322_base::SSD1322, esphome::ssd1327_base::SSD1327, esphome::sdl::Sdl, esphome::ssd1331_base::SSD1331, and esphome::st7920::ST7920.

◆ graph()

void esphome::display::Display::graph ( int  x,
int  y,
graph::Graph graph,
Color  color_on = COLOR_ON 
)

Draw the graph with the top-left corner at [x,y] to the screen.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
graphThe graph id to draw
color_onThe color to replace in binary images for the on bits.

Definition at line 388 of file display.cpp.

◆ horizontal_line()

void HOT esphome::display::Display::horizontal_line ( int  x,
int  y,
int  width,
Color  color = COLOR_ON 
)

Draw a horizontal line from the point [x,y] to [x+width,y] with the given color.

Definition at line 88 of file display.cpp.

◆ image() [1/2]

void esphome::display::Display::image ( int  x,
int  y,
BaseImage image,
Color  color_on = COLOR_ON,
Color  color_off = COLOR_OFF 
)

Draw the image with the top-left corner at [x,y] to the screen.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
imageThe image to draw.
color_onThe color to replace in binary images for the on bits.
color_offThe color to replace in binary images for the off bits.

Definition at line 352 of file display.cpp.

◆ image() [2/2]

void esphome::display::Display::image ( int  x,
int  y,
BaseImage image,
ImageAlign  align,
Color  color_on = COLOR_ON,
Color  color_off = COLOR_OFF 
)

Draw the image at [x,y] to the screen.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
imageThe image to draw.
alignThe alignment of the image.
color_onThe color to replace in binary images for the on bits.
color_offThe color to replace in binary images for the off bits.

Definition at line 356 of file display.cpp.

◆ is_clipping()

bool esphome::display::Display::is_clipping ( ) const
inline

Definition at line 629 of file display.h.

◆ legend()

void esphome::display::Display::legend ( int  x,
int  y,
graph::Graph graph,
Color  color_on = COLOR_ON 
)

Draw the legend for graph with the top-left corner at [x,y] to the screen.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
graphThe graph id for which the legend applies to
graphThe graph id for which the legend applies to
graphThe graph id for which the legend applies to
name_fontThe font used for the trace name
value_fontThe font used for the trace value and units
color_onThe color of the border

Definition at line 389 of file display.cpp.

◆ line()

void HOT esphome::display::Display::line ( int  x1,
int  y1,
int  x2,
int  y2,
Color  color = COLOR_ON 
)

Draw a straight line from the point [x1,y1] to [x2,y2] with the given color.

Definition at line 18 of file display.cpp.

◆ line_at_angle() [1/2]

void esphome::display::Display::line_at_angle ( int  x,
int  y,
int  angle,
int  length,
Color  color = COLOR_ON 
)

Draw a straight line at the given angle based on the origin [x, y] for a specified length with the given color.

Definition at line 39 of file display.cpp.

◆ line_at_angle() [2/2]

void esphome::display::Display::line_at_angle ( int  x,
int  y,
int  angle,
int  start_radius,
int  stop_radius,
Color  color = COLOR_ON 
)

Draw a straight line at the given angle based on the origin [x, y] from a specified start and stop radius with the given color.

Definition at line 43 of file display.cpp.

◆ menu()

void esphome::display::Display::menu ( int  x,
int  y,
graphical_display_menu::GraphicalDisplayMenu menu,
int  width,
int  height 
)
Parameters
xThe x coordinate of the upper left corner
yThe y coordinate of the upper left corner
menuThe GraphicalDisplayMenu to draw
widthWidth of the menu
heightHeight of the menu

Definition at line 399 of file display.cpp.

◆ print() [1/4]

void esphome::display::Display::print ( int  x,
int  y,
BaseFont font,
Color  color,
TextAlign  align,
const char *  text,
Color  background = COLOR_OFF 
)

Print text with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
colorThe color to draw the text with.
alignThe alignment of the text.
textThe text to draw.
backgroundWhen using multi-bit (anti-aliased) fonts, blend this background color into pixels

Definition at line 337 of file display.cpp.

◆ print() [2/4]

void esphome::display::Display::print ( int  x,
int  y,
BaseFont font,
Color  color,
const char *  text,
Color  background = COLOR_OFF 
)

Print text with the top left at [x,y] with font.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
fontThe font to draw the text with.
colorThe color to draw the text with.
textThe text to draw.
backgroundWhen using multi-bit (anti-aliased) fonts, blend this background color into pixels

Definition at line 443 of file display.cpp.

◆ print() [3/4]

void esphome::display::Display::print ( int  x,
int  y,
BaseFont font,
TextAlign  align,
const char *  text 
)

Print text with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
alignThe alignment of the text.
textThe text to draw.

Definition at line 446 of file display.cpp.

◆ print() [4/4]

void esphome::display::Display::print ( int  x,
int  y,
BaseFont font,
const char *  text 
)

Print text with the top left at [x,y] with font.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
fontThe font to draw the text with.
textThe text to draw.

Definition at line 449 of file display.cpp.

◆ printf() [1/5]

void esphome::display::Display::printf ( int  x,
int  y,
BaseFont font,
Color  color,
Color  background,
TextAlign  align,
const char *  format,
  ... 
)

Evaluate the printf-format format and print the result with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
colorThe color to draw the text with.
backgroundThe background color to use for anti-aliasing
alignThe alignment of the text.
formatThe format to use.
...The arguments to use for the text formatting.

Definition at line 452 of file display.cpp.

◆ printf() [2/5]

void esphome::display::Display::printf ( int  x,
int  y,
BaseFont font,
Color  color,
TextAlign  align,
const char *  format,
  ... 
)

Evaluate the printf-format format and print the result with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
colorThe color to draw the text with.
alignThe alignment of the text.
formatThe format to use.
...The arguments to use for the text formatting.

Definition at line 459 of file display.cpp.

◆ printf() [3/5]

void esphome::display::Display::printf ( int  x,
int  y,
BaseFont font,
Color  color,
const char *  format,
  ... 
)

Evaluate the printf-format format and print the result with the top left at [x,y] with font.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
fontThe font to draw the text with.
colorThe color to draw the text with.
formatThe format to use.
...The arguments to use for the text formatting.

Definition at line 465 of file display.cpp.

◆ printf() [4/5]

void esphome::display::Display::printf ( int  x,
int  y,
BaseFont font,
TextAlign  align,
const char *  format,
  ... 
)

Evaluate the printf-format format and print the result with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
alignThe alignment of the text.
formatThe format to use.
...The arguments to use for the text formatting.

Definition at line 471 of file display.cpp.

◆ printf() [5/5]

void esphome::display::Display::printf ( int  x,
int  y,
BaseFont font,
const char *  format,
  ... 
)

Evaluate the printf-format format and print the result with the top left at [x,y] with font.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
fontThe font to draw the text with.
formatThe format to use.
...The arguments to use for the text formatting.

Definition at line 477 of file display.cpp.

◆ qr_code()

void esphome::display::Display::qr_code ( int  x,
int  y,
qr_code::QrCode qr_code,
Color  color_on = COLOR_ON,
int  scale = 1 
)

Draw the qr_code with the top-left corner at [x,y] to the screen.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
qr_codeThe qr_code to draw
color_onThe color to replace in binary images for the on bits.

Definition at line 393 of file display.cpp.

◆ rectangle()

void esphome::display::Display::rectangle ( int  x1,
int  y1,
int  width,
int  height,
Color  color = COLOR_ON 
)

Draw the outline of a rectangle with the top left point at [x1,y1] and the bottom right point at [x1+width,y1+height].

Definition at line 98 of file display.cpp.

◆ regular_polygon() [1/3]

void HOT esphome::display::Display::regular_polygon ( int  x,
int  y,
int  radius,
int  edges,
RegularPolygonVariation  variation = VARIATION_POINTY_TOP,
float  rotation_degrees = ROTATION_0_DEGREES,
Color  color = COLOR_ON,
RegularPolygonDrawing  drawing = DRAWING_OUTLINE 
)

Draw the outline of a regular polygon inscribed in the circle centered on [x,y] with the given radius and color.

Use the edges constants (e.g.: EDGES_HEXAGON) or any integer to specify the number of edges of the polygon. Use the variation to switch between the flat-topped or the pointy-topped variation of the polygon. Use the rotation in degrees to rotate the shape clockwise. Use the drawing to switch between outlining or filling the polygon.

Definition at line 298 of file display.cpp.

◆ regular_polygon() [2/3]

void HOT esphome::display::Display::regular_polygon ( int  x,
int  y,
int  radius,
int  edges,
RegularPolygonVariation  variation,
Color  color,
RegularPolygonDrawing  drawing = DRAWING_OUTLINE 
)

Definition at line 318 of file display.cpp.

◆ regular_polygon() [3/3]

void HOT esphome::display::Display::regular_polygon ( int  x,
int  y,
int  radius,
int  edges,
Color  color,
RegularPolygonDrawing  drawing = DRAWING_OUTLINE 
)

Definition at line 322 of file display.cpp.

◆ set_auto_clear()

void esphome::display::Display::set_auto_clear ( bool  auto_clear_enabled)
inline

Definition at line 579 of file display.h.

◆ set_pages()

void esphome::display::Display::set_pages ( std::vector< DisplayPage *>  pages)

Definition at line 484 of file display.cpp.

◆ set_rotation()

void esphome::display::Display::set_rotation ( DisplayRotation  rotation)

Internal method to set the display rotation with.

Definition at line 17 of file display.cpp.

◆ set_writer()

void esphome::display::Display::set_writer ( display_writer_t &&  writer)

Internal method to set the display writer lambda.

Definition at line 483 of file display.cpp.

◆ show_next_page()

void esphome::display::Display::show_next_page ( )

Definition at line 504 of file display.cpp.

◆ show_page()

void esphome::display::Display::show_page ( DisplayPage page)

Definition at line 496 of file display.cpp.

◆ show_prev_page()

void esphome::display::Display::show_prev_page ( )

Definition at line 505 of file display.cpp.

◆ show_test_card()

void esphome::display::Display::show_test_card ( )
inline

Definition at line 636 of file display.h.

◆ shrink_clipping() [1/2]

void esphome::display::Display::shrink_clipping ( Rect  rect)

substract a rectangular region to the invalidation region

  • This is usually called when an element has been modified
Parameters
[in]rectRectangle to add to the invalidation region

Definition at line 560 of file display.cpp.

◆ shrink_clipping() [2/2]

void esphome::display::Display::shrink_clipping ( uint16_t  left,
uint16_t  top,
uint16_t  right,
uint16_t  bottom 
)
inline

Definition at line 615 of file display.h.

◆ sort_triangle_points_by_y_()

void esphome::display::Display::sort_triangle_points_by_y_ ( int *  x1,
int *  y1,
int *  x2,
int *  y2,
int *  x3,
int *  y3 
)
protected

Definition at line 164 of file display.cpp.

◆ start_clipping() [1/2]

void esphome::display::Display::start_clipping ( Rect  rect)

Set the clipping rectangle for further drawing.

Parameters
[in]rectPointer to Rect for clipping (or NULL for entire screen)

return true if success, false if error

Definition at line 539 of file display.cpp.

◆ start_clipping() [2/2]

void esphome::display::Display::start_clipping ( int16_t  left,
int16_t  top,
int16_t  right,
int16_t  bottom 
)
inline

Definition at line 595 of file display.h.

◆ strftime() [1/4]

void esphome::display::Display::strftime ( int  x,
int  y,
BaseFont font,
Color  color,
TextAlign  align,
const char *  format,
ESPTime  time 
)

Evaluate the strftime-format format and print the result with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
colorThe color to draw the text with.
alignThe alignment of the text.
formatThe strftime format to use.
timeThe time to format.

Definition at line 523 of file display.cpp.

◆ strftime() [2/4]

void esphome::display::Display::strftime ( int  x,
int  y,
BaseFont font,
Color  color,
const char *  format,
ESPTime  time 
)

Evaluate the strftime-format format and print the result with the top left at [x,y] with font.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
fontThe font to draw the text with.
colorThe color to draw the text with.
formatThe strftime format to use.
timeThe time to format.

Definition at line 529 of file display.cpp.

◆ strftime() [3/4]

void esphome::display::Display::strftime ( int  x,
int  y,
BaseFont font,
TextAlign  align,
const char *  format,
ESPTime  time 
)

Evaluate the strftime-format format and print the result with the anchor point at [x,y] with font.

Parameters
xThe x coordinate of the text alignment anchor point.
yThe y coordinate of the text alignment anchor point.
fontThe font to draw the text with.
alignThe alignment of the text.
formatThe strftime format to use.
timeThe time to format.

Definition at line 532 of file display.cpp.

◆ strftime() [4/4]

void esphome::display::Display::strftime ( int  x,
int  y,
BaseFont font,
const char *  format,
ESPTime  time 
)

Evaluate the strftime-format format and print the result with the top left at [x,y] with font.

Parameters
xThe x coordinate of the upper left corner.
yThe y coordinate of the upper left corner.
fontThe font to draw the text with.
formatThe strftime format to use.
timeThe time to format.

Definition at line 535 of file display.cpp.

◆ test_card()

void esphome::display::Display::test_card ( )

Definition at line 617 of file display.cpp.

◆ triangle()

void HOT esphome::display::Display::triangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
Color  color = COLOR_ON 
)

Draw the outline of a triangle contained between the points [x1,y1], [x2,y2] and [x3,y3] with the given color.

Definition at line 159 of file display.cpp.

◆ vertical_line()

void HOT esphome::display::Display::vertical_line ( int  x,
int  y,
int  height,
Color  color = COLOR_ON 
)

Draw a vertical line from the point [x,y] to [x,y+width] with the given color.

Definition at line 93 of file display.cpp.

◆ vprintf_()

void esphome::display::Display::vprintf_ ( int  x,
int  y,
BaseFont font,
Color  color,
Color  background,
TextAlign  align,
const char *  format,
va_list  arg 
)
protected

Definition at line 344 of file display.cpp.

Field Documentation

◆ auto_clear_enabled_

bool esphome::display::Display::auto_clear_enabled_ {true}
protected

Definition at line 664 of file display.h.

◆ clipping_rectangle_

std::vector<Rect> esphome::display::Display::clipping_rectangle_
protected

Definition at line 665 of file display.h.

◆ on_page_change_triggers_

std::vector<DisplayOnPageChangeTrigger *> esphome::display::Display::on_page_change_triggers_
protected

Definition at line 663 of file display.h.

◆ page_

DisplayPage* esphome::display::Display::page_ {nullptr}
protected

Definition at line 661 of file display.h.

◆ previous_page_

DisplayPage* esphome::display::Display::previous_page_ {nullptr}
protected

Definition at line 662 of file display.h.

◆ rotation_

DisplayRotation esphome::display::Display::rotation_ {DISPLAY_ROTATION_0_DEGREES}
protected

Definition at line 659 of file display.h.

◆ show_test_card_

bool esphome::display::Display::show_test_card_ {false}
protected

Definition at line 666 of file display.h.

◆ writer_

optional<display_writer_t> esphome::display::Display::writer_ {}
protected

Definition at line 660 of file display.h.


The documentation for this class was generated from the following files: