idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::epaper::mono_framebuffer Class Reference

In-memory framebuffer for monochrome (1 bit per pixel) ePaper displays. More...

Public Types

using pixel_type = bool
 The value type written by set_pixel — true is black ink.
 

Public Member Functions

 mono_framebuffer (size_t width, size_t height)
 Creates a framebuffer of the given dimensions, with all pixels white.
 
size_t width () const noexcept
 Returns the width in pixels.
 
size_t height () const noexcept
 Returns the height in pixels.
 
size_t stride_bytes () const noexcept
 Returns the number of bytes per row.
 
void set_pixel (size_t x, size_t y, bool ink) noexcept
 Inks or blanks a single pixel.
 
bool get_pixel (size_t x, size_t y) const noexcept
 Returns the state of a single pixel.
 
void fill (bool ink) noexcept
 Sets every pixel to the given state.
 
void clear () noexcept
 Blanks every pixel to white (equivalent to fill(false)).
 
std::span< const uint8_t > data () const noexcept
 Returns the raw row-major pixel data.
 
std::span< const uint8_t > row (size_t y) const noexcept
 Returns the raw bytes of a single row.
 
void flush (panel &panel, size_t x=0, size_t y=0) const
 Uploads the full framebuffer to a panel's RAM.
 
void flush_rows (panel &panel, size_t y_start, size_t y_end) const
 Uploads a horizontal band of the framebuffer to a panel's RAM.
 
result< void > try_flush (panel &panel, size_t x=0, size_t y=0) const
 Uploads the full framebuffer to a panel's RAM.
 
result< void > try_flush_rows (panel &panel, size_t y_start, size_t y_end) const
 Uploads a horizontal band of the framebuffer to a panel's RAM.
 

Static Public Member Functions

static result< mono_framebuffermake (size_t width, size_t height)
 Creates a framebuffer of the given dimensions, with all pixels white.
 

Detailed Description

In-memory framebuffer for monochrome (1 bit per pixel) ePaper displays.

Pixels are stored row-major with byte-padded rows, the native format of SSD1680- and UC8179-style ePaper controllers: each byte holds 8 horizontally adjacent pixels (bit 7 is the leftmost), rows are laid out top-to-bottom, and each row is padded to a whole number of bytes (stride_bytes). The byte for pixel (x, y) is at index y * stride_bytes() + x / 8, bit 7 - x % 8. Following the controllers' RAM convention, a set bit is white paper and a cleared bit is black ink; a new framebuffer starts all-white, and set_pixel(x, y, true) inks a pixel black.

Draw into the framebuffer with set_pixel and friends, then upload it to a panel's RAM with flush (full frame) or flush_rows (a horizontal band), and make it visible with panel::refresh. This is a plain value type: copyable, movable, and independent of any panel.

idfxx::epaper::mono_framebuffer fb(display.width(), display.height());
fb.set_pixel(10, 20, true);
fb.flush(display);
display.refresh();
In-memory framebuffer for monochrome (1 bit per pixel) ePaper displays.

Definition at line 54 of file mono_framebuffer.hpp.

Member Typedef Documentation

◆ pixel_type

The value type written by set_pixel — true is black ink.

Definition at line 57 of file mono_framebuffer.hpp.

Constructor & Destructor Documentation

◆ mono_framebuffer()

idfxx::epaper::mono_framebuffer::mono_framebuffer ( size_t  width,
size_t  height 
)
inline

Creates a framebuffer of the given dimensions, with all pixels white.

Parameters
widthWidth in pixels; must be non-zero.
heightHeight in pixels; must be non-zero.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error (e.g. invalid dimensions).

Definition at line 69 of file mono_framebuffer.hpp.

Member Function Documentation

◆ clear()

void idfxx::epaper::mono_framebuffer::clear ( )
inlinenoexcept

Blanks every pixel to white (equivalent to fill(false)).

Definition at line 150 of file mono_framebuffer.hpp.

References fill().

◆ data()

std::span< const uint8_t > idfxx::epaper::mono_framebuffer::data ( ) const
inlinenoexcept

Returns the raw row-major pixel data.

The span holds stride_bytes() * height() bytes in the layout described in the class documentation, suitable for streaming directly to an ePaper controller's RAM.

Returns
A read-only view of the pixel data.

Definition at line 161 of file mono_framebuffer.hpp.

◆ fill()

void idfxx::epaper::mono_framebuffer::fill ( bool  ink)
inlinenoexcept

Sets every pixel to the given state.

Parameters
inktrue to ink all pixels black, false to blank them white.

Definition at line 147 of file mono_framebuffer.hpp.

Referenced by clear().

◆ flush()

void idfxx::epaper::mono_framebuffer::flush ( panel panel,
size_t  x = 0,
size_t  y = 0 
) const
inline

Uploads the full framebuffer to a panel's RAM.

Places the framebuffer's origin at panel pixel (x, y). The upload is invisible until the next panel::refresh.

Parameters
panelThe panel to upload to.
xDestination column; must be a multiple of 8.
yDestination row.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 189 of file mono_framebuffer.hpp.

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

◆ flush_rows()

void idfxx::epaper::mono_framebuffer::flush_rows ( panel panel,
size_t  y_start,
size_t  y_end 
) const
inline

Uploads a horizontal band of the framebuffer to a panel's RAM.

The band spans rows [y_start, y_end) across the full width and lands at the same rows on the panel. The upload is invisible until the next panel::refresh.

Parameters
panelThe panel to upload to.
y_startFirst row of the band, inclusive.
y_endEnd row of the band, exclusive; must satisfy y_start < y_end <= height().
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error (e.g. an invalid row range).

Definition at line 204 of file mono_framebuffer.hpp.

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

◆ get_pixel()

bool idfxx::epaper::mono_framebuffer::get_pixel ( size_t  x,
size_t  y 
) const
inlinenoexcept

Returns the state of a single pixel.

Parameters
xColumn, in [0, width()).
yRow, in [0, height()).
Returns
true if the pixel is black ink; false if it is white or the coordinates are out of range.

Definition at line 136 of file mono_framebuffer.hpp.

References stride_bytes().

◆ height()

size_t idfxx::epaper::mono_framebuffer::height ( ) const
inlinenoexcept

Returns the height in pixels.

Definition at line 93 of file mono_framebuffer.hpp.

Referenced by make().

◆ make()

static result< mono_framebuffer > idfxx::epaper::mono_framebuffer::make ( size_t  width,
size_t  height 
)
inlinestatic

Creates a framebuffer of the given dimensions, with all pixels white.

Parameters
widthWidth in pixels; must be non-zero.
heightHeight in pixels; must be non-zero.
Returns
The new mono_framebuffer, or an error.
Return values
idfxx::errc::invalid_argif width or height is zero.

Definition at line 82 of file mono_framebuffer.hpp.

References idfxx::error(), height(), idfxx::invalid_arg, and width().

◆ row()

std::span< const uint8_t > idfxx::epaper::mono_framebuffer::row ( size_t  y) const
inlinenoexcept

Returns the raw bytes of a single row.

Unlike set_pixel / get_pixel, the raw views do not tolerate out-of-range arguments: passing one is undefined behavior.

Parameters
yRow, in [0, height()).
Returns
A read-only view of the row's stride_bytes bytes.

Definition at line 172 of file mono_framebuffer.hpp.

References stride_bytes().

◆ set_pixel()

void idfxx::epaper::mono_framebuffer::set_pixel ( size_t  x,
size_t  y,
bool  ink 
)
inlinenoexcept

Inks or blanks a single pixel.

Out-of-range coordinates are ignored.

Parameters
xColumn, in [0, width()).
yRow, in [0, height()).
inktrue for black ink, false for white paper.

Definition at line 114 of file mono_framebuffer.hpp.

References stride_bytes().

◆ stride_bytes()

size_t idfxx::epaper::mono_framebuffer::stride_bytes ( ) const
inlinenoexcept

Returns the number of bytes per row.

Rows are padded to whole bytes: (width() + 7) / 8. Padding bits sit past the right edge and stay white.

Returns
The row stride, in bytes.

Definition at line 103 of file mono_framebuffer.hpp.

Referenced by get_pixel(), row(), and set_pixel().

◆ try_flush()

result< void > idfxx::epaper::mono_framebuffer::try_flush ( panel panel,
size_t  x = 0,
size_t  y = 0 
) const
inline

Uploads the full framebuffer to a panel's RAM.

Places the framebuffer's origin at panel pixel (x, y). The upload is invisible until the next panel::try_refresh.

Parameters
panelThe panel to upload to.
xDestination column; must be a multiple of 8.
yDestination row.
Returns
Success, or an error.

Definition at line 218 of file mono_framebuffer.hpp.

References idfxx::epaper::panel::try_write().

Referenced by flush().

◆ try_flush_rows()

result< void > idfxx::epaper::mono_framebuffer::try_flush_rows ( panel panel,
size_t  y_start,
size_t  y_end 
) const
inline

Uploads a horizontal band of the framebuffer to a panel's RAM.

The band spans rows [y_start, y_end) across the full width and lands at the same rows on the panel. The upload is invisible until the next panel::try_refresh.

Parameters
panelThe panel to upload to.
y_startFirst row of the band, inclusive.
y_endEnd row of the band, exclusive; must satisfy y_start < y_end <= height().
Returns
Success, or an error.
Return values
idfxx::errc::invalid_argif the row range is invalid.

Definition at line 235 of file mono_framebuffer.hpp.

References idfxx::epaper::panel::try_write_rows().

Referenced by flush_rows().

◆ width()

size_t idfxx::epaper::mono_framebuffer::width ( ) const
inlinenoexcept

Returns the width in pixels.

Definition at line 90 of file mono_framebuffer.hpp.

Referenced by make().


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