15#include <esp_lcd_panel_io.h>
28 rgb = LCD_RGB_ELEMENT_ORDER_RGB,
29 bgr = LCD_RGB_ELEMENT_ORDER_BGR,
37 big = LCD_RGB_DATA_ENDIAN_BIG,
38 little = LCD_RGB_DATA_ENDIAN_LITTLE,
58 constexpr rgb565() noexcept = default;
70 constexpr
rgb565(uint8_t r, uint8_t g, uint8_t b) noexcept
71 : _repr(_to_panel_order(static_cast<uint16_t>(((r & 0xF8u) << 8) | ((g & 0xFCu) << 3) | (b >> 3)))) {}
82 c._repr = _to_panel_order(
value);
91 [[nodiscard]]
constexpr uint16_t
value() const noexcept {
return _to_panel_order(_repr); }
99 static constexpr uint16_t _to_panel_order(uint16_t
value)
noexcept {
100 if constexpr (std::endian::native == std::endian::little) {
101 return std::byteswap(
value);
110static_assert(
sizeof(rgb565) == 2);
A 16-bit RGB565 color, stored in panel byte order.
constexpr rgb565() noexcept=default
Creates black.
constexpr uint16_t value() const noexcept
Returns the packed RGB565 value.
static constexpr rgb565 from_value(uint16_t value) noexcept
Creates a color from a packed RGB565 value.
friend constexpr bool operator==(rgb565, rgb565) noexcept=default
Compares two colors for equality.
rgb_element_order
RGB element order for LCD panels.
rgb_data_endian
RGB data endian for LCD panels.
@ little
RGB data endian: LSB first.
@ big
RGB data endian: MSB first.