Guest User

Untitled

a guest
Sep 20th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. /* FastLED_RGBW
  2. *
  3. * Hack to enable SK6812 RGBW strips to work with FastLED.
  4. *
  5. * Original code by Jim Bumgardner (http://krazydad.com).
  6. * Modified by David Madison (http://partsnotincluded.com).
  7. *
  8. */
  9.  
  10. #ifndef FastLED_RGBW_h
  11. #define FastLED_RGBW_h
  12.  
  13. struct CRGBW {
  14. union {
  15. struct {
  16.  
  17. union {
  18. uint8_t g;
  19. uint8_t green;
  20. };
  21. union {
  22. uint8_t r;
  23. uint8_t red;
  24. };
  25. union {
  26. uint8_t b;
  27. uint8_t blue;
  28. };
  29. union {
  30. uint8_t w;
  31. uint8_t white;
  32. };
  33. };
  34. uint8_t raw[4];
  35. };
  36.  
  37. CRGBW(){}
  38.  
  39. CRGBW(uint8_t rd, uint8_t grn, uint8_t blu, uint8_t wht){
  40. r = rd;
  41. g = grn;
  42. b = blu;
  43. w = wht;
  44. }
  45.  
  46. inline void operator = (const CRGB c) __attribute__((always_inline)){
  47. this->r = c.r;
  48. this->g = c.g;
  49. this->b = c.b;
  50. this->white = 0;
  51. }
  52. };
  53.  
  54. inline uint16_t getRGBWsize(uint16_t nleds){
  55. uint16_t nbytes = nleds * 4;
  56. if(nbytes % 3 > 0) return nbytes / 3 + 1;
  57. else return nbytes / 3;
  58. }
  59.  
  60. #endif
  61.  
Add Comment
Please, Sign In to add comment