You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.4 KiB

  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. uint8_t g;
  36. uint8_t r;
  37. uint8_t b;
  38. } cRGB;
  39. typedef cRGB RGB;
  40. // WS2812 specific layout
  41. typedef struct PACKED {
  42. uint8_t g;
  43. uint8_t r;
  44. uint8_t b;
  45. uint8_t w;
  46. } cRGBW;
  47. typedef struct PACKED {
  48. uint8_t h;
  49. uint8_t s;
  50. uint8_t v;
  51. } HSV;
  52. #if defined(_MSC_VER)
  53. # pragma pack(pop)
  54. #endif
  55. RGB hsv_to_rgb(HSV hsv);
  56. #endif // COLOR_H