summaryrefslogtreecommitdiff
path: root/quantum/color.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/color.h')
-rw-r--r--quantum/color.h52
1 files changed, 9 insertions, 43 deletions
diff --git a/quantum/color.h b/quantum/color.h
index 135ad623b5..00a3bfb3f8 100644
--- a/quantum/color.h
+++ b/quantum/color.h
@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include "util.h"
// clang-format off
@@ -73,22 +74,6 @@
// clang-format on
-#if defined(__GNUC__)
-# define PACKED __attribute__((__packed__))
-#else
-# define PACKED
-#endif
-
-#if defined(_MSC_VER)
-# pragma pack(push, 1)
-#endif
-
-#ifdef RGBW
-# define LED_TYPE cRGBW
-#else
-# define LED_TYPE RGB
-#endif
-
#define WS2812_BYTE_ORDER_RGB 0
#define WS2812_BYTE_ORDER_GRB 1
#define WS2812_BYTE_ORDER_BGR 2
@@ -97,26 +82,7 @@
# define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_GRB
#endif
-typedef struct PACKED {
-#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
- uint8_t g;
- uint8_t r;
- uint8_t b;
-#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
- uint8_t r;
- uint8_t g;
- uint8_t b;
-#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
- uint8_t b;
- uint8_t g;
- uint8_t r;
-#endif
-} cRGB;
-
-typedef cRGB RGB;
-
-// WS2812 specific layout
-typedef struct PACKED {
+typedef struct PACKED rgb_led_t {
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
uint8_t g;
uint8_t r;
@@ -130,21 +96,21 @@ typedef struct PACKED {
uint8_t g;
uint8_t r;
#endif
+#ifdef RGBW
uint8_t w;
-} cRGBW;
+#endif
+} rgb_led_t;
-typedef struct PACKED {
+typedef rgb_led_t RGB;
+
+typedef struct PACKED HSV {
uint8_t h;
uint8_t s;
uint8_t v;
} HSV;
-#if defined(_MSC_VER)
-# pragma pack(pop)
-#endif
-
RGB hsv_to_rgb(HSV hsv);
RGB hsv_to_rgb_nocie(HSV hsv);
#ifdef RGBW
-void convert_rgb_to_rgbw(LED_TYPE *led);
+void convert_rgb_to_rgbw(rgb_led_t *led);
#endif