Guest User

New_Chipset.h

a guest
Aug 9th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 27.15 KB | None | 0 0
  1. #ifndef __INC_CHIPSETS_H
  2. #define __INC_CHIPSETS_H
  3.  
  4. #include "FastLED.h"
  5. #include "pixeltypes.h"
  6.  
  7. /// @file chipsets.h
  8. /// Contains the bulk of the definitions for the various LED chipsets supported.
  9.  
  10. FASTLED_NAMESPACE_BEGIN
  11.  
  12. /// @defgroup Chipsets LED Chipset Controllers
  13. /// Implementations of ::CLEDController classes for various led chipsets.
  14. ///
  15. /// @{
  16.  
  17. #if defined(ARDUINO) //&& defined(SoftwareSerial_h)
  18.  
  19.  
  20. #if defined(SoftwareSerial_h) || defined(__SoftwareSerial_h)
  21. #include <SoftwareSerial.h>
  22.  
  23. #define HAS_PIXIE
  24.  
  25. /// Adafruit Pixie controller class
  26. /// @tparam DATA_PIN the pin to write data out on
  27. /// @tparam RGB_ORDER the RGB ordering for the LED data
  28. template<uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  29. class PixieController : public CPixelLEDController<RGB_ORDER> {
  30.     SoftwareSerial Serial;
  31.     CMinWait<2000> mWait;
  32.  
  33. public:
  34.     PixieController() : Serial(-1, DATA_PIN) {}
  35.  
  36. protected:
  37.     /// Initialize the controller
  38.     virtual void init() {
  39.         Serial.begin(115200);
  40.         mWait.mark();
  41.     }
  42.  
  43.     /// @copydoc CPixelLEDController::showPixels()
  44.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  45.         mWait.wait();
  46.         while(pixels.has(1)) {
  47.             uint8_t r = pixels.loadAndScale0();
  48.             Serial.write(r);
  49.             uint8_t g = pixels.loadAndScale1();
  50.             Serial.write(g);
  51.             uint8_t b = pixels.loadAndScale2();
  52.             Serial.write(b);
  53.             pixels.advanceData();
  54.             pixels.stepDithering();
  55.         }
  56.         mWait.mark();
  57.     }
  58.  
  59. };
  60.  
  61. // template<SoftwareSerial & STREAM, EOrder RGB_ORDER = RGB>
  62. // class PixieController : public PixieBaseController<STREAM, RGB_ORDER> {
  63. // public:
  64. //  virtual void init() {
  65. //      STREAM.begin(115200);
  66. //  }
  67. // };
  68. #endif
  69. #endif
  70.  
  71. /// @defgroup ClockedChipsets Clocked Chipsets
  72. /// Nominally SPI based, these chipsets have a data and a clock line.
  73. /// @{
  74.  
  75. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. //
  77. // LPD8806 controller class - takes data/clock/select pin values (N.B. should take an SPI definition?)
  78. //
  79. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  80.  
  81. /// LPD8806 controller class.
  82. /// @tparam DATA_PIN the data pin for these LEDs
  83. /// @tparam CLOCK_PIN the clock pin for these LEDs
  84. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  85. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(12)
  86. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB,  uint32_t SPI_SPEED = DATA_RATE_MHZ(12) >
  87. class LPD8806Controller : public CPixelLEDController<RGB_ORDER> {
  88.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  89.  
  90.     class LPD8806_ADJUST {
  91.     public:
  92.         // LPD8806 spec wants the high bit of every rgb data byte sent out to be set.
  93.         __attribute__((always_inline)) inline static uint8_t adjust(FASTLED_REGISTER uint8_t data) { return ((data>>1) | 0x80) + ((data && (data<254)) & 0x01); }
  94.         __attribute__((always_inline)) inline static void postBlock(int len) {
  95.             SPI::writeBytesValueRaw(0, ((len*3+63)>>6));
  96.         }
  97.  
  98.     };
  99.  
  100.     SPI mSPI;
  101.  
  102. public:
  103.     LPD8806Controller()  {}
  104.     virtual void init() {
  105.         mSPI.init();
  106.     }
  107.  
  108. protected:
  109.  
  110.     /// @copydoc CPixelLEDController::showPixels()
  111.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  112.         mSPI.template writePixels<0, LPD8806_ADJUST, RGB_ORDER>(pixels);
  113.     }
  114. };
  115.  
  116.  
  117. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  118. //
  119. // WS2801 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
  120. //
  121. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  122.  
  123. /// WS2801 controller class.
  124. /// @tparam DATA_PIN the data pin for these LEDs
  125. /// @tparam CLOCK_PIN the clock pin for these LEDs
  126. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  127. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(1)
  128. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(1)>
  129. class WS2801Controller : public CPixelLEDController<RGB_ORDER> {
  130.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  131.     SPI mSPI;
  132.     CMinWait<1000>  mWaitDelay;
  133.  
  134. public:
  135.     WS2801Controller() {}
  136.  
  137.     /// Initialize the controller
  138.     virtual void init() {
  139.         mSPI.init();
  140.       mWaitDelay.mark();
  141.     }
  142.  
  143. protected:
  144.  
  145.     /// @copydoc CPixelLEDController::showPixels()
  146.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  147.         mWaitDelay.wait();
  148.         mSPI.template writePixels<0, DATA_NOP, RGB_ORDER>(pixels);
  149.         mWaitDelay.mark();
  150.     }
  151. };
  152.  
  153. /// WS2803 controller class.
  154. /// @copydetails WS2801Controller
  155. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(25)>
  156. class WS2803Controller : public WS2801Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED> {};
  157.  
  158. /// LPD6803 controller class (LPD1101).
  159. /// 16 bit (1 bit const "1", 5 bit red, 5 bit green, 5 bit blue).
  160. /// In chip CMODE pin must be set to 1 (inside oscillator mode).
  161. /// @tparam DATA_PIN the data pin for these LEDs
  162. /// @tparam CLOCK_PIN the clock pin for these LEDs
  163. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  164. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(12)
  165. /// @see Datasheet: https://cdn-shop.adafruit.com/datasheets/LPD6803.pdf
  166. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(12)>
  167. class LPD6803Controller : public CPixelLEDController<RGB_ORDER> {
  168.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  169.     SPI mSPI;
  170.  
  171.     void startBoundary() { mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); mSPI.writeByte(0); }
  172.     void endBoundary(int nLeds) { int nDWords = (nLeds/32); do { mSPI.writeByte(0xFF); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nDWords--); }
  173.  
  174. public:
  175.     LPD6803Controller() {}
  176.  
  177.     virtual void init() {
  178.         mSPI.init();
  179.     }
  180.  
  181. protected:
  182.     /// @copydoc CPixelLEDController::showPixels()
  183.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  184.         mSPI.select();
  185.  
  186.         startBoundary();
  187.         while(pixels.has(1)) {
  188.             FASTLED_REGISTER uint16_t command;
  189.             command = 0x8000;
  190.             command |= (pixels.loadAndScale0() & 0xF8) << 7; // red is the high 5 bits
  191.             command |= (pixels.loadAndScale1() & 0xF8) << 2; // green is the middle 5 bits
  192.             mSPI.writeByte((command >> 8) & 0xFF);
  193.             command |= pixels.loadAndScale2() >> 3 ; // blue is the low 5 bits
  194.             mSPI.writeByte(command & 0xFF);
  195.  
  196.             pixels.stepDithering();
  197.             pixels.advanceData();
  198.         }
  199.         endBoundary(pixels.size());
  200.         mSPI.waitFully();
  201.         mSPI.release();
  202.     }
  203.  
  204. };
  205.  
  206. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  207. //
  208. // APA102 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
  209. //
  210. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  211.  
  212. /// APA102 controller class.
  213. /// @tparam DATA_PIN the data pin for these LEDs
  214. /// @tparam CLOCK_PIN the clock pin for these LEDs
  215. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  216. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(12)
  217. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(12)>
  218. class APA102Controller : public CPixelLEDController<RGB_ORDER> {
  219.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  220.     SPI mSPI;
  221.  
  222.     void startBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); }
  223.     void endBoundary(int nLeds) { int nDWords = (nLeds/32); do { mSPI.writeByte(0xFF); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nDWords--); }
  224.  
  225.     inline void writeLed(uint8_t brightness, uint8_t b0, uint8_t b1, uint8_t b2) __attribute__((always_inline)) {
  226. #ifdef FASTLED_SPI_BYTE_ONLY
  227.         mSPI.writeByte(0xE0 | brightness);
  228.         mSPI.writeByte(b0);
  229.         mSPI.writeByte(b1);
  230.         mSPI.writeByte(b2);
  231. #else
  232.         uint16_t b = 0xE000 | (brightness << 8) | (uint16_t)b0;
  233.         mSPI.writeWord(b);
  234.         uint16_t w = b1 << 8;
  235.         w |= b2;
  236.         mSPI.writeWord(w);
  237. #endif
  238.     }
  239.  
  240. public:
  241.     APA102Controller() {}
  242.  
  243.     virtual void init() {
  244.         mSPI.init();
  245.     }
  246.  
  247. protected:
  248.     /// @copydoc CPixelLEDController::showPixels()
  249.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  250.         mSPI.select();
  251.  
  252.         uint8_t s0 = pixels.getScale0(), s1 = pixels.getScale1(), s2 = pixels.getScale2();
  253. #if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
  254.         const uint16_t maxBrightness = 0x1F;
  255.         uint16_t brightness = ((((uint16_t)max(max(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1;
  256.         s0 = (maxBrightness * s0 + (brightness >> 1)) / brightness;
  257.         s1 = (maxBrightness * s1 + (brightness >> 1)) / brightness;
  258.         s2 = (maxBrightness * s2 + (brightness >> 1)) / brightness;
  259. #else
  260.         const uint8_t brightness = 0x1F;
  261. #endif
  262.  
  263.         startBoundary();
  264.         while (pixels.has(1)) {
  265.             writeLed(brightness, pixels.loadAndScale0(0, s0), pixels.loadAndScale1(0, s1), pixels.loadAndScale2(0, s2));
  266.             pixels.stepDithering();
  267.             pixels.advanceData();
  268.         }
  269.         endBoundary(pixels.size());
  270.  
  271.         mSPI.waitFully();
  272.         mSPI.release();
  273.     }
  274.  
  275. };
  276.  
  277. /// SK9822 controller class.
  278. /// @tparam DATA_PIN the data pin for these LEDs
  279. /// @tparam CLOCK_PIN the clock pin for these LEDs
  280. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  281. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(24)
  282. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(24)>
  283. class SK9822Controller : public CPixelLEDController<RGB_ORDER> {
  284.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  285.     SPI mSPI;
  286.  
  287.     void startBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); }
  288.     void endBoundary(int nLeds) { int nLongWords = (nLeds/32); do { mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nLongWords--); }
  289.  
  290.     inline void writeLed(uint8_t brightness, uint8_t b0, uint8_t b1, uint8_t b2) __attribute__((always_inline)) {
  291. #ifdef FASTLED_SPI_BYTE_ONLY
  292.         mSPI.writeByte(0xE0 | brightness);
  293.         mSPI.writeByte(b0);
  294.         mSPI.writeByte(b1);
  295.         mSPI.writeByte(b2);
  296. #else
  297.         uint16_t b = 0xE000 | (brightness << 8) | (uint16_t)b0;
  298.         mSPI.writeWord(b);
  299.         uint16_t w = b1 << 8;
  300.         w |= b2;
  301.         mSPI.writeWord(w);
  302. #endif
  303.     }
  304.  
  305. public:
  306.     SK9822Controller() {}
  307.  
  308.     virtual void init() {
  309.         mSPI.init();
  310.     }
  311.  
  312. protected:
  313.     /// @copydoc CPixelLEDController::showPixels()
  314.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  315.         mSPI.select();
  316.  
  317.         uint8_t s0 = pixels.getScale0(), s1 = pixels.getScale1(), s2 = pixels.getScale2();
  318. #if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
  319.         const uint16_t maxBrightness = 0x1F;
  320.         uint16_t brightness = ((((uint16_t)max(max(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1;
  321.         s0 = (maxBrightness * s0 + (brightness >> 1)) / brightness;
  322.         s1 = (maxBrightness * s1 + (brightness >> 1)) / brightness;
  323.         s2 = (maxBrightness * s2 + (brightness >> 1)) / brightness;
  324. #else
  325.         const uint8_t brightness = 0x1F;
  326. #endif
  327.  
  328.         startBoundary();
  329.         while (pixels.has(1)) {
  330.             writeLed(brightness, pixels.loadAndScale0(0, s0), pixels.loadAndScale1(0, s1), pixels.loadAndScale2(0, s2));
  331.             pixels.stepDithering();
  332.             pixels.advanceData();
  333.         }
  334.  
  335.         endBoundary(pixels.size());
  336.  
  337.         mSPI.waitFully();
  338.         mSPI.release();
  339.     }
  340.  
  341. };
  342.  
  343.  
  344.  
  345. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  346. //
  347. // P9813 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
  348. //
  349. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  350.  
  351. /// P9813 controller class.
  352. /// @tparam DATA_PIN the data pin for these LEDs
  353. /// @tparam CLOCK_PIN the clock pin for these LEDs
  354. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  355. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(10)
  356. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(10)>
  357. class P9813Controller : public CPixelLEDController<RGB_ORDER> {
  358.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  359.     SPI mSPI;
  360.  
  361.     void writeBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); }
  362.  
  363.     inline void writeLed(uint8_t r, uint8_t g, uint8_t b) __attribute__((always_inline)) {
  364.         FASTLED_REGISTER uint8_t top = 0xC0 | ((~b & 0xC0) >> 2) | ((~g & 0xC0) >> 4) | ((~r & 0xC0) >> 6);
  365.         mSPI.writeByte(top); mSPI.writeByte(b); mSPI.writeByte(g); mSPI.writeByte(r);
  366.     }
  367.  
  368. public:
  369.     P9813Controller() {}
  370.  
  371.     virtual void init() {
  372.         mSPI.init();
  373.     }
  374.  
  375. protected:
  376.     /// @copydoc CPixelLEDController::showPixels()
  377.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  378.         mSPI.select();
  379.  
  380.         writeBoundary();
  381.         while(pixels.has(1)) {
  382.             writeLed(pixels.loadAndScale0(), pixels.loadAndScale1(), pixels.loadAndScale2());
  383.             pixels.advanceData();
  384.             pixels.stepDithering();
  385.         }
  386.         writeBoundary();
  387.         mSPI.waitFully();
  388.  
  389.         mSPI.release();
  390.     }
  391.  
  392. };
  393.  
  394.  
  395. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  396. //
  397. // SM16716 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
  398. //
  399. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  400.  
  401. /// SM16716 controller class.
  402. /// @tparam DATA_PIN the data pin for these LEDs
  403. /// @tparam CLOCK_PIN the clock pin for these LEDs
  404. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  405. /// @tparam SPI_SPEED the clock divider used for these LEDs.  Set using the ::DATA_RATE_MHZ / ::DATA_RATE_KHZ macros.  Defaults to ::DATA_RATE_MHZ(16)
  406. template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = RGB, uint32_t SPI_SPEED = DATA_RATE_MHZ(16)>
  407. class SM16716Controller : public CPixelLEDController<RGB_ORDER> {
  408.     typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
  409.     SPI mSPI;
  410.  
  411.     void writeHeader() {
  412.         // Write out 50 zeros to the spi line (6 blocks of 8 followed by two single bit writes)
  413.         mSPI.select();
  414.         mSPI.template writeBit<0>(0);
  415.         mSPI.writeByte(0);
  416.         mSPI.writeByte(0);
  417.         mSPI.writeByte(0);
  418.         mSPI.template writeBit<0>(0);
  419.         mSPI.writeByte(0);
  420.         mSPI.writeByte(0);
  421.         mSPI.writeByte(0);
  422.         mSPI.waitFully();
  423.         mSPI.release();
  424.     }
  425.  
  426. public:
  427.     SM16716Controller() {}
  428.  
  429.     virtual void init() {
  430.         mSPI.init();
  431.     }
  432.  
  433. protected:
  434.     /// @copydoc CPixelLEDController::showPixels()
  435.     virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  436.         // Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start
  437.         // of each triplet of bytes for rgb data
  438.         // writeHeader();
  439.         mSPI.template writePixels<FLAG_START_BIT, DATA_NOP, RGB_ORDER>( pixels );
  440.         writeHeader();
  441.     }
  442.  
  443. };
  444.  
  445. /// @} ClockedChipsets
  446.  
  447.  
  448. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  449. //
  450. // Clockless template instantiations - see clockless.h for how the timing values are used
  451. //
  452.  
  453. #ifdef FASTLED_HAS_CLOCKLESS
  454. /// @defgroup ClocklessChipsets Clockless Chipsets
  455. /// These chipsets have only a single data line.
  456. ///
  457. /// The clockless chipset controllers use the same base class
  458. /// and the same protocol, but with varying timing periods.
  459. ///
  460. /// These controllers have 3 control points in their cycle for each bit:
  461. ///   @code
  462. ///   At T=0        : the line is raised hi to start a bit
  463. ///   At T=T1       : the line is dropped low to transmit a zero bit
  464. ///   At T=T1+T2    : the line is dropped low to transmit a one bit
  465. ///   At T=T1+T2+T3 : the cycle is concluded (next bit can be sent)
  466. ///   @endcode
  467. ///
  468. /// The units used for T1, T2, and T3 is nanoseconds.  
  469. ///
  470. /// For 8MHz/16MHz/24MHz frequencies, these values are also guaranteed
  471. /// to be integral multiples of an 8MHz clock (125ns increments).
  472. ///
  473. /// @note The base class, ClocklessController, is platform-specific.
  474. /// @{
  475.  
  476. // Allow clock that clockless controller is based on to have different
  477. // frequency than the CPU.
  478. #if !defined(CLOCKLESS_FREQUENCY)
  479.     #define CLOCKLESS_FREQUENCY F_CPU
  480. #endif
  481.  
  482. // We want to force all avr's to use the Trinket controller when running at 8Mhz, because even the 328's at 8Mhz
  483. // need the more tightly defined timeframes.
  484. #if defined(__LGT8F__) || (CLOCKLESS_FREQUENCY == 8000000 || CLOCKLESS_FREQUENCY == 16000000 || CLOCKLESS_FREQUENCY == 24000000) || defined(FASTLED_DOXYGEN) //  || CLOCKLESS_FREQUENCY == 48000000 || CLOCKLESS_FREQUENCY == 96000000) // 125ns/clock
  485.  
  486. /// Frequency multiplier for each clockless data interval.
  487. /// @see Notes in @ref ClocklessChipsets
  488. #define FMUL (CLOCKLESS_FREQUENCY/8000000)
  489.  
  490. /// GE8822 controller class.
  491. /// @copydetails WS2812Controller800Khz
  492. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  493. class GE8822Controller800Khz : public ClocklessController<DATA_PIN, 3 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER, 4> {};
  494.  
  495. /// LPD1886 controller class.
  496. /// @copydetails WS2812Controller800Khz
  497. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  498. class LPD1886Controller1250Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 3 * FMUL, 2 * FMUL, RGB_ORDER, 4> {};
  499.  
  500. /// LPD1886 controller class.
  501. /// @copydetails WS2812Controller800Khz
  502. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  503. class LPD1886Controller1250Khz_8bit : public ClocklessController<DATA_PIN, 2 * FMUL, 3 * FMUL, 2 * FMUL, RGB_ORDER> {};
  504.  
  505. /// WS2812 controller class @ 800 KHz.
  506. /// @tparam DATA_PIN the data pin for these LEDs
  507. /// @tparam RGB_ORDER the RGB ordering for these LEDs
  508. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  509. class WS2812Controller800Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER> {};
  510.  
  511. /// WS2812V5 controller class @ 800 KHz.
  512. /// @copydetails WS2812V5Controller800Khz
  513. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  514. class WS2815V5Controller800Khz : public ClocklessController<DATA_PIN, 1 * FMUL, 4.5 * FMUL, 4.5 * FMUL, RGB_ORDER> {};
  515.  
  516. /// WS2811 controller class @ 800 KHz.
  517. /// @copydetails WS2812Controller800Khz
  518. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  519. class WS2811Controller800Khz : public ClocklessController<DATA_PIN, 3 * FMUL, 4 * FMUL, 3 * FMUL, RGB_ORDER> {};
  520.  
  521. /// DP1903 controller class @ 800 KHz.
  522. /// @copydetails WS2812Controller800Khz
  523. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  524. class DP1903Controller800Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 8 * FMUL, 2 * FMUL, RGB_ORDER> {};
  525.  
  526. /// DP1903 controller class @ 400 KHz.
  527. /// @copydetails WS2812Controller800Khz
  528. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  529. class DP1903Controller400Khz : public ClocklessController<DATA_PIN, 4 * FMUL, 16 * FMUL, 4 * FMUL, RGB_ORDER> {};
  530.  
  531. /// WS2813 controller class.
  532. /// @copydetails WS2812Controller800Khz
  533. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>                                                             //not tested
  534. class WS2813Controller : public ClocklessController<DATA_PIN, 3 * FMUL, 4 * FMUL, 3 * FMUL, RGB_ORDER> {};
  535.  
  536. /// WS2811 controller class @ 400 KHz.
  537. /// @copydetails WS2812Controller800Khz
  538. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  539. class WS2811Controller400Khz : public ClocklessController<DATA_PIN, 4 * FMUL, 10 * FMUL, 6 * FMUL, RGB_ORDER> {};
  540.  
  541. /// SK6822 controller class.
  542. /// @copydetails WS2812Controller800Khz
  543. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  544. class SK6822Controller : public ClocklessController<DATA_PIN, 3 * FMUL, 8 * FMUL, 3 * FMUL, RGB_ORDER> {};
  545.  
  546. /// SM16703 controller class.
  547. /// @copydetails WS2812Controller800Khz
  548. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  549. class SM16703Controller : public ClocklessController<DATA_PIN, 3 * FMUL, 4 * FMUL, 3 * FMUL, RGB_ORDER> {};
  550.  
  551. /// SK6812 controller class.
  552. /// @copydetails WS2812Controller800Khz
  553. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  554. class SK6812Controller : public ClocklessController<DATA_PIN, 3 * FMUL, 3 * FMUL, 4 * FMUL, RGB_ORDER> {};
  555.  
  556. /// UCS1903 controller class @ 400 KHz.
  557. /// @copydetails WS2812Controller800Khz
  558. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  559. class UCS1903Controller400Khz : public ClocklessController<DATA_PIN, 4 * FMUL, 12 * FMUL, 4 * FMUL, RGB_ORDER> {};
  560.  
  561. /// UCS1903B controller class.
  562. /// @copydetails WS2812Controller800Khz
  563. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  564. class UCS1903BController800Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 4 * FMUL, 4 * FMUL, RGB_ORDER> {};
  565.  
  566. /// UCS1904 controller class.
  567. /// @copydetails WS2812Controller800Khz
  568. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  569. class UCS1904Controller800Khz : public ClocklessController<DATA_PIN, 3 * FMUL, 3 * FMUL, 4 * FMUL, RGB_ORDER> {};
  570.  
  571. /// UCS2903 controller class.
  572. /// @copydetails WS2812Controller800Khz
  573. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  574. class UCS2903Controller : public ClocklessController<DATA_PIN, 2 * FMUL, 6 * FMUL, 2 * FMUL, RGB_ORDER> {};
  575.  
  576. /// TM1809 controller class.
  577. /// @copydetails WS2812Controller800Khz
  578. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  579. class TM1809Controller800Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER> {};
  580.  
  581. /// TM1803 controller class.
  582. /// @copydetails WS2812Controller800Khz
  583. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  584. class TM1803Controller400Khz : public ClocklessController<DATA_PIN, 6 * FMUL, 9 * FMUL, 6 * FMUL, RGB_ORDER> {};
  585.  
  586. /// TM1829 controller class.
  587. /// @copydetails WS2812Controller800Khz
  588. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  589. class TM1829Controller800Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 5 * FMUL, 3 * FMUL, RGB_ORDER, 0, true, 500> {};
  590.  
  591. /// GW6205 controller class @ 400 KHz.
  592. /// @copydetails WS2812Controller800Khz
  593. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  594. class GW6205Controller400Khz : public ClocklessController<DATA_PIN, 6 * FMUL, 7 * FMUL, 6 * FMUL, RGB_ORDER, 4> {};
  595.  
  596. /// UCS1904 controller class @ 800 KHz.
  597. /// @copydetails WS2812Controller800Khz
  598. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  599. class GW6205Controller800Khz : public ClocklessController<DATA_PIN, 2 * FMUL, 4 * FMUL, 4 * FMUL, RGB_ORDER, 4> {};
  600.  
  601. /// PL9823 controller class.
  602. /// @copydetails WS2812Controller800Khz
  603. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  604. class PL9823Controller : public ClocklessController<DATA_PIN, 3 * FMUL, 8 * FMUL, 3 * FMUL, RGB_ORDER> {};
  605.  
  606. #else
  607.  
  608. /// Calculates the number of cycles for the clockless chipset (which may differ from CPU cycles)
  609. /// @see ::NS()
  610. #ifdef FASTLED_TEENSY4
  611. // just use raw nanosecond values for the teensy4
  612. #define C_NS(_NS) _NS
  613. #else
  614. #define C_NS(_NS) (((_NS * ((CLOCKLESS_FREQUENCY / 1000000L)) + 999)) / 1000)
  615. #endif
  616.  
  617. // GE8822 - 350ns 660ns 350ns
  618. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  619. class GE8822Controller800Khz : public ClocklessController<DATA_PIN, C_NS(350), C_NS(660), C_NS(350), RGB_ORDER, 4> {};
  620.  
  621. // GW6205@400khz - 800ns, 800ns, 800ns
  622. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  623. class GW6205Controller400Khz : public ClocklessController<DATA_PIN, C_NS(800), C_NS(800), C_NS(800), RGB_ORDER, 4> {};
  624.  
  625. // GW6205@400khz - 400ns, 400ns, 400ns
  626. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  627. class GW6205Controller800Khz : public ClocklessController<DATA_PIN, C_NS(400), C_NS(400), C_NS(400), RGB_ORDER, 4> {};
  628.  
  629. // UCS1903 - 500ns, 1500ns, 500ns
  630. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  631. class UCS1903Controller400Khz : public ClocklessController<DATA_PIN, C_NS(500), C_NS(1500), C_NS(500), RGB_ORDER> {};
  632.  
  633. // UCS1903B - 400ns, 450ns, 450ns
  634. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  635. class UCS1903BController800Khz : public ClocklessController<DATA_PIN, C_NS(400), C_NS(450), C_NS(450), RGB_ORDER> {};
  636.  
  637. // UCS1904 - 400ns, 400ns, 450ns
  638. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  639. class UCS1904Controller800Khz : public ClocklessController<DATA_PIN, C_NS(400), C_NS(400), C_NS(450), RGB_ORDER> {};
  640.  
  641. // UCS2903 - 250ns, 750ns, 250ns
  642. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  643. class UCS2903Controller : public ClocklessController<DATA_PIN, C_NS(250), C_NS(750), C_NS(250), RGB_ORDER> {};
  644.  
  645. // TM1809 - 350ns, 350ns, 550ns
  646. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  647. class TM1809Controller800Khz : public ClocklessController<DATA_PIN, C_NS(350), C_NS(350), C_NS(450), RGB_ORDER> {};
  648.  
  649. // WS2811 - 320ns, 320ns, 640ns
  650. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  651. class WS2811Controller800Khz : public ClocklessController<DATA_PIN, C_NS(320), C_NS(320), C_NS(640), RGB_ORDER> {};
  652.  
  653. // WS2813 - 320ns, 320ns, 640ns
  654. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  655. class WS2813Controller : public ClocklessController<DATA_PIN, C_NS(320), C_NS(320), C_NS(640), RGB_ORDER> {};
  656.  
  657. // WS2812 - 250ns, 625ns, 375ns
  658. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  659. class WS2812Controller800Khz : public ClocklessController<DATA_PIN, C_NS(250), C_NS(625), C_NS(375), RGB_ORDER> {};
  660.  
  661. // WS2811@400khz - 800ns, 800ns, 900ns
  662. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  663. class WS2811Controller400Khz : public ClocklessController<DATA_PIN, C_NS(800), C_NS(800), C_NS(900), RGB_ORDER> {};
  664.  
  665. // 750NS, 750NS, 750NS
  666. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  667. class TM1803Controller400Khz : public ClocklessController<DATA_PIN, C_NS(700), C_NS(1100), C_NS(700), RGB_ORDER> {};
  668.  
  669. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  670. class TM1829Controller800Khz : public ClocklessController<DATA_PIN, C_NS(340), C_NS(340), C_NS(550), RGB_ORDER, 0, true, 500> {};
  671.  
  672. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  673. class TM1829Controller1600Khz : public ClocklessController<DATA_PIN, C_NS(100), C_NS(300), C_NS(200), RGB_ORDER, 0, true, 500> {};
  674.  
  675. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  676. class LPD1886Controller1250Khz : public ClocklessController<DATA_PIN, C_NS(200), C_NS(400), C_NS(200), RGB_ORDER, 4> {};
  677.  
  678. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  679. class LPD1886Controller1250Khz_8bit : public ClocklessController<DATA_PIN, C_NS(200), C_NS(400), C_NS(200), RGB_ORDER> {};
  680.  
  681.  
  682. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  683. class SK6822Controller : public ClocklessController<DATA_PIN, C_NS(375), C_NS(1000), C_NS(375), RGB_ORDER> {};
  684.  
  685. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  686. class SK6812Controller : public ClocklessController<DATA_PIN, C_NS(300), C_NS(300), C_NS(600), RGB_ORDER> {};
  687.  
  688. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  689. class SM16703Controller : public ClocklessController<DATA_PIN, C_NS(300), C_NS(600), C_NS(300), RGB_ORDER> {};
  690.  
  691. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
  692. class PL9823Controller : public ClocklessController<DATA_PIN, C_NS(350), C_NS(1010), C_NS(350), RGB_ORDER> {};
  693. #endif
  694. /// @} ClocklessChipsets
  695.  
  696. #endif
  697. /// @} Chipsets
  698.  
  699. FASTLED_NAMESPACE_END
  700.  
  701. #endif
  702.  
Advertisement
Add Comment
Please, Sign In to add comment