dynamic keymap sanity check (#8181)
[jackhill/qmk/firmware.git] / quantum / color.h
CommitLineData
14b7602a
JH
1/* Copyright 2017 Jason Williams
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
14b7602a
JH
17#ifndef COLOR_H
18#define COLOR_H
19
20#include <stdint.h>
21#include <stdbool.h>
22
14b7602a 23#if defined(__GNUC__)
b624f32f 24# define PACKED __attribute__((__packed__))
14b7602a 25#else
b624f32f 26# define PACKED
14b7602a
JH
27#endif
28
29#if defined(_MSC_VER)
b624f32f 30# pragma pack(push, 1)
14b7602a
JH
31#endif
32
e7711b3b 33#ifdef RGBW
b624f32f 34# define LED_TYPE cRGBW
e7711b3b 35#else
b624f32f 36# define LED_TYPE RGB
e7711b3b
X
37#endif
38
39// WS2812 specific layout
b624f32f 40typedef struct PACKED {
41 uint8_t g;
42 uint8_t r;
43 uint8_t b;
e7711b3b
X
44} cRGB;
45
46typedef cRGB RGB;
47
48// WS2812 specific layout
b624f32f 49typedef struct PACKED {
50 uint8_t g;
51 uint8_t r;
52 uint8_t b;
53 uint8_t w;
e7711b3b 54} cRGBW;
14b7602a 55
b624f32f 56typedef struct PACKED {
57 uint8_t h;
58 uint8_t s;
59 uint8_t v;
14b7602a
JH
60} HSV;
61
62#if defined(_MSC_VER)
b624f32f 63# pragma pack(pop)
14b7602a
JH
64#endif
65
e7711b3b 66RGB hsv_to_rgb(HSV hsv);
7ba6456c
DJ
67#ifdef RGBW
68void convert_rgb_to_rgbw(LED_TYPE *led);
69#endif
b624f32f 70#endif // COLOR_H