idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::lcd::panel Class Referenceabstract

Abstract base class for LCD panels. More...

Inheritance diagram for idfxx::lcd::panel:
idfxx::lcd::ili9341 idfxx::lcd::ssd1306

Classes

struct  config
 Configuration structure for LCD panels. More...
 

Public Member Functions

virtual ~panel ()=default
 
 panel (const panel &)=delete
 
paneloperator= (const panel &)=delete
 
esp_lcd_panel_handle_t idf_handle () const
 Returns the underlying ESP-IDF handle.
 
size_t width () const noexcept
 Returns the panel's native width in pixels.
 
size_t height () const noexcept
 Returns the panel's native height in pixels.
 
void draw_bitmap (int x_start, int y_start, int x_end, int y_end, const void *color_data)
 Draws bitmap data to a region of the display.
 
void invert_color (bool invert)
 Inverts the color of the display.
 
void swap_xy (bool swap)
 Swaps the X and Y axes.
 
void mirror (bool mirror_x, bool mirror_y)
 Mirrors the display.
 
void display_on (bool on)
 Turns the display on or off.
 
result< void > try_draw_bitmap (int x_start, int y_start, int x_end, int y_end, const void *color_data)
 Draws bitmap data to a region of the display.
 
result< void > try_invert_color (bool invert)
 Inverts the color of the display.
 
result< void > try_swap_xy (bool swap)
 Swaps the X and Y axes.
 
result< void > try_mirror (bool mirror_x, bool mirror_y)
 Mirrors the display.
 
result< void > try_display_on (bool on)
 Turns the display on or off.
 

Protected Member Functions

 panel ()=default
 
 panel (size_t width, size_t height) noexcept
 Constructs a panel reporting the given native dimensions.
 
 panel (panel &&) noexcept=default
 
paneloperator= (panel &&) noexcept=default
 
virtual esp_lcd_panel_handle_t do_idf_handle () const =0
 Hook for idf_handle.
 
virtual result< void > do_draw_bitmap (int x_start, int y_start, int x_end, int y_end, const void *color_data)
 Hook for try_draw_bitmap.
 
virtual result< void > do_invert_color (bool invert)
 Hook for try_invert_color.
 
virtual result< void > do_swap_xy (bool swap)
 Hook for try_swap_xy.
 
virtual result< void > do_mirror (bool mirror_x, bool mirror_y)
 Hook for try_mirror.
 
virtual result< void > do_display_on (bool on)
 Hook for try_display_on.
 

Detailed Description

Abstract base class for LCD panels.

The public interface is non-virtual; concrete drivers (e.g. idfxx::lcd::ili9341) customize behaviour by overriding the protected do_* hooks, mirroring the standard library's non-virtual-interface pattern (cf. std::pmr::memory_resource).

Definition at line 47 of file panel.hpp.

Constructor & Destructor Documentation

◆ ~panel()

virtual idfxx::lcd::panel::~panel ( )
virtualdefault

◆ panel() [1/4]

idfxx::lcd::panel::panel ( const panel )
delete

◆ panel() [2/4]

idfxx::lcd::panel::panel ( )
protecteddefault

◆ panel() [3/4]

idfxx::lcd::panel::panel ( size_t  width,
size_t  height 
)
inlineprotectednoexcept

Constructs a panel reporting the given native dimensions.

Definition at line 199 of file panel.hpp.

◆ panel() [4/4]

idfxx::lcd::panel::panel ( panel &&  )
protecteddefaultnoexcept

Member Function Documentation

◆ display_on()

void idfxx::lcd::panel::display_on ( bool  on)
inline

Turns the display on or off.

Parameters
ontrue to turn on, false to turn off.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 145 of file panel.hpp.

References try_display_on(), and idfxx::unwrap().

◆ do_display_on()

virtual result< void > idfxx::lcd::panel::do_display_on ( bool  on)
protectedvirtual

Hook for try_display_on.

The default implementation switches the display via the panel handle returned by do_idf_handle().

Referenced by try_display_on().

◆ do_draw_bitmap()

virtual result< void > idfxx::lcd::panel::do_draw_bitmap ( int  x_start,
int  y_start,
int  x_end,
int  y_end,
const void *  color_data 
)
protectedvirtual

Hook for try_draw_bitmap.

The default implementation draws via the panel handle returned by do_idf_handle().

Referenced by try_draw_bitmap().

◆ do_idf_handle()

virtual esp_lcd_panel_handle_t idfxx::lcd::panel::do_idf_handle ( ) const
protectedpure virtual

Hook for idf_handle.

Referenced by idf_handle().

◆ do_invert_color()

virtual result< void > idfxx::lcd::panel::do_invert_color ( bool  invert)
protectedvirtual

Hook for try_invert_color.

The default implementation inverts via the panel handle returned by do_idf_handle().

Referenced by try_invert_color().

◆ do_mirror()

virtual result< void > idfxx::lcd::panel::do_mirror ( bool  mirror_x,
bool  mirror_y 
)
protectedvirtual

Hook for try_mirror.

The default implementation mirrors via the panel handle returned by do_idf_handle().

Referenced by try_mirror().

◆ do_swap_xy()

virtual result< void > idfxx::lcd::panel::do_swap_xy ( bool  swap)
protectedvirtual

Hook for try_swap_xy.

The default implementation swaps via the panel handle returned by do_idf_handle().

