|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
In-memory framebuffer for 4-level grayscale ePaper displays. More...
Public Types | |
| using | pixel_type = gray4 |
| The value type written by set_pixel. | |
Public Member Functions | |
| gray4_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 within each plane. | |
| void | set_pixel (size_t x, size_t y, gray4 level) noexcept |
| Sets a single pixel to the given gray level. | |
| gray4 | get_pixel (size_t x, size_t y) const noexcept |
| Returns the gray level of a single pixel. | |
| void | fill (gray4 level) noexcept |
| Sets every pixel to the given gray level. | |
| void | clear () noexcept |
Blanks every pixel to white (equivalent to fill(gray4::white)). | |
| std::span< const uint8_t > | plane (size_t index) const noexcept |
| Returns the raw pixel data of one plane. | |
| std::span< const uint8_t > | plane_row (size_t index, size_t y) const noexcept |
| Returns the raw bytes of a single row of one plane. | |
| 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< gray4_framebuffer > | make (size_t width, size_t height) |
| Creates a framebuffer of the given dimensions, with all pixels white. | |
In-memory framebuffer for 4-level grayscale ePaper displays.
Each pixel is a gray4 level (2 bits). The levels are stored as two separate 1-bit-per-pixel planes — plane 0 holds bit 0 of each pixel's level, plane 1 holds bit 1 — because that is how ePaper controllers consume grayscale data: one plane per controller RAM bank. Within each plane the layout matches mono_framebuffer — row-major, MSB-first, with rows padded to whole bytes (stride_bytes).
A new framebuffer starts all-white (gray4::white, level 0), so generic drawing code that clears with a value-initialized pixel (e.g. idfxx::gfx::canvas::clear) clears to blank paper.
Draw into the framebuffer with set_pixel and friends, then upload it to a panel's RAM with flush or flush_rows, and make it visible with panel::refresh. This is a plain value type: copyable, movable, and independent of any panel.
Definition at line 58 of file gray4_framebuffer.hpp.
The value type written by set_pixel.
Definition at line 61 of file gray4_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 73 of file gray4_framebuffer.hpp.
|
inlinenoexcept |
Blanks every pixel to white (equivalent to fill(gray4::white)).
Definition at line 167 of file gray4_framebuffer.hpp.
References fill(), and idfxx::epaper::white.
|
inlinenoexcept |
Sets every pixel to the given gray level.
| level | The gray level to fill with. |
Definition at line 158 of file gray4_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. The panel must be operating in color_mode::gray4.
| 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 214 of file gray4_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. The panel must be operating in color_mode::gray4.
| 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 230 of file gray4_framebuffer.hpp.
References try_flush_rows(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the gray level of a single pixel.
gray4::white if the coordinates are out of range. Definition at line 138 of file gray4_framebuffer.hpp.
References stride_bytes(), and idfxx::epaper::white.
|
inlinenoexcept |
Returns the height in pixels.
Definition at line 98 of file gray4_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 86 of file gray4_framebuffer.hpp.
References idfxx::error(), height(), idfxx::invalid_arg, and width().
|
inlinenoexcept |
Returns the raw pixel data of one plane.
Each plane holds stride_bytes() * height() bytes in the row-major MSB-first layout described in the class documentation. Plane 0 holds bit 0 of each pixel's gray level, plane 1 holds bit 1.
Unlike set_pixel / get_pixel, the raw views do not tolerate out-of-range arguments: passing one is undefined behavior.
| index | The plane to view: 0 or 1. |
Definition at line 182 of file gray4_framebuffer.hpp.
Referenced by plane_row().
|
inlinenoexcept |
Returns the raw bytes of a single row of one plane.
Unlike set_pixel / get_pixel, the raw views do not tolerate out-of-range arguments: passing one is undefined behavior.
| index | The plane to view: 0 or 1. |
| y | Row, in [0, height()). |
Definition at line 196 of file gray4_framebuffer.hpp.
References plane(), and stride_bytes().
|
inlinenoexcept |
Sets a single pixel to the given gray level.
Out-of-range coordinates are ignored.
Definition at line 119 of file gray4_framebuffer.hpp.
References stride_bytes().
|
inlinenoexcept |
Returns the number of bytes per row within each plane.
Rows are padded to whole bytes: (width() + 7) / 8. Padding bits sit past the right edge and stay white.
Definition at line 108 of file gray4_framebuffer.hpp.
Referenced by get_pixel(), plane_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. The panel must be operating in color_mode::gray4.
| panel | The panel to upload to. |
| x | Destination column; must be a multiple of 8. |
| y | Destination row. |
Definition at line 245 of file gray4_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. The panel must be operating in color_mode::gray4.
| 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 263 of file gray4_framebuffer.hpp.
References idfxx::epaper::panel::try_write_rows().
Referenced by flush_rows().
|
inlinenoexcept |
Returns the width in pixels.
Definition at line 95 of file gray4_framebuffer.hpp.
Referenced by make().