Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First prototype sketch to find equal values of GBC and normal values.
/*
First try to match SK9822 GBC with RGB values.
Based on the test code of Louis Beaudoin.
The difference is best visible in the green color. Probably because our eye is more sensitive for green?
SK9822 high brightness green tends more to lime color (instead of the APA102 green).
I tried to match them (just GBC 15 and finding a similar rgb value on GBC 31). It's not possible.
GBC controlled pixels seem more lime, while without GBC they are more blueish green.
Maybe because of power management?
GBC seems then impossible because of the hue shift with the SK9822.
*/
#include <SPI.h>
void setup() {
SPI.begin();
Serial.begin(57600);
}
uint8_t ledValue;
uint8_t globalBrightness;
boolean oddEven = false;
int counter = 1;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
// Every 2 seconds we change the values
int interval = 2000;
//int ledValues[] = { 255, 127, 63, 31, 16 };
//int globalValues[] = { 31, 15, 7, 3, 1 };
int ledValues[] = { 255, 160, 63, 31, 16 };
int globalValues[] = { 31, 15, 7, 3, 1 };
void loop() {
currentMillis = millis();
// check to see if the interval time is passed.
if (currentMillis - previousMillis >= interval == true ) {
ledValue = ledValues[counter];
globalBrightness = globalValues[counter];
// this fits kind of with APA102
//ledValue = 255 - (counter * 8); // 165
//globalBrightness = 31 - counter; //16; //0x1F - counter;
Serial.print(counter);
Serial.print(" - ");
Serial.print(ledValue);
Serial.print(" - ");
Serial.println(globalBrightness);
//counter++;
//if(counter>4) counter=0;
previousMillis = currentMillis;
}
for(int i=0; i<4; i++) SPI.transfer(0); // Start-frame marker
// switch between to see visual differences.
if(oddEven%2 == 0) {
Serial.println("p1 global");
bitPixel();
gbcPixel();
}
else {
Serial.println("p1 bit");
gbcPixel();
bitPixel();
}
oddEven = !oddEven;
for(int i=0; i<1; i++) SPI.transfer(0xFF); // End-frame marker
// make switching between two leds visible
delay(1000);
}
void gbcPixel() {
// drive second pixel with 8-bit color plus 5-bit global brightness
SPI.transfer(0xE0 | globalBrightness); // Pixel start with global brightness
SPI.transfer(0); // B
SPI.transfer(255); // G
SPI.transfer(0); // R
};
void bitPixel() {
// Pixel with max global brightness
SPI.transfer(0xFF);
SPI.transfer(0); // B
SPI.transfer(ledValue); // G
SPI.transfer(0); // R
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.