Improved adalight show() handling

pull/391/head
cschwinne 2019-11-28 19:25:04 +01:00
rodzic f8e262b87e
commit 2e5f6a3507
1 zmienionych plików z 10 dodań i 4 usunięć

Wyświetl plik

@ -16,12 +16,13 @@ enum class AdaState {
void handleSerial() void handleSerial()
{ {
static auto state = AdaState::Header_A; static auto state = AdaState::Header_A;
static unsigned int count = 0; static uint16_t count = 0;
static unsigned int pixel = 0; static uint16_t pixel = 0;
static byte check = 0x00; static byte check = 0x00;
static byte red = 0x00; static byte red = 0x00;
static byte green = 0x00; static byte green = 0x00;
static byte blue = 0x00; static bool changed = false;
while (Serial.available() > 0) while (Serial.available() > 0)
{ {
byte next = Serial.read(); byte next = Serial.read();
@ -61,18 +62,23 @@ void handleSerial()
state = AdaState::Data_Blue; state = AdaState::Data_Blue;
break; break;
case AdaState::Data_Blue: case AdaState::Data_Blue:
blue = next; byte blue = next;
changed = true;
setRealtimePixel(pixel++, red, green, blue, 0); setRealtimePixel(pixel++, red, green, blue, 0);
if (--count > 0) state = AdaState::Data_Red; if (--count > 0) state = AdaState::Data_Red;
else state = AdaState::Header_A; else state = AdaState::Header_A;
break; break;
} }
}
if (changed)
{
if (!realtimeActive && bri == 0) strip.setBrightness(briLast); if (!realtimeActive && bri == 0) strip.setBrightness(briLast);
arlsLock(realtimeTimeoutMs); arlsLock(realtimeTimeoutMs);
yield(); yield();
strip.show(); strip.show();
changed = false;
} }
} }