TLC5940 library which supports SWSPI, has API to specify grayscale PWM period and has API like Arduino library.
Fork of TLC5940 by
TLC5940.h
- Committer:
- deton
- Date:
- 2015-10-17
- Revision:
- 4:fc83415fa28c
- Parent:
- 3:2c0af5f5fa13
- Child:
- 5:c35b2b62f2f3
File content as of revision 4:fc83415fa28c:
#ifndef TLC5940_H_ #define TLC5940_H_ #include "mbed.h" #include "SWSPI.h" class TLC5940 { private: SWSPI _spi; PwmOut _gsclk; DigitalOut _xlat; DigitalOut _blank; Ticker _t; int _gspwmcycle_us; bool _gspwmcycle_repeat; uint16_t gs_data[16]; public: /** * 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(); void refresh(); }; #endif /* TLC5940_H_ */