color.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef COLOR_H
  17. #define COLOR_H
  18. #include <stdint.h>
  19. #include <stdbool.h>
  20. #if defined(__GNUC__)
  21. #define PACKED __attribute__ ((__packed__))
  22. #else
  23. #define PACKED
  24. #endif
  25. #if defined(_MSC_VER)
  26. #pragma pack( push, 1 )
  27. #endif
  28. #ifdef RGBW
  29. #define LED_TYPE cRGBW
  30. #else
  31. #define LED_TYPE RGB
  32. #endif
  33. // WS2812 specific layout
  34. typedef struct PACKED
  35. {
  36. uint8_t g;
  37. uint8_t r;
  38. uint8_t b;
  39. } cRGB;
  40. typedef cRGB RGB;
  41. // WS2812 specific layout
  42. typedef struct PACKED
  43. {
  44. uint8_t g;
  45. uint8_t r;
  46. uint8_t b;
  47. uint8_t w;
  48. } cRGBW;
  49. typedef struct PACKED
  50. {
  51. uint8_t h;
  52. uint8_t s;
  53. uint8_t v;
  54. } HSV;
  55. #if defined(_MSC_VER)
  56. #pragma pack( pop )
  57. #endif
  58. RGB hsv_to_rgb(HSV hsv);
  59. #endif // COLOR_H