14
14
15
15
#include < Arduino.h>
16
16
17
- #define MAX_HUE 360
17
+ #define MAX_HUE 360
18
18
#define MAX_SATURATION 255
19
19
#define MAX_BRIGHTNESS 255
20
- #define MAX_PROGRESS 256
20
+ #define MAX_PROGRESS 256
21
21
22
22
typedef struct {
23
- union {
24
- struct {
25
- uint32_t v: 8 ; /* !< Brightness/Value of the LED. 0-255 */
26
- uint32_t s: 8 ; /* !< Saturation of the LED. 0-255 */
27
- uint32_t h: 9 ; /* !< Hue of the LED. 0-360 */
28
- };
29
- uint32_t value; /* !< IHSV value of the LED. */
23
+ union {
24
+ struct {
25
+ uint32_t v : 8 ; /* !< Brightness/Value of the LED. 0-255 */
26
+ uint32_t s : 8 ; /* !< Saturation of the LED. 0-255 */
27
+ uint32_t h : 9 ; /* !< Hue of the LED. 0-360 */
30
28
};
29
+ uint32_t value; /* !< IHSV value of the LED. */
30
+ };
31
31
} led_indicator_color_hsv_t ;
32
32
33
33
typedef struct {
34
- union {
35
- struct {
36
- uint32_t r: 8 ; /* !< Red component of the LED color. Range: 0-255. */
37
- uint32_t g: 8 ; /* !< Green component of the LED color. Range: 0-255. */
38
- uint32_t b: 8 ; /* !< Blue component of the LED color. Range: 0-255. */
39
- };
40
- uint32_t value; /* !< Combined RGB value of the LED color. */
34
+ union {
35
+ struct {
36
+ uint32_t r : 8 ; /* !< Red component of the LED color. Range: 0-255. */
37
+ uint32_t g : 8 ; /* !< Green component of the LED color. Range: 0-255. */
38
+ uint32_t b : 8 ; /* !< Blue component of the LED color. Range: 0-255. */
41
39
};
40
+ uint32_t value; /* !< Combined RGB value of the LED color. */
41
+ };
42
42
} led_indicator_color_rgb_t ;
43
43
44
44
class BuiltInLED {
45
45
private:
46
- uint8_t pin_number;
47
- bool state;
48
- led_indicator_color_hsv_t hsv_color;
46
+ uint8_t pin_number;
47
+ bool state;
48
+ led_indicator_color_hsv_t hsv_color;
49
49
50
50
public:
51
- BuiltInLED ();
52
- ~BuiltInLED ();
51
+ BuiltInLED ();
52
+ ~BuiltInLED ();
53
53
54
- static led_indicator_color_hsv_t rgb2hsv (led_indicator_color_rgb_t rgb_value);
55
- static led_indicator_color_rgb_t hsv2rgb (led_indicator_color_hsv_t hsv);
54
+ static led_indicator_color_hsv_t rgb2hsv (led_indicator_color_rgb_t rgb_value);
55
+ static led_indicator_color_rgb_t hsv2rgb (led_indicator_color_hsv_t hsv);
56
56
57
- void begin (uint8_t pin);
58
- void end ();
57
+ void begin (uint8_t pin);
58
+ void end ();
59
59
60
- void on ();
61
- void off ();
62
- void toggle ();
63
- bool getState ();
60
+ void on ();
61
+ void off ();
62
+ void toggle ();
63
+ bool getState ();
64
64
65
- bool write ();
65
+ bool write ();
66
66
67
- void setBrightness (uint8_t brightness);
68
- uint8_t getBrightness ();
69
- void setHSV (led_indicator_color_hsv_t hsv);
70
- led_indicator_color_hsv_t getHSV ();
71
- void setRGB (led_indicator_color_rgb_t color);
72
- led_indicator_color_rgb_t getRGB ();
73
- void setTemperature (uint32_t temperature);
74
- };
67
+ void setBrightness (uint8_t brightness);
68
+ uint8_t getBrightness ();
69
+ void setHSV (led_indicator_color_hsv_t hsv);
70
+ led_indicator_color_hsv_t getHSV ();
71
+ void setRGB (led_indicator_color_rgb_t color);
72
+ led_indicator_color_rgb_t getRGB ();
73
+ void setTemperature (uint32_t temperature);
74
+ };
0 commit comments