idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::lcd::rgb565 Class Reference

A 16-bit RGB565 color, stored in panel byte order. More...

Public Member Functions

constexpr rgb565 () noexcept=default
 Creates black.
 
constexpr rgb565 (uint8_t r, uint8_t g, uint8_t b) noexcept
 Creates a color from 8-bit red, green, and blue components.
 
constexpr uint16_t value () const noexcept
 Returns the packed RGB565 value.
 

Static Public Member Functions

static constexpr rgb565 from_value (uint16_t value) noexcept
 Creates a color from a packed RGB565 value.
 

Friends

constexpr bool operator== (rgb565, rgb565) noexcept=default
 Compares two colors for equality.
 

Detailed Description

A 16-bit RGB565 color, stored in panel byte order.

The stored representation places the most significant byte first, the order color panels expect by default (rgb_data_endian::big), so arrays of rgb565 values can be passed directly to panel::draw_bitmap without conversion.

constexpr idfxx::lcd::rgb565 amber(255, 191, 0);
fb.set_pixel(10, 20, amber);
A 16-bit RGB565 color, stored in panel byte order.
Definition color.hpp:55

Definition at line 55 of file color.hpp.

Constructor & Destructor Documentation

◆ rgb565() [1/2]

constexpr idfxx::lcd::rgb565::rgb565 ( )
constexprdefaultnoexcept

Creates black.

◆ rgb565() [2/2]

constexpr idfxx::lcd::rgb565::rgb565 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inlineconstexprnoexcept

Creates a color from 8-bit red, green, and blue components.

Components are truncated to the 5-6-5 bit layout: red and blue keep their top 5 bits, green its top 6.

Parameters
rRed component, 0-255.
gGreen component, 0-255.
bBlue component, 0-255.

Definition at line 70 of file color.hpp.

Member Function Documentation

◆ from_value()

static constexpr rgb565 idfxx::lcd::rgb565::from_value ( uint16_t  value)
inlinestaticconstexprnoexcept

Creates a color from a packed RGB565 value.

Parameters
valuePacked color: red in bits 15-11, green in bits 10-5, blue in bits 4-0.
Returns
The color.

Definition at line 80 of file color.hpp.

References value().

◆ value()

constexpr uint16_t idfxx::lcd::rgb565::value ( ) const
inlineconstexprnoexcept

Returns the packed RGB565 value.

Returns
The packed color: red in bits 15-11, green in bits 10-5, blue in bits 4-0.

Definition at line 91 of file color.hpp.

Referenced by from_value().

Friends And Related Symbol Documentation

◆ operator==

constexpr bool operator== ( rgb565  ,
rgb565   
)
friend

Compares two colors for equality.


The documentation for this class was generated from the following file: