ESPHome  2022.9.2
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::display::DisplayBuffer Class Referenceabstract

#include <display_buffer.h>

Inheritance diagram for esphome::display::DisplayBuffer:
esphome::addressable_light::AddressableLightDisplay esphome::ili9341::ILI9341Display esphome::inkplate6::Inkplate6 esphome::max7219digit::MAX7219Component esphome::pcd8544::PCD8544 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::st7735::ST7735 esphome::st7789v::ST7789V esphome::st7920::ST7920 esphome::waveshare_epaper::WaveshareEPaper

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...
 
int get_width ()
 Get the width of the image in pixels with rotation applied. More...
 
int get_height ()
 Get the height of the image in pixels with rotation applied. More...
 
void draw_pixel_at (int x, int y, Color color=COLOR_ON)
 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, Font *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, Font *font, Color color, const char *text)
 Print text with the top left at [x,y] with font. More...
 
void print (int x, int y, Font *font, TextAlign align, const char *text)
 Print text with the anchor point at [x,y] with font. More...
 
void print (int x, int y, Font *font, const char *text)
 Print text with the top left at [x,y] with font. More...
 
void printf (int x, int y, Font *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, Font *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, Font *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, Font *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, Font *font, Color color, TextAlign align, const char *format, time::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, Font *font, Color color, const char *format, time::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, Font *font, TextAlign align, const char *format, time::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, Font *font, const char *format, time::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, Image *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 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, Font *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)
 
virtual int get_height_internal ()=0
 
virtual int get_width_internal ()=0
 
DisplayRotation get_rotation () const
 
virtual DisplayType get_display_type ()=0
 Get the type of display that the buffer corresponds to. More...
 

Protected Member Functions

void vprintf_ (int x, int y, Font *font, Color color, TextAlign align, const char *format, va_list arg)
 
virtual void draw_absolute_pixel_internal (int x, int y, Color color)=0
 
void init_internal_ (uint32_t buffer_length)
 
void do_update_ ()
 

Protected Attributes

uint8_t * buffer_ {nullptr}
 
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}
 

Detailed Description

Definition at line 116 of file display_buffer.h.

Member Function Documentation

◆ add_on_page_change_trigger()

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

Definition at line 358 of file display_buffer.h.

◆ circle()

void HOT esphome::display::DisplayBuffer::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 114 of file display_buffer.cpp.

◆ clear()

void esphome::display::DisplayBuffer::clear ( )

Clear the entire screen by filling it with OFF pixels.

Definition at line 28 of file display_buffer.cpp.

◆ do_update_()

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

Definition at line 362 of file display_buffer.cpp.

◆ draw_absolute_pixel_internal()

virtual void esphome::display::DisplayBuffer::draw_absolute_pixel_internal ( int  x,
int  y,
Color  color 
)
protectedpure virtual

◆ draw_pixel_at()

void HOT esphome::display::DisplayBuffer::draw_pixel_at ( int  x,
int  y,
Color  color = COLOR_ON 
)

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

Definition at line 52 of file display_buffer.cpp.

◆ fill()

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

◆ filled_circle()

void esphome::display::DisplayBuffer::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 137 of file display_buffer.cpp.

◆ filled_rectangle()

void esphome::display::DisplayBuffer::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 108 of file display_buffer.cpp.

◆ get_active_page()

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

Definition at line 356 of file display_buffer.h.

◆ get_display_type()

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

◆ get_height()

int esphome::display::DisplayBuffer::get_height ( )

Get the height of the image in pixels with rotation applied.

Definition at line 40 of file display_buffer.cpp.

◆ get_height_internal()

virtual int esphome::display::DisplayBuffer::get_height_internal ( )
pure virtual

◆ get_rotation()

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

Definition at line 368 of file display_buffer.h.

◆ get_text_bounds()

