1 |
|
|
/** |
2 |
|
|
* @file RGBN.hpp |
3 |
|
|
* @brief Header file for blink1_lib::RGBN |
4 |
|
|
*/ |
5 |
|
|
|
6 |
|
|
#pragma once |
7 |
|
|
|
8 |
|
|
#include <cstdint> |
9 |
|
|
#include <ostream> |
10 |
|
|
|
11 |
|
|
namespace blink1_lib { |
12 |
|
|
|
13 |
|
|
/** |
14 |
|
|
* A datatype that combines an RGB value with an LED index |
15 |
|
|
*/ |
16 |
|
|
struct RGBN { |
17 |
|
|
/** |
18 |
|
|
* Red value |
19 |
|
|
*/ |
20 |
|
|
std::uint8_t r{0}; |
21 |
|
|
|
22 |
|
|
/** |
23 |
|
|
* Green value |
24 |
|
|
*/ |
25 |
|
|
std::uint8_t g{0}; |
26 |
|
|
|
27 |
|
|
/** |
28 |
|
|
* Blue value |
29 |
|
|
*/ |
30 |
|
|
std::uint8_t b{0}; |
31 |
|
|
|
32 |
|
|
/** |
33 |
|
|
* LED index |
34 |
|
|
*/ |
35 |
|
|
std::uint8_t n{0}; |
36 |
|
|
|
37 |
|
|
/** |
38 |
|
|
* @param r Red value |
39 |
|
|
* @param g Green value |
40 |
|
|
* @param b Blue value |
41 |
|
|
* @param n LED index |
42 |
|
|
*/ |
43 |
|
|
RGBN(const std::uint8_t r, const std::uint8_t g, const std::uint8_t b, const std::uint8_t n) noexcept; |
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
* Default constructor |
47 |
|
|
* |
48 |
|
|
* Initializes all values to 0 |
49 |
|
|
*/ |
50 |
|
4 |
RGBN() noexcept = default; |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* Equality operator |
54 |
|
|
* |
55 |
|
|
* @param other Object to compare to |
56 |
|
|
* @return true if the objects are equal, false otherwise |
57 |
|
|
*/ |
58 |
|
|
[[nodiscard]] bool operator==(const RGBN& other) const noexcept; |
59 |
|
|
|
60 |
|
|
/** |
61 |
|
|
* Inequality operator |
62 |
|
|
* |
63 |
|
|
* @param other Object to compare to |
64 |
|
|
* @return true if the objects are not equal, false otherwise |
65 |
|
|
*/ |
66 |
|
|
[[nodiscard]] bool operator!=(const RGBN& other) const noexcept; |
67 |
|
|
|
68 |
|
|
/** |
69 |
|
|
* Output operator |
70 |
|
|
* |
71 |
|
|
* @param os Output stream |
72 |
|
|
* @param rgb RGBN object to output |
73 |
|
|
*/ |
74 |
|
|
friend std::ostream& operator<<(std::ostream& os, const RGBN& rgb); |
75 |
|
|
}; |
76 |
|
|
} |