|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
In-memory framebuffer for monochrome (1 bit per pixel) displays. More...
Public Types | |
| using | pixel_type = bool |
| The value type written by set_pixel. | |
Public Member Functions | |
| mono_framebuffer (size_t width, size_t height) | |
| Creates a framebuffer of the given dimensions, with all pixels off. | |
| size_t | width () const noexcept |
| Returns the width in pixels. | |
| size_t | height () const noexcept |
| Returns the height in pixels. | |
| void | set_pixel (size_t x, size_t y, bool on) noexcept |
| Sets or clears a single pixel. | |
| bool | get_pixel (size_t x, size_t y) const noexcept |
| Returns the state of a single pixel. | |
| void | fill (bool on) noexcept |
| Sets every pixel to the given state. | |
| void | clear () noexcept |
Clears every pixel (equivalent to fill(false)). | |
| std::span< const uint8_t > | data () const noexcept |
| Returns the raw page-packed pixel data. | |
| void | flush (panel &panel) const |
| Draws the full framebuffer to a panel. | |
| void | flush_rows (panel &panel, size_t y_start, size_t y_end) const |
| Draws a horizontal band of the framebuffer to a panel. | |
| void | flush_region (panel &panel, size_t x_start, size_t y_start, size_t x_end, size_t y_end) const |
| Draws a rectangular region of the framebuffer to a panel. | |
| result< void > | try_flush (panel &panel) const |
| Draws the full framebuffer to a panel. | |
| result< void > | try_flush_rows (panel &panel, size_t y_start, size_t y_end) const |
| Draws a horizontal band of the framebuffer to a panel. | |
| result< void > | try_flush_region (panel &panel, size_t x_start, size_t y_start, size_t x_end, size_t y_end) const |
| Draws a rectangular region of the framebuffer to a panel. | |
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 off. | |
In-memory framebuffer for monochrome (1 bit per pixel) displays.
Pixels are stored page-packed, the native format of SSD1306-style monochrome OLED controllers: each byte holds 8 vertically adjacent pixels (bit 0 is the topmost), and pages (rows of 8 pixels) are laid out top-to-bottom, each page spanning the full display width. The byte for pixel (x, y) is at index (y / 8) * width() + x, bit y % 8.
Draw into the framebuffer with set_pixel and friends, then push it to a panel with flush (full frame) or flush_rows (a horizontal band). This is a plain value type: copyable, movable, and independent of any panel.
Definition at line 49 of file mono_framebuffer.hpp.
| using idfxx::lcd::mono_framebuffer::pixel_type = bool |
The value type written by set_pixel.
Definition at line 52 of file mono_framebuffer.hpp.
|
inline |
Creates a framebuffer of the given dimensions, with all pixels off.
| width | Width in pixels; must be non-zero. |
| height | Height in pixels; must be non-zero and a multiple of 8. |
| std::system_error | on error (e.g. invalid dimensions). |
Definition at line 64 of file mono_framebuffer.hpp.
|
inlinenoexcept |
Clears every pixel (equivalent to fill(false)).
Definition at line 133 of file mono_framebuffer.hpp.
References fill().
|
inlinenoexcept |
Returns the raw page-packed pixel data.
The span holds width() * height() / 8 bytes in the layout described in the class documentation, suitable for passing directly to a monochrome panel's draw_bitmap.
Definition at line 144 of file mono_framebuffer.hpp.
|
inlinenoexcept |
Sets every pixel to the given state.
| on | true to set all pixels, false to clear them. |
Definition at line 130 of file mono_framebuffer.hpp.
Referenced by clear().
|
inline |
Draws the full framebuffer to a panel.
The panel must use the page-packed 1-bpp format (e.g. an SSD1306) and should match the framebuffer's dimensions.
| panel | The panel to draw to. |
| std::system_error | on error. |
Definition at line 157 of file mono_framebuffer.hpp.
References try_flush(), and idfxx::unwrap().
|
inline |
Draws a rectangular region of the framebuffer to a panel.
The region spans columns [x_start, x_end) and rows [y_start, y_end), with the rows expanded outward to page boundaries (multiples of 8) to match the page-packed layout. Full-width regions transfer in a single draw; narrower regions transfer one draw per page. The panel must use the page-packed 1-bpp format (e.g. an SSD1306) and should match the framebuffer's dimensions.
| panel | The panel to draw to. |
| x_start | First column of the region, inclusive. |
| y_start | First row of the region, inclusive. |
| x_end | End column, exclusive; must satisfy x_start < x_end <= width(). |
| y_end | End row, exclusive; must satisfy y_start < y_end <= height(). |
| std::system_error | on error (e.g. an invalid region). |
Definition at line 193 of file mono_framebuffer.hpp.
References try_flush_region(), and idfxx::unwrap().
|
inline |
Draws a horizontal band of the framebuffer to a panel.
The band spans rows [y_start, y_end) across the full width, and is expanded outward to page boundaries (multiples of 8 rows) to match the page-packed layout. The panel must use the page-packed 1-bpp format (e.g. an SSD1306) and should match the framebuffer's dimensions.
| panel | The panel to draw 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 173 of file mono_framebuffer.hpp.
References try_flush_rows(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the state of a single pixel.
Definition at line 119 of file mono_framebuffer.hpp.
|
inlinenoexcept |
Returns the height in pixels.
Definition at line 88 of file mono_framebuffer.hpp.
Referenced by make().
|
inlinestatic |
Creates a framebuffer of the given dimensions, with all pixels off.
| width | Width in pixels; must be non-zero. |
| height | Height in pixels; must be non-zero and a multiple of 8. |
| idfxx::errc::invalid_arg | if width is zero, or height is zero or not a multiple of 8. |
Definition at line 77 of file mono_framebuffer.hpp.
References idfxx::error(), height(), idfxx::invalid_arg, and width().
|
inlinenoexcept |
Sets or clears a single pixel.
Out-of-range coordinates are ignored.
| x | Column, in [0, width()). |
| y | Row, in [0, height()). |
| on | true to set the pixel, false to clear it. |
Definition at line 99 of file mono_framebuffer.hpp.
Draws the full framebuffer to a panel.
The panel must use the page-packed 1-bpp format (e.g. an SSD1306) and should match the framebuffer's dimensions.
| panel | The panel to draw to. |
Definition at line 207 of file mono_framebuffer.hpp.
References idfxx::lcd::panel::try_draw_bitmap().
Referenced by flush().
|
inline |
Draws a rectangular region of the framebuffer to a panel.
The region spans columns [x_start, x_end) and rows [y_start, y_end), with the rows expanded outward to page boundaries (multiples of 8) to match the page-packed layout. Full-width regions transfer in a single draw; narrower regions transfer one draw per page. The panel must use the page-packed 1-bpp format (e.g. an SSD1306) and should match the framebuffer's dimensions.
| panel | The panel to draw to. |
| x_start | First column of the region, inclusive. |
| y_start | First row of the region, inclusive. |
| x_end | End column, exclusive; must satisfy x_start < x_end <= width(). |
| y_end | End row, exclusive; must satisfy y_start < y_end <= height(). |
| idfxx::errc::invalid_arg | if the region is invalid. |
Definition at line 248 of file mono_framebuffer.hpp.
References idfxx::error(), idfxx::invalid_arg, and idfxx::lcd::panel::try_draw_bitmap().
Referenced by flush_region(), and try_flush_rows().
|
inline |
Draws a horizontal band of the framebuffer to a panel.
The band spans rows [y_start, y_end) across the full width, and is expanded outward to page boundaries (multiples of 8 rows) to match the page-packed layout. The panel must use the page-packed 1-bpp format (e.g. an SSD1306) and should match the framebuffer's dimensions.
| panel | The panel to draw 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 225 of file mono_framebuffer.hpp.
References try_flush_region().
Referenced by flush_rows().
|
inlinenoexcept |
Returns the width in pixels.
Definition at line 85 of file mono_framebuffer.hpp.
Referenced by make().