idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
panel.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Chris Leishman
3
4#pragma once
5
13#include <idfxx/error>
14#include <idfxx/gpio>
15#include <idfxx/lcd/color>
16
17struct esp_lcd_panel_t;
18typedef struct esp_lcd_panel_t* esp_lcd_panel_handle_t;
19
24namespace idfxx::lcd {
25
30class panel {
31public:
46
47 virtual ~panel() = default;
48
50 [[nodiscard]] virtual esp_lcd_panel_handle_t idf_handle() const = 0;
51
52#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
59 virtual void swap_xy(bool swap) { unwrap(try_swap_xy(swap)); }
60#endif
61
67 [[nodiscard]] virtual result<void> try_swap_xy(bool swap) = 0;
68
69#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
77 virtual void mirror(bool mirrorX, bool mirrorY) { unwrap(try_mirror(mirrorX, mirrorY)); }
78#endif
79
86 [[nodiscard]] virtual result<void> try_mirror(bool mirrorX, bool mirrorY) = 0;
87
88#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
95 virtual void display_on(bool on) { unwrap(try_display_on(on)); }
96#endif
97
103 [[nodiscard]] virtual result<void> try_display_on(bool on) = 0;
104};
105
106} // namespace idfxx::lcd
Type-safe set of flags from a scoped enum.
Definition flags.hpp:88
A GPIO pin.
Definition gpio.hpp:58
static constexpr gpio nc()
Returns a GPIO representing "not connected".
Definition gpio.hpp:248
Abstract base class for LCD panels.
Definition panel.hpp:30
virtual result< void > try_mirror(bool mirrorX, bool mirrorY)=0
Mirrors the display.
virtual esp_lcd_panel_handle_t idf_handle() const =0
Returns the underlying ESP-IDF handle.
virtual void display_on(bool on)
Turns the display on or off.
Definition panel.hpp:95
virtual result< void > try_display_on(bool on)=0
Turns the display on or off.
virtual void swap_xy(bool swap)
Swaps the X and Y axes.
Definition panel.hpp:59
virtual void mirror(bool mirrorX, bool mirrorY)
Mirrors the display.
Definition panel.hpp:77
virtual ~panel()=default
virtual result< void > try_swap_xy(bool swap)=0
Swaps the X and Y axes.
LCD driver classes.
Definition color.hpp:19
rgb_element_order
RGB element order for LCD panels.
Definition color.hpp:25
rgb_data_endian
RGB data endian for LCD panels.
Definition color.hpp:34
@ big
RGB data endian: MSB first.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
Definition error.hpp:237
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:118
struct esp_lcd_panel_t * esp_lcd_panel_handle_t
Definition panel.hpp:18
Configuration structure for LCD panels.
Definition panel.hpp:36
gpio reset_gpio
GPIO number for hardware reset, or idfxx::gpio::nc() if not used.
Definition panel.hpp:37
uint32_t bits_per_pixel
Color depth, in bpp.
Definition panel.hpp:40
void * vendor_config
vendor specific configuration, optional, left as NULL if not used
Definition panel.hpp:44
rgb_data_endian data_endian
Set the data endian for color data larger than 1 byte.
Definition panel.hpp:39
enum rgb_element_order rgb_element_order
Set RGB element order, RGB or BGR.
Definition panel.hpp:38
unsigned int reset_active_high
Setting this if the panel reset is high level active.
Definition panel.hpp:42