ESPHome  2021.9.1
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 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...
 

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
 
virtual int get_height_internal ()=0
 
virtual int get_width_internal ()=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_
 

Detailed Description

Definition at line 95 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 302 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 111 of file display_buffer.cpp.

◆ clear()

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

Clear the entire screen by filling it with OFF pixels.

Definition at line 25 of file display_buffer.cpp.

◆ do_update_()

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

Definition at line 330 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 49 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 134 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 105 of file display_buffer.cpp.

◆ get_active_page()

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

Definition at line 300 of file display_buffer.h.

◆ get_height()

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

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

Definition at line 37 of file display_buffer.cpp.

◆ get_height_internal()

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

◆ 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 236 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 26 of file display_buffer.cpp.

◆ get_width_internal()

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

◆ 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 89 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 210 of file display_buffer.cpp.

◆ init_internal_()

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

Definition at line 16 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 69 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 161 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 274 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 277 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 280 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 283 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 289 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 295 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 301 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 99 of file display_buffer.cpp.

◆ set_pages()

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

Definition at line 308 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 48 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 307 of file display_buffer.cpp.

◆ show_next_page()

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

Definition at line 328 of file display_buffer.cpp.

◆ show_page()

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

Definition at line 320 of file display_buffer.cpp.

◆ show_prev_page()

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

Definition at line 329 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 343 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 350 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 353 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 356 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 94 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 203 of file display_buffer.cpp.

Field Documentation

◆ buffer_

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

Definition at line 320 of file display_buffer.h.

◆ on_page_change_triggers_

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

Definition at line 325 of file display_buffer.h.

◆ page_

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

Definition at line 323 of file display_buffer.h.

◆ previous_page_

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

Definition at line 324 of file display_buffer.h.

◆ rotation_

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

Definition at line 321 of file display_buffer.h.

◆ writer_

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

Definition at line 322 of file display_buffer.h.


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