TLC5940 library which supports SWSPI, has API to specify grayscale PWM period and has API like Arduino library.
Fork of TLC5940 by
Diff: TLC5940.cpp
- Revision:
- 5:c35b2b62f2f3
- Parent:
- 3:2c0af5f5fa13
- Child:
- 6:04354724a9c6
--- a/TLC5940.cpp Sat Oct 17 02:47:11 2015 +0000 +++ b/TLC5940.cpp Sat Oct 17 06:52:23 2015 +0000 @@ -1,6 +1,7 @@ #include "TLC5940.h" -TLC5940::TLC5940(PinName mosi, PinName miso, PinName sck, PinName xlat, PinName blank, PinName gsclk, +template<typename T> +TLC5940<T>::TLC5940(PinName mosi, PinName miso, PinName sck, PinName xlat, PinName blank, PinName gsclk, int gspwmcycle_us, bool gspwmcycle_repeat): _spi(mosi, miso, sck), _gsclk(gsclk), @@ -24,13 +25,14 @@ _xlat.write(0); } -void TLC5940::set(int channel, uint16_t brightness) +template<typename T> +void TLC5940<T>::set(int channel, uint16_t brightness) { gs_data[15-channel] = brightness; } - -void TLC5940::flush() +template<typename T> +void TLC5940<T>::flush() { //_sclk.write(1); //_sclk.write(0); @@ -45,7 +47,8 @@ _blank.write(0); } -void TLC5940::run() +template<typename T> +void TLC5940<T>::run() { if (_gspwmcycle_repeat) { _t.attach_us(this, &TLC5940::refresh, _gspwmcycle_us); @@ -53,8 +56,13 @@ _gsclk.write(0.5f); } -void TLC5940::refresh() +template<typename T> +void TLC5940<T>::refresh() { _blank.write(1); _blank.write(0); } + +template class TLC5940<SPI>; +#include "SWSPI.h" +template class TLC5940<SWSPI>;