PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

octows2811_controller.h 1.6KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef __INC_OCTOWS2811_CONTROLLER_H
  2. #define __INC_OCTOWS2811_CONTROLLER_H
  3. #ifdef USE_OCTOWS2811
  4. // #include "OctoWS2811.h"
  5. FASTLED_NAMESPACE_BEGIN
  6. template<EOrder RGB_ORDER = GRB, uint8_t CHIP = WS2811_800kHz>
  7. class COctoWS2811Controller : public CPixelLEDController<RGB_ORDER, 8, 0xFF> {
  8. OctoWS2811 *pocto;
  9. uint8_t *drawbuffer,*framebuffer;
  10. void _init(int nLeds) {
  11. if(pocto == NULL) {
  12. drawbuffer = (uint8_t*)malloc(nLeds * 8 * 3);
  13. framebuffer = (uint8_t*)malloc(nLeds * 8 * 3);
  14. // byte ordering is handled in show by the pixel controller
  15. int config = WS2811_RGB;
  16. config |= CHIP;
  17. pocto = new OctoWS2811(nLeds, framebuffer, drawbuffer, config);
  18. pocto->begin();
  19. }
  20. }
  21. public:
  22. COctoWS2811Controller() { pocto = NULL; }
  23. virtual int size() { return CLEDController::size() * 8; }
  24. virtual void init() { /* do nothing yet */ }
  25. typedef union {
  26. uint8_t bytes[8];
  27. uint32_t raw[2];
  28. } Lines;
  29. virtual void showPixels(PixelController<RGB_ORDER, 8, 0xFF> & pixels) {
  30. _init(pixels.size());
  31. uint8_t *pData = drawbuffer;
  32. while(pixels.has(1)) {
  33. Lines b;
  34. for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale0(i); }
  35. transpose8x1_MSB(b.bytes,pData); pData += 8;
  36. for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale1(i); }
  37. transpose8x1_MSB(b.bytes,pData); pData += 8;
  38. for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale2(i); }
  39. transpose8x1_MSB(b.bytes,pData); pData += 8;
  40. pixels.stepDithering();
  41. pixels.advanceData();
  42. }
  43. pocto->show();
  44. }
  45. };
  46. FASTLED_NAMESPACE_END
  47. #endif
  48. #endif