Arduino Code Update for Success Byte Fix

This commit is contained in:
Sven Vogel 2021-07-06 14:41:58 +02:00
parent ee5aee20dc
commit da6e4bbb08
1 changed files with 21 additions and 36 deletions

View File

@ -23,14 +23,6 @@ uint8_t height = STD_HEIGHT;
uint32_t ledCount; uint32_t ledCount;
uint8_t gamma8(uint8_t x) {
uint32_t x2 = (uint32_t) x;
x2 = x2 * x2 * 258 >> 16;
return (uint8_t) x2;
}
CRGB leds[MATRIX_LED_MAX_COUNT]; CRGB leds[MATRIX_LED_MAX_COUNT];
typedef void (*FNPTR_t)(); typedef void (*FNPTR_t)();
@ -75,13 +67,10 @@ void scale() {
Serial.println(ledCount); Serial.println(ledCount);
#endif #endif
FastLED.addLeds<LED_TYPE, DATA_PIN, GRB>(leds, ledCount);
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, ledCount);
for (uint16_t x = 0; x < ledCount; x++) { for (uint16_t x = 0; x < ledCount; x++) {
leds[x].r = 0; leds[x] = 0;
leds[x].g = 0;
leds[x].b = 0;
} }
FastLED.show(); FastLED.show();
@ -93,9 +82,9 @@ void single() {
#endif #endif
uint16_t index = getWord(); uint16_t index = getWord();
uint8_t green = gamma8(getByte()); uint8_t green = getByte();
uint8_t red = gamma8(getByte()); uint8_t red = getByte();
uint8_t blue = gamma8(getByte()); uint8_t blue = getByte();
#ifdef DEBUG_PRINT_CALLBACK #ifdef DEBUG_PRINT_CALLBACK
Serial.print("Index: "); Serial.print("Index: ");
@ -120,12 +109,6 @@ void image() {
Serial.readBytes((char*) leds, ledCount * 3); Serial.readBytes((char*) leds, ledCount * 3);
for (uint16_t x = 0; x < ledCount; x++) {
leds[x].r = gamma8(leds[x].r);
leds[x].g = gamma8(leds[x].g);
leds[x].b = gamma8(leds[x].b);
}
FastLED.show(); FastLED.show();
} }
@ -134,9 +117,9 @@ void fill() {
Serial.println("Called fill"); Serial.println("Called fill");
#endif #endif
uint8_t green = gamma8(getByte()); uint8_t green = getByte();
uint8_t red = gamma8(getByte()); uint8_t red = getByte();
uint8_t blue = gamma8(getByte()); uint8_t blue = getByte();
#ifdef DEBUG_PRINT_CALLBACK #ifdef DEBUG_PRINT_CALLBACK
Serial.print("Red: "); Serial.print("Red: ");
@ -181,14 +164,16 @@ FNPTR_t opcodeTable[] = {
void setup() { void setup() {
ledCount = STD_LED_MAX_COUNT; ledCount = STD_LED_MAX_COUNT;
Serial.begin(9600); Serial.begin(48000);
FastLED.addLeds<LED_TYPE, DATA_PIN, GRB>(leds, ledCount);
FastLED.setCorrection(TypicalLEDStrip);
FastLED.setBrightness(80);
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, ledCount);
for (uint16_t i = 0; i < ledCount; i++) { for (uint16_t i = 0; i < ledCount; i++) {
leds[i].r = 0; leds[i] = 0;
leds[i].g = 0;
leds[i].b = 0;
} }
FastLED.show(); FastLED.show();
} }
@ -207,7 +192,7 @@ void loop() {
if (opcode <= 4) { if (opcode <= 4) {
opcodeTable[opcode](); opcodeTable[opcode]();
Serial.write(21); Serial.write(75);
} }
} }
} }