]> git.zerfleddert.de Git - fnordlicht-mini/blob - firmware/fnordlicht-firmware/color.h
import original fnordlichtmini firmware
[fnordlicht-mini] / firmware / fnordlicht-firmware / color.h
1 /* vim:ts=4 sts=4 et tw=80
2 *
3 * fnordlicht firmware
4 *
5 * for additional information please
6 * see http://lochraster.org/fnordlichtmini
7 *
8 * (c) by Alexander Neumann <alexander@bumpern.de>
9 * Lars Noschinski <lars@public.noschinski.de>
10 *
11 * This program is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 3 as published by
13 * the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #include <stdint.h>
25 /* for PWM_CHANNELS */
26 #include "globals.h"
27
28 #ifndef COLOR_H
29 #define COLOR_H
30
31 #if PWM_CHANNELS != 3
32 #error "PWM_CHANNELS is not 3, this is unsupported!"
33 #endif
34
35 struct rgb_color_t
36 {
37 union {
38 struct {
39 uint8_t red;
40 uint8_t green;
41 uint8_t blue;
42 };
43 uint8_t rgb[3];
44 };
45 };
46
47 struct rgb_color_offset_t {
48 union {
49 struct {
50 int8_t red;
51 int8_t green;
52 int8_t blue;
53 };
54 int8_t rgb[3];
55 };
56 };
57
58 struct hsv_color_t
59 {
60 union {
61 struct {
62 uint16_t hue;
63 uint8_t saturation;
64 uint8_t value;
65 };
66 uint8_t hsv[4];
67 };
68 };
69
70 struct hsv_color_offset_t {
71 int16_t hue;
72 int8_t saturation;
73 int8_t value;
74 };
75
76 struct dual_color_t
77 {
78 struct rgb_color_t rgb;
79 struct hsv_color_t hsv;
80 };
81
82 union color_t
83 {
84 /* rgb */
85 struct {
86 union {
87 struct {
88 uint8_t red;
89 uint8_t green;
90 uint8_t blue;
91 };
92 uint8_t rgb[3];
93 };
94 /* marker, 0xff if rgb */
95 uint8_t rgb_marker;
96 };
97
98 /* hsv */
99 struct {
100 uint8_t saturation;
101 uint8_t value;
102 /* 0 <= hue <= 349, otherwise rgb might be assumed */
103 uint16_t hue;
104 };
105 };
106
107 #endif
Impressum, Datenschutz