ESPHome
2023.11.6
|
#include <display.h>
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 ()=0 |
Get the width of the image in pixels with rotation applied. More... | |
virtual int | get_height ()=0 |
Get the height of the image in pixels with rotation applied. 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... | |
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 | 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 | print (int x, int y, BaseFont *font, Color color, 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, Color color, const char *text) |
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, 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, 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 DisplayPage * | get_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... | |
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, TextAlign align, const char *format, va_list arg) |
void | do_update_ () |
void | clear_clipping_ () |
Protected Attributes | |
DisplayRotation | rotation_ {DISPLAY_ROTATION_0_DEGREES} |
optional< display_writer_t > | writer_ {} |
DisplayPage * | page_ {nullptr} |
DisplayPage * | previous_page_ {nullptr} |
std::vector< DisplayOnPageChangeTrigger * > | on_page_change_triggers_ |
bool | auto_clear_enabled_ {true} |
std::vector< Rect > | clipping_rectangle_ |
|
inline |
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 60 of file display.cpp.
|
protected |
Definition at line 337 of file display.cpp.
|
protected |
Definition at line 352 of file display.cpp.
void esphome::display::Display::clear | ( | ) |
Clear the entire screen by filling it with OFF pixels.
Definition at line 16 of file display.cpp.
|
protected |
Definition at line 329 of file display.cpp.
bool esphome::display::Display::clip | ( | int | x, |
int | y | ||
) |
Check if pixel is within region of display.
Definition at line 330 of file display.cpp.
|
protected |
Definition at line 263 of file display.cpp.
|
inline |
|
pure virtual |
Set a single pixel at the specified coordinates to the given color.
Implemented in esphome::display::DisplayBuffer.
void esphome::display::Display::end_clipping | ( | ) |
Reset the invalidation region.
Definition at line 301 of file display.cpp.
void esphome::display::Display::extend_clipping | ( | Rect | rect | ) |
Add a rectangular region to the invalidation region.
[in] | rect | Rectangle to add to the invalidation region |
Definition at line 308 of file display.cpp.
|
inline |
|
virtual |
Fill the entire screen with the given color.
Reimplemented in esphome::inkplate6::Inkplate6, esphome::ssd1306_base::SSD1306, esphome::pcd8544::PCD8544, esphome::ili9xxx::ILI9XXXDisplay, esphome::ssd1325_base::SSD1325, esphome::ssd1351_base::SSD1351, esphome::ssd1322_base::SSD1322, esphome::ssd1327_base::SSD1327, esphome::waveshare_epaper::WaveshareEPaper, esphome::st7920::ST7920, and esphome::ssd1331_base::SSD1331.
Definition at line 15 of file display.cpp.
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 83 of file display.cpp.
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 54 of file display.cpp.
|
inline |
Rect esphome::display::Display::get_clipping | ( | ) | const |
Get the current the clipping rectangle.
return rect for active clipping region
Definition at line 322 of file display.cpp.
|
pure virtual |
Get the type of display that the buffer corresponds to.
In case of dynamically configurable displays, returns the type the display is currently configured to.
Implemented in esphome::st7789v::ST7789V, esphome::inkplate6::Inkplate6, esphome::max7219digit::MAX7219Component, esphome::st7735::ST7735, esphome::pcd8544::PCD8544, esphome::ssd1306_base::SSD1306, esphome::ili9xxx::ILI9XXXDisplay, esphome::addressable_light::AddressableLightDisplay, esphome::waveshare_epaper::WaveshareEPaper, esphome::ssd1325_base::SSD1325, esphome::ssd1351_base::SSD1351, esphome::ssd1322_base::SSD1322, esphome::ssd1327_base::SSD1327, esphome::st7920::ST7920, and esphome::ssd1331_base::SSD1331.
|
pure virtual |
Get the height of the image in pixels with rotation applied.
Implemented in esphome::display::DisplayBuffer.
|
inline |
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.
x | The x coordinate to place the string at, can be 0 if only interested in dimensions. |
y | The y coordinate to place the string at, can be 0 if only interested in dimensions. |
text | The text to measure. |
font | The font to measure the text bounds with. |
align | The alignment of the text. Set to TextAlign::TOP_LEFT if only interested in dimensions. |
x1 | A pointer to store the returned x coordinate of the upper left corner in. |
y1 | A pointer to store the returned y coordinate of the upper left corner in. |
width | A pointer to store the returned text width in. |
height | A pointer to store the returned text height in. |
Definition at line 169 of file display.cpp.
|
pure virtual |
Get the width of the image in pixels with rotation applied.
Implemented in esphome::display::DisplayBuffer.
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.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
graph | The graph id to draw |
color_on | The color to replace in binary images for the on bits. |
Definition at line 159 of file display.cpp.
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 38 of file display.cpp.
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.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
image | The image to draw. |
color_on | The color to replace in binary images for the on bits. |
color_off | The color to replace in binary images for the off bits. |
Definition at line 123 of file display.cpp.
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.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
image | The image to draw. |
align | The alignment of the image. |
color_on | The color to replace in binary images for the on bits. |
color_off | The color to replace in binary images for the off bits. |
Definition at line 127 of file display.cpp.
|
inline |
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.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
graph | The graph id for which the legend applies to |
graph | The graph id for which the legend applies to |
graph | The graph id for which the legend applies to |
name_font | The font used for the trace name |
value_font | The font used for the trace value and units |
color_on | The color of the border |
Definition at line 160 of file display.cpp.
Draw a straight line from the point [x1,y1] to [x2,y2] with the given color.
Definition at line 18 of file display.cpp.
void esphome::display::Display::print | ( | int | x, |
int | y, | ||
BaseFont * | font, | ||
Color | color, | ||
TextAlign | align, | ||
const char * | text | ||
) |
Print text
with the anchor point at [x,y] with font
.
x | The x coordinate of the text alignment anchor point. |
y | The y coordinate of the text alignment anchor point. |
font | The font to draw the text with. |
color | The color to draw the text with. |
align | The alignment of the text. |
text | The text to draw. |
Definition at line 110 of file display.cpp.
void esphome::display::Display::print | ( | int | x, |
int | y, | ||
BaseFont * | font, | ||
Color | color, | ||
const char * | text | ||
) |
Print text
with the top left at [x,y] with font
.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
font | The font to draw the text with. |
color | The color to draw the text with. |
text | The text to draw. |
Definition at line 207 of file display.cpp.
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
.
x | The x coordinate of the text alignment anchor point. |
y | The y coordinate of the text alignment anchor point. |
font | The font to draw the text with. |
align | The alignment of the text. |
text | The text to draw. |
Definition at line 210 of file display.cpp.
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
.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
font | The font to draw the text with. |
text | The text to draw. |
Definition at line 213 of file display.cpp.
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
.
x | The x coordinate of the text alignment anchor point. |
y | The y coordinate of the text alignment anchor point. |
font | The font to draw the text with. |
color | The color to draw the text with. |
align | The alignment of the text. |
format | The format to use. |
... | The arguments to use for the text formatting. |
Definition at line 216 of file display.cpp.
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
.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
font | The font to draw the text with. |
color | The color to draw the text with. |
format | The format to use. |
... | The arguments to use for the text formatting. |
Definition at line 222 of file display.cpp.
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
.
x | The x coordinate of the text alignment anchor point. |
y | The y coordinate of the text alignment anchor point. |
font | The font to draw the text with. |
align | The alignment of the text. |
format | The format to use. |
... | The arguments to use for the text formatting. |
Definition at line 228 of file display.cpp.
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
.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
font | The font to draw the text with. |
format | The format to use. |
... | The arguments to use for the text formatting. |
Definition at line 234 of file display.cpp.
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.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
qr_code | The qr_code to draw |
color_on | The color to replace in binary images for the on bits. |
Definition at line 164 of file display.cpp.
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 48 of file display.cpp.
|
inline |
void esphome::display::Display::set_pages | ( | std::vector< DisplayPage *> | pages | ) |
Definition at line 241 of file display.cpp.
void esphome::display::Display::set_rotation | ( | DisplayRotation | rotation | ) |
Internal method to set the display rotation with.
Definition at line 17 of file display.cpp.
void esphome::display::Display::set_writer | ( | display_writer_t && | writer | ) |
Internal method to set the display writer lambda.
Definition at line 240 of file display.cpp.
void esphome::display::Display::show_next_page | ( | ) |
Definition at line 261 of file display.cpp.
void esphome::display::Display::show_page | ( | DisplayPage * | page | ) |
Definition at line 253 of file display.cpp.
void esphome::display::Display::show_prev_page | ( | ) |
Definition at line 262 of file display.cpp.
void esphome::display::Display::shrink_clipping | ( | Rect | rect | ) |
substract a rectangular region to the invalidation region
[in] | rect | Rectangle to add to the invalidation region |
Definition at line 315 of file display.cpp.
|
inline |
void esphome::display::Display::start_clipping | ( | Rect | rect | ) |
Set the clipping rectangle for further drawing.
[in] | rect | Pointer to Rect for clipping (or NULL for entire screen) |
return true if success, false if error
Definition at line 294 of file display.cpp.
|
inline |
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
.
x | The x coordinate of the text alignment anchor point. |
y | The y coordinate of the text alignment anchor point. |
font | The font to draw the text with. |
color | The color to draw the text with. |
align | The alignment of the text. |
format | The strftime format to use. |
time | The time to format. |
Definition at line 278 of file display.cpp.
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
.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
font | The font to draw the text with. |
color | The color to draw the text with. |
format | The strftime format to use. |
time | The time to format. |
Definition at line 284 of file display.cpp.
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
.
x | The x coordinate of the text alignment anchor point. |
y | The y coordinate of the text alignment anchor point. |
font | The font to draw the text with. |
align | The alignment of the text. |
format | The strftime format to use. |
time | The time to format. |
Definition at line 287 of file display.cpp.
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
.
x | The x coordinate of the upper left corner. |
y | The y coordinate of the upper left corner. |
font | The font to draw the text with. |
format | The strftime format to use. |
time | The time to format. |
Definition at line 290 of file display.cpp.
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 43 of file display.cpp.
|
protected |
Definition at line 116 of file display.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |