8000 setBuffer(uint8t bit) issue · Issue #4 · Limb/TLC5951 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

setBuffer(uint8t bit) issue #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aeroyao opened this issue Jun 26, 2015 · 0 comments
Open

setBuffer(uint8t bit) issue #4

aeroyao opened this issue Jun 26, 2015 · 0 comments

Comments

@aeroyao
Copy link
aeroyao commented Jun 26, 2015

i remove the library into the main code to clarify the SPI data is correct .
below is my code

void setup() {
-------$$--------
TLC5951_Init(GSLAT,XBLNK,0);
for(int i = 0; i <= 7; i++){
setLED(i,0,0,4095);
}
-------$$--------
update();
}

void setLED(uint8_t led, uint16_t red, uint16_t green, uint16_t blue){
gsData[led][2] = blue;
gsData[led][1] = green;
gsData[led][0] = red;
}

void update(){
updateControl();
updateGS();
}

void updateGS() {
bufferCount = 0;
digitalWrite(XBLNK, LOW); // Turn off the LED's since we're clocking in data
digitalWrite(GSLAT, LOW); // GS Latch low, so it goes into the GS data latch
for(int8_t a = 7; a >= 0; a--) { // We have 8 LED's. Start at the last since thats how we clock data out
for(int8_t b = 2; b >= 0; b--) { // Each with 3 colors
for(int8_t c = 11; c >= 0; c--) { // each consiting of 12 bits
setBuffer((gsData[a][b] & (1<<c)));
}
}
}
delay(1);
digitalWrite(GSLAT, HIGH);
digitalWrite(GSLAT, LOW);
digitalWrite(XBLNK, HIGH);
}

void setBuffer(uint16_t bit){
bitWrite(buffer, bufferCount, bit);
bufferCount++;
if(bufferCount == 8)
{
Serial.print("buffer=");
Serial.print(buffer,BIN);
Serial.println();
SPI.setBitOrder(LSBFIRST);
SPI.transfer(buffer);
bufferCount = 0;
buffer = 0;
}
}

uint16_t bit result:
buffer=11111111<-20
buffer=11111111<-21 (dot correct end)
buffer=11111111<-1 bit
buffer=00001111<--Blue+Green
buffer=00000000<--Green
buffer=00000000<--Red
buffer=11110000
buffer=11111111
buffer=00000000
buffer=00000000
buffer=00000000
buffer=11111111
buffer=00001111<-11 bit

uint8_t bit result:
buffer=11111111 <-21(dot correct end)
buffer=11110000 <-1 bit
buffer=00001111
buffer=00000000
buffer=00000000
buffer=00000000
buffer=11111111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0