void esphome::display::DisplayBuffer::get_text_bounds ( int  x,
int  y,
const char *  text,
Font 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 268 of file display_buffer.cpp.

◆ get_width()

int esphome::display::DisplayBuffer::get_width ( )

Get the width of the image in pixels with rotation applied.

Definition at line 29 of file display_buffer.cpp.

◆ get_width_internal()

virtual int esphome::display::DisplayBuffer::get_width_internal ( )
pure virtual

◆ graph()

void esphome::display::DisplayBuffer::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 256 of file display_buffer.cpp.

◆ horizontal_line()

void HOT esphome::display::DisplayBuffer::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 92 of file display_buffer.cpp.

◆ image()

void esphome::display::DisplayBuffer::image ( int  x,
int  y,
Image 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 214 of file display_buffer.cpp.

◆ init_internal_()

void esphome::display::DisplayBuffer::init_internal_ ( uint32_t  buffer_length)
protected

Definition at line 18 of file display_buffer.cpp.

◆ legend()

void esphome::display::DisplayBuffer::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 257 of file display_buffer.cpp.

◆ line()

void HOT esphome::display::DisplayBuffer::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 72 of file display_buffer.cpp.

◆ print() [1/4]

void esphome::display::DisplayBuffer::print ( int  x,
int  y,
Font font,
Color  color,
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.
colorThe color to draw the text with.
alignThe alignment of the text.
textThe text to draw.

Definition at line 164 of file display_buffer.cpp.

◆ print() [2/4]

void esphome::display::DisplayBuffer::print ( int  x,
int  y,
Font font,
Color  color,
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.
colorThe color to draw the text with.
textThe text to draw.

Definition at line 306 of file display_buffer.cpp.

◆ print() [3/4]

void esphome::display::DisplayBuffer::print ( int  x,
int  y,
Font 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 309 of file display_buffer.cpp.

◆ print() [4/4]

void esphome::display::DisplayBuffer::print ( int  x,
int  y,
Font 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 312 of file display_buffer.cpp.

◆ printf() [1/4]

void esphome::display::DisplayBuffer::printf ( int  x,
int  y,
Font 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 315 of file display_buffer.cpp.

◆ printf() [2/4]

void esphome::display::DisplayBuffer::printf ( int  x,
int  y,
Font 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 321 of file display_buffer.cpp.

◆ printf() [3/4]

void esphome::display::DisplayBuffer::printf ( int  x,
int  y,
Font 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 327 of file display_buffer.cpp.

◆ printf() [4/4]

void esphome::display::DisplayBuffer::printf ( int  x,
int  y,
Font 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 333 of file display_buffer.cpp.

◆ qr_code()

void esphome::display::DisplayBuffer::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 263 of file display_buffer.cpp.

◆ rectangle()

void esphome::display::DisplayBuffer::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 102 of file display_buffer.cpp.

◆ set_auto_clear()

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

Definition at line 364 of file display_buffer.h.

◆ set_pages()

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

Definition at line 340 of file display_buffer.cpp.

◆ set_rotation()

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

Internal method to set the display rotation with.

Definition at line 51 of file display_buffer.cpp.

◆ set_writer()

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

Internal method to set the display writer lambda.

Definition at line 339 of file display_buffer.cpp.

◆ show_next_page()

void esphome::display::DisplayBuffer::show_next_page ( )

Definition at line 360 of file display_buffer.cpp.

◆ show_page()

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

Definition at line 352 of file display_buffer.cpp.

◆ show_prev_page()

void esphome::display::DisplayBuffer::show_prev_page ( )

Definition at line 361 of file display_buffer.cpp.

◆ strftime() [1/4]

void esphome::display::DisplayBuffer::strftime ( int  x,
int  y,
Font font,
Color  color,
TextAlign  align,
const char *  format,
time::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 377 of file display_buffer.cpp.

◆ strftime() [2/4]

void esphome::display::DisplayBuffer::strftime ( int  x,
int  y,
Font font,
Color  color,
const char *  format,
time::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 384 of file display_buffer.cpp.

◆ strftime() [3/4]

void esphome::display::DisplayBuffer::strftime ( int  x,
int  y,
Font font,
TextAlign  align,
const char *  format,
time::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 387 of file display_buffer.cpp.

◆ strftime() [4/4]

void esphome::display::DisplayBuffer::strftime ( int  x,
int  y,
Font font,
const char *  format,
time::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 390 of file display_buffer.cpp.

◆ vertical_line()

void HOT esphome::display::DisplayBuffer::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 97 of file display_buffer.cpp.

◆ vprintf_()

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

Definition at line 207 of file display_buffer.cpp.

Field Documentation

◆ auto_clear_enabled_

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

Definition at line 390 of file display_buffer.h.

◆ buffer_

uint8_t* esphome::display::DisplayBuffer::buffer_ {nullptr}
protected

Definition at line 384 of file display_buffer.h.

◆ on_page_change_triggers_

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

Definition at line 389 of file display_buffer.h.

◆ page_

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

Definition at line 387 of file display_buffer.h.

◆ previous_page_

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

Definition at line 388 of file display_buffer.h.

◆ rotation_

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

Definition at line 385 of file display_buffer.h.

◆ writer_

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

Definition at line 386 of file display_buffer.h.


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