14#include <idfxx/lcd/color>
15#include <idfxx/lcd/panel>
58#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
89 [[nodiscard]]
size_t width() const noexcept {
return _width; }
92 [[nodiscard]]
size_t height() const noexcept {
return _height; }
104 if (x >= _width || y >= _height) {
107 _data[y * _width + x] = color;
118 if (x >= _width || y >= _height) {
121 return _data[y * _width + x];
128 void fill(
rgb565 color)
noexcept { std::ranges::fill(_data, color); }
142 [[nodiscard]] std::span<const rgb565>
data() const noexcept {
return _data; }
144#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
213 static_cast<int>(x + _width),
214 static_cast<int>(y + _height),
255 if (x_start >= x_end || x_end > _width || y_start >= y_end || y_end > _height) {
258 if (x_start == 0 && x_end == _width) {
263 static_cast<int>(y_start),
264 static_cast<int>(_width),
265 static_cast<int>(y_end),
266 _data.data() + y_start * _width
269 for (
size_t row = y_start; row < y_end; ++row) {
271 static_cast<int>(x_start),
272 static_cast<int>(row),
273 static_cast<int>(x_end),
274 static_cast<int>(row + 1),
275 _data.data() + row * _width + x_start
288 , _data(std::move(
data)) {}
292 std::vector<rgb565> _data;
Abstract base class for LCD panels.
result< void > try_draw_bitmap(int x_start, int y_start, int x_end, int y_end, const void *color_data)
Draws bitmap data to a region of the display.
In-memory framebuffer for RGB565 (16 bits per pixel) color displays.
void flush(panel &panel, size_t x=0, size_t y=0) const
Draws the full framebuffer to a panel.
rgb565_framebuffer(size_t width, size_t height)
Creates a framebuffer of the given dimensions, with all pixels black.
result< void > try_flush(panel &panel, size_t x=0, size_t y=0) const
Draws the full framebuffer to a panel.
size_t height() const noexcept
Returns the height in pixels.
void fill(rgb565 color) noexcept
Sets every pixel to the given color.
rgb565 get_pixel(size_t x, size_t y) const noexcept
Returns the color of a single pixel.
void set_pixel(size_t x, size_t y, rgb565 color) noexcept
Sets a single pixel to the given color.
void flush_rows(panel &panel, size_t y_start, size_t y_end) const
Draws a horizontal band of the framebuffer to a panel.
static result< rgb565_framebuffer > make(size_t width, size_t height)
Creates a framebuffer of the given dimensions, with all pixels black.
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_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_rows(panel &panel, size_t y_start, size_t y_end) const
Draws a horizontal band of the framebuffer to a panel.
size_t width() const noexcept
Returns the width in pixels.
std::span< const rgb565 > data() const noexcept
Returns the raw pixel data.
void clear() noexcept
Sets every pixel to black (equivalent to fill({})).
A 16-bit RGB565 color, stored in panel byte order.
constexpr std::unexpected< std::error_code > error(E e) noexcept
Creates an unexpected error from an error code enum.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
@ invalid_arg
Invalid argument.
std::expected< T, std::error_code > result
result type wrapping a value or error code.