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
Open
@aeroyao

Description

@aeroyao

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=000000 51F3 00
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0