|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
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_framebuffer > | make (size_t width, size_t height) |
| Creates a framebuffer of the given dimensions, with all pixels white. | |
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.
Definition at line 54 of file mono_framebuffer.hpp.
| using idfxx::epaper::mono_framebuffer::pixel_type = bool |
The value type written by set_pixel — true is black ink.
Definition at line 57 of file mono_framebuffer.hpp.
|
inline |
Creates a framebuffer of the given dimensions, with all pixels white.
| width | Width in pixels; must be non-zero. |
| height | Height in pixels; must be non-zero. |
| std::system_error | on error (e.g. invalid dimensions). |
Definition at line 69 of file mono_framebuffer.hpp.
|
inlinenoexcept |
Blanks every pixel to white (equivalent to fill(false)).
Definition at line 150 of file mono_framebuffer.hpp.
References fill().
|
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.
Definition at line 161 of file mono_framebuffer.hpp.
|
inlinenoexcept |
Sets every pixel to the given state.
| ink | true to ink all pixels black, false to blank them white. |
Definition at line 147 of file mono_framebuffer.hpp.
Referenced by clear().
|
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.
| panel | The panel to upload to. |
| x | Destination column; must be a multiple of 8. |
| y | Destination row. |
| std::system_error | on error. |
Definition at line 189 of file mono_framebuffer.hpp.
References try_flush(), and idfxx::unwrap().
|
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.
| panel | The panel to upload to. |
| y_start | First row of the band, inclusive. |
| y_end | End row of the band, exclusive; must satisfy y_start < y_end <= height(). |
| std::system_error | on error (e.g. an invalid row range). |
Definition at line 204 of file mono_framebuffer.hpp.
References try_flush_rows(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the state of a single pixel.
Definition at line 136 of file mono_framebuffer.hpp.
References stride_bytes().
|
inlinenoexcept |
Returns the height in pixels.
Definition at line 93 of file mono_framebuffer.hpp.
Referenced by make().
|
inlinestatic |
Creates a framebuffer of the given dimensions, with all pixels white.
| width | Width in pixels; must be non-zero. |
| height | Height in pixels; must be non-zero. |
| idfxx::errc::invalid_arg | if width or height is zero. |
Definition at line 82 of file mono_framebuffer.hpp.
References idfxx::error(), height(), idfxx::invalid_arg, and width().
|
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.
| y | Row, in [0, height()). |
Definition at line 172 of file mono_framebuffer.hpp.
References stride_bytes().
|
inlinenoexcept |
Inks or blanks a single pixel.
Out-of-range coordinates are ignored.
| x | Column, in [0, width()). |
| y | Row, in [0, height()). |
| ink | true for black ink, false for white paper. |
Definition at line 114 of file mono_framebuffer.hpp.
References stride_bytes().
|
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.
Definition at line 103 of file mono_framebuffer.hpp.
Referenced by get_pixel(), row(), and set_pixel().
|
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.
| panel | The panel to upload to. |
| x | Destination column; must be a multiple of 8. |
| y | Destination row. |
Definition at line 218 of file mono_framebuffer.hpp.
References idfxx::epaper::panel::try_write().
Referenced by flush().
|
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.
| panel | The panel to upload to. |
| y_start | First row of the band, inclusive. |
| y_end | End row of the band, exclusive; must satisfy y_start < y_end <= height(). |
| idfxx::errc::invalid_arg | if 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().
|
inlinenoexcept |
Returns the width in pixels.
Definition at line 90 of file mono_framebuffer.hpp.
Referenced by make().