M5Unit-COLOR 0.2.0 git rev:d6fe6e1
Loading...
Searching...
No Matches
color_correction.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
12#ifndef M5_UNIT_COLOR_UTILITY_COLOR_CORRECTION_HPP
13#define M5_UNIT_COLOR_UTILITY_COLOR_CORRECTION_HPP
14
16#include <cstdint>
17
18namespace m5 {
19namespace unit {
20namespace tcs3472x {
21
27struct RGB8 {
28 uint8_t r;
29 uint8_t g;
30 uint8_t b;
31
33 inline uint16_t to565() const
34 {
35 return Data::color565(r, g, b);
36 }
38 inline uint32_t to888() const
39 {
40 return Data::color888(r, g, b);
41 }
42};
43
54RGB8 pureHue(const uint8_t r, const uint8_t g, const uint8_t b);
55
65RGB8 normalizeBrightness(const uint8_t r, const uint8_t g, const uint8_t b);
66
75RGB8 grayscale(const uint8_t r, const uint8_t g, const uint8_t b);
76
81enum class ColorName : uint8_t {
82 Black,
83 White,
84 Gray,
85 Red,
86 Orange,
87 Yellow,
88 Green,
89 Cyan,
90 Blue,
91 Purple,
92 Magenta,
93 Brown,
94};
95
105ColorName nearestColorName(const uint8_t r, const uint8_t g, const uint8_t b);
106
112RGB8 colorNameToRGB(const ColorName name);
113
119const char* colorNameToString(const ColorName name);
120
121} // namespace tcs3472x
122} // namespace unit
123} // namespace m5
124#endif
ColorName
Color names for nearestColorName.
Definition color_correction.hpp:81
Top level namespace of M5Stack.
For TCS3472x.
Unit-related namespace.
static constexpr uint32_t color888(const uint8_t r, const uint8_t g, const uint8_t b)
Converts 8-bit RGB channels to RGB888 format.
Definition unit_TCS3472x_data.hpp:228
static constexpr uint16_t color565(const uint8_t r, const uint8_t g, const uint8_t b)
Converts 8-bit RGB channels to RGB565 format.
Definition unit_TCS3472x_data.hpp:217
8-bit RGB value
Definition color_correction.hpp:27
uint8_t r
Red (0-255)
Definition color_correction.hpp:28
uint16_t to565() const
Gets the value in RGB565 format.
Definition color_correction.hpp:33
uint8_t b
Blue (0-255)
Definition color_correction.hpp:30
uint32_t to888() const
Gets the value in RGB888 format.
Definition color_correction.hpp:38
uint8_t g
Green (0-255)
Definition color_correction.hpp:29
Data types for TCS3472x.