Referenced by try_swap_xy().

◆ draw_bitmap()

void idfxx::lcd::panel::draw_bitmap ( int  x_start,
int  y_start,
int  x_end,
int  y_end,
const void *  color_data 
)
inline

Draws bitmap data to a region of the display.

The region is end-exclusive: it spans columns [x_start, x_end) and rows [y_start, y_end). The buffer layout of color_data is panel-specific (e.g. RGB565 pixels for color panels, page-packed 1-bpp data for monochrome OLEDs); consult the concrete driver's documentation.

Parameters
x_startStart column, inclusive.
y_startStart row, inclusive.
x_endEnd column, exclusive.
y_endEnd row, exclusive.
color_dataPixel data in the panel's native format.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 110 of file panel.hpp.

References try_draw_bitmap(), and idfxx::unwrap().

◆ height()

size_t idfxx::lcd::panel::height ( ) const
inlinenoexcept

Returns the panel's native height in pixels.

The native dimensions are fixed at construction and are not affected by swap_xy or mirror.

Returns
The height in pixels, or 0 if the driver does not report dimensions.

Definition at line 91 of file panel.hpp.

◆ idf_handle()

esp_lcd_panel_handle_t idfxx::lcd::panel::idf_handle ( ) const
inline

Returns the underlying ESP-IDF handle.

Returns
The ESP-IDF LCD panel handle.

Definition at line 71 of file panel.hpp.

References do_idf_handle().

◆ invert_color()

void idfxx::lcd::panel::invert_color ( bool  invert)
inline

Inverts the color of the display.

Parameters
inverttrue to invert colors, false for normal.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 120 of file panel.hpp.

References try_invert_color(), and idfxx::unwrap().

◆ mirror()

void idfxx::lcd::panel::mirror ( bool  mirror_x,
bool  mirror_y 
)
inline

Mirrors the display.

Parameters
mirror_xtrue to mirror horizontally.
mirror_ytrue to mirror vertically.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 137 of file panel.hpp.

References try_mirror(), and idfxx::unwrap().

◆ operator=() [1/2]

panel & idfxx::lcd::panel::operator= ( const panel )
delete

◆ operator=() [2/2]

panel & idfxx::lcd::panel::operator= ( panel &&  )
protecteddefaultnoexcept

◆ swap_xy()

void idfxx::lcd::panel::swap_xy ( bool  swap)
inline

Swaps the X and Y axes.

Parameters
swaptrue to swap, false for normal.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 128 of file panel.hpp.

References try_swap_xy(), and idfxx::unwrap().

◆ try_display_on()

result< void > idfxx::lcd::panel::try_display_on ( bool  on)
inline

Turns the display on or off.

Parameters
ontrue to turn on, false to turn off.
Returns
Success, or an error.

Definition at line 194 of file panel.hpp.

References do_display_on().

Referenced by display_on().

◆ try_draw_bitmap()

result< void > idfxx::lcd::panel::try_draw_bitmap ( int  x_start,
int  y_start,
int  x_end,
int  y_end,
const void *  color_data 
)
inline

Draws bitmap data to a region of the display.

The region is end-exclusive: it spans columns [x_start, x_end) and rows [y_start, y_end). The buffer layout of color_data is panel-specific (e.g. RGB565 pixels for color panels, page-packed 1-bpp data for monochrome OLEDs); consult the concrete driver's documentation.

Parameters
x_startStart column, inclusive.
y_startStart row, inclusive.
x_endEnd column, exclusive.
y_endEnd row, exclusive.
color_dataPixel data in the panel's native format.
Returns
Success, or an error.

Definition at line 163 of file panel.hpp.

References do_draw_bitmap().

Referenced by draw_bitmap(), idfxx::lcd::mono_framebuffer::try_flush(), idfxx::lcd::rgb565_framebuffer::try_flush(), idfxx::lcd::mono_framebuffer::try_flush_region(), and idfxx::lcd::rgb565_framebuffer::try_flush_region().

◆ try_invert_color()

result< void > idfxx::lcd::panel::try_invert_color ( bool  invert)
inline

Inverts the color of the display.

Parameters
inverttrue to invert colors, false for normal.
Returns
Success, or an error.

Definition at line 172 of file panel.hpp.

References do_invert_color().

Referenced by invert_color().

◆ try_mirror()

result< void > idfxx::lcd::panel::try_mirror ( bool  mirror_x,
bool  mirror_y 
)
inline

Mirrors the display.

Parameters
mirror_xtrue to mirror horizontally.
mirror_ytrue to mirror vertically.
Returns
Success, or an error.

Definition at line 187 of file panel.hpp.

References do_mirror().

Referenced by mirror().

◆ try_swap_xy()

result< void > idfxx::lcd::panel::try_swap_xy ( bool  swap)
inline

Swaps the X and Y axes.

Parameters
swaptrue to swap, false for normal.
Returns
Success, or an error.

Definition at line 179 of file panel.hpp.

References do_swap_xy().

Referenced by swap_xy().

◆ width()

size_t idfxx::lcd::panel::width ( ) const
inlinenoexcept

Returns the panel's native width in pixels.

The native dimensions are fixed at construction and are not affected by swap_xy or mirror.

Returns
The width in pixels, or 0 if the driver does not report dimensions.

Definition at line 81 of file panel.hpp.


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