Skip to content

Commit

Permalink
move 8bit to 16bit for LED storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed May 9, 2016
1 parent d76f0d3 commit 3f05d71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Adafruit_TLC5947.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <Adafruit_TLC5947.h>

Adafruit_TLC5947::Adafruit_TLC5947(uint8_t n, uint8_t c, uint8_t d, uint8_t l) {
Adafruit_TLC5947::Adafruit_TLC5947(uint16_t n, uint8_t c, uint8_t d, uint8_t l) {
numdrivers = n;
_clk = c;
_dat = d;
Expand All @@ -32,7 +32,7 @@ Adafruit_TLC5947::Adafruit_TLC5947(uint8_t n, uint8_t c, uint8_t d, uint8_t l) {
void Adafruit_TLC5947::write(void) {
digitalWrite(_lat, LOW);
// 24 channels per TLC5974
for (int8_t c=24*numdrivers - 1; c >= 0 ; c--) {
for (int16_t c=24*numdrivers - 1; c >= 0 ; c--) {
// 12 bits per channel, send MSB first
for (int8_t b=11; b>=0; b--) {
digitalWrite(_clk, LOW);
Expand All @@ -53,14 +53,14 @@ void Adafruit_TLC5947::write(void) {



void Adafruit_TLC5947::setPWM(uint8_t chan, uint16_t pwm) {
void Adafruit_TLC5947::setPWM(uint16_t chan, uint16_t pwm) {
if (pwm > 4095) pwm = 4095;
if (chan > 24*numdrivers) return;
pwmbuffer[chan] = pwm;
}


void Adafruit_TLC5947::setLED(uint8_t lednum, uint16_t r, uint16_t g, uint16_t b) {
void Adafruit_TLC5947::setLED(uint16_t lednum, uint16_t r, uint16_t g, uint16_t b) {
setPWM(lednum*3, r);
setPWM(lednum*3+1, g);
setPWM(lednum*3+2, b);
Expand Down
9 changes: 5 additions & 4 deletions Adafruit_TLC5947.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@

class Adafruit_TLC5947 {
public:
Adafruit_TLC5947(uint8_t n, uint8_t c, uint8_t d, uint8_t l);
Adafruit_TLC5947(uint16_t n, uint8_t c, uint8_t d, uint8_t l);

boolean begin(void);

void setPWM(uint8_t chan, uint16_t pwm);
void setLED(uint8_t lednum, uint16_t r, uint16_t g, uint16_t b);
void setPWM(uint16_t chan, uint16_t pwm);
void setLED(uint16_t lednum, uint16_t r, uint16_t g, uint16_t b);
void write(void);


private:
uint16_t *pwmbuffer;

uint8_t numdrivers, _clk, _dat, _lat;
uint16_t numdrivers;
uint8_t _clk, _dat, _lat;

};

Expand Down

0 comments on commit 3f05d71

Please sign in to comment.