TLC5940 library which supports SWSPI, has API to specify grayscale PWM period and has API like Arduino library.

Fork of TLC5940 by Stefan Nielsen

Committer:
deton
Date:
Mon Oct 12 04:28:01 2015 +0000
Revision:
1:b188393f5b49
Parent:
0:bdf7a64b89a7
Child:
2:b411648dfe54
use SWSPI for nRF51822 that does not support 12 bits format SPI.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Julepalme 0:bdf7a64b89a7 1 #ifndef TLC5940_H_
Julepalme 0:bdf7a64b89a7 2 #define TLC5940_H_
Julepalme 0:bdf7a64b89a7 3
Julepalme 0:bdf7a64b89a7 4 #include "mbed.h"
deton 1:b188393f5b49 5 #include "SWSPI.h"
Julepalme 0:bdf7a64b89a7 6
Julepalme 0:bdf7a64b89a7 7 class TLC5940 {
Julepalme 0:bdf7a64b89a7 8 private:
deton 1:b188393f5b49 9 SWSPI _spi;
deton 1:b188393f5b49 10 PwmOut _gsclk;
deton 1:b188393f5b49 11 DigitalOut _sclk;
deton 1:b188393f5b49 12 DigitalOut _xlat;
deton 1:b188393f5b49 13 DigitalOut _blank;
deton 1:b188393f5b49 14 Ticker _t;
deton 1:b188393f5b49 15 uint16_t gs_data[16];
deton 1:b188393f5b49 16 void refresh();
Julepalme 0:bdf7a64b89a7 17 public:
Julepalme 0:bdf7a64b89a7 18 TLC5940(PinName mosi, PinName miso, PinName sck, PinName xlat, PinName blank, PinName gsclk);
deton 1:b188393f5b49 19 void set(int channel, uint16_t brightness);
deton 1:b188393f5b49 20 void setAll(uint16_t brightness);
Julepalme 0:bdf7a64b89a7 21 void flush();
Julepalme 0:bdf7a64b89a7 22 void run();
Julepalme 0:bdf7a64b89a7 23 };
Julepalme 0:bdf7a64b89a7 24
Julepalme 0:bdf7a64b89a7 25 #endif /* TLC5940_H_ */