|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
In-memory framebuffer for RGB565 (16 bits per pixel) color displays. More...
Public Types | |
| using | pixel_type = rgb565 |
| The value type written by set_pixel. | |
Public Member Functions | |
| rgb565_framebuffer (size_t width, size_t height) | |
| Creates a framebuffer of the given dimensions, with all pixels black. | |
| 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, rgb565 color) noexcept |
| Sets a single pixel to the given color. | |
| rgb565 | get_pixel (size_t x, size_t y) const noexcept |
| Returns the color of a single pixel. | |
| void | fill (rgb565 color) noexcept |
| Sets every pixel to the given color. | |
| void | clear () noexcept |
Sets every pixel to black (equivalent to fill({})). | |
| std::span< const rgb565 > | data () const noexcept |
| Returns the raw pixel data. | |
| void | flush (panel &panel, size_t x=0, size_t y=0) 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, size_t x=0, size_t y=0) 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< rgb565_framebuffer > | make (size_t width, size_t height) |
| Creates a framebuffer of the given dimensions, with all pixels black. | |
In-memory framebuffer for RGB565 (16 bits per pixel) color displays.
Pixels are stored row-major as rgb565 values (panel byte order), so the buffer can be passed directly to a color panel's draw_bitmap. The pixel (x, y) is at index y * width() + x.
Draw into the framebuffer with set_pixel and friends, then push it to a panel with flush. A full frame at 16 bpp is large (a 240x320 panel needs 150 KB), so the framebuffer may also be sized as a horizontal band and flushed at a destination offset, rendering the frame in slices:
This is a plain value type: copyable, movable, and independent of any panel.
Definition at line 53 of file rgb565_framebuffer.hpp.
The value type written by set_pixel.
Definition at line 56 of file rgb565_framebuffer.hpp.
|
inline |
Creates a framebuffer of the given dimensions, with all pixels black.
| 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 68 of file rgb565_framebuffer.hpp.
|
inlinenoexcept |
Sets every pixel to black (equivalent to fill({})).
Definition at line 131 of file rgb565_framebuffer.hpp.
References fill().
|
inlinenoexcept |
Returns the raw pixel data.
The span holds width() * height() values in the row-major layout described in the class documentation, suitable for passing directly to a color panel's draw_bitmap.
Definition at line 142 of file rgb565_framebuffer.hpp.
|
inlinenoexcept |
Sets every pixel to the given color.
| color | The color to fill with. |
Definition at line 128 of file rgb565_framebuffer.hpp.
Referenced by clear().
|
inline |
Draws the full framebuffer to a panel.
The framebuffer's top-left corner lands at (x, y) on the panel, so a band-sized framebuffer can render a taller frame in slices. The panel must use the RGB565 format.
| panel | The panel to draw to. |
| x | Destination column of the framebuffer's left edge. |
| y | Destination row of the framebuffer's top edge. |
| std::system_error | on error. |
Definition at line 158 of file rgb565_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), and is drawn to the same coordinates on the panel. Full-width regions transfer in a single draw; narrower regions transfer one draw per row. The panel must use the RGB565 format 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 192 of file rgb565_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 drawn to the same rows on the panel. The panel must use the RGB565 format 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 rgb565_framebuffer.hpp.
References try_flush_rows(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the color of a single pixel.
Definition at line 117 of file rgb565_framebuffer.hpp.
|
inlinenoexcept |
Returns the height in pixels.
Definition at line 92 of file rgb565_framebuffer.hpp.
Referenced by make().
|
inlinestatic |
Creates a framebuffer of the given dimensions, with all pixels black.
| 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 81 of file rgb565_framebuffer.hpp.
References idfxx::error(), height(), idfxx::invalid_arg, and width().
|
inlinenoexcept |
Sets a single pixel to the given color.
Out-of-range coordinates are ignored.
Definition at line 103 of file rgb565_framebuffer.hpp.
|
inline |
Draws the full framebuffer to a panel.
The framebuffer's top-left corner lands at (x, y) on the panel, so a band-sized framebuffer can render a taller frame in slices. The panel must use the RGB565 format.
| panel | The panel to draw to. |
| x | Destination column of the framebuffer's left edge. |
| y | Destination row of the framebuffer's top edge. |
Definition at line 209 of file rgb565_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), and is drawn to the same coordinates on the panel. Full-width regions transfer in a single draw; narrower regions transfer one draw per row. The panel must use the RGB565 format 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 254 of file rgb565_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 drawn to the same rows on the panel. The panel must use the RGB565 format 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 232 of file rgb565_framebuffer.hpp.
References try_flush_region().
Referenced by flush_rows().
|
inlinenoexcept |
Returns the width in pixels.
Definition at line 89 of file rgb565_framebuffer.hpp.
Referenced by make().