TLC5940 library which supports SWSPI, has API to specify grayscale PWM period and has API like Arduino library.
Fork of TLC5940 by
Diff: TLC5940.h
- Revision:
- 3:2c0af5f5fa13
- Parent:
- 2:b411648dfe54
- Child:
- 4:fc83415fa28c
--- a/TLC5940.h Tue Oct 13 12:20:23 2015 +0000 +++ b/TLC5940.h Sat Oct 17 01:36:58 2015 +0000 @@ -8,14 +8,28 @@ private: SWSPI _spi; PwmOut _gsclk; - DigitalOut _sclk; DigitalOut _xlat; - DigitalOut _blank; + DigitalOut _blank; Ticker _t; + int _gspwmcycle_us; + bool _gspwmcycle_repeat; uint16_t gs_data[16]; void refresh(); public: - TLC5940(PinName mosi, PinName miso, PinName sck, PinName xlat, PinName blank, PinName gsclk); + /** + * Constructor. + * @param mosi -> SIN + * @param miso -> (not connect to TLC5940) + * @param sck -> SCLK + * @param xlat -> XLAT + * @param blank -> BLANK + * @param gsclk -> GSCLK + * @param gspwmcycle_us grayscale PWM cycle in [us]. consists of 4096 pulses. + * @param gspwmcycle_repeat repeat grayscale PWM cycle or not. + * If true, send BLANK pulse after each grayscale PWM cycle using Ticker. + */ + TLC5940(PinName mosi, PinName miso, PinName sck, PinName xlat, PinName blank, PinName gsclk, + int gspwmcycle_us = 20480, bool gspwmcycle_repeat = true); void set(int channel, uint16_t brightness); void flush(); void run();