From 9ee23cee1b4bfca05c37b0c8a26376fc99e63ace Mon Sep 17 00:00:00 2001 From: David Madison Date: Tue, 20 Dec 2016 10:07:35 -0500 Subject: [PATCH] Added calibration mode --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index f34fbe1..c1c1d49 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -8,6 +8,7 @@ #define GROUND_PIN 10 // additional grounding pin (optional) #define BRIGHTNESS 255 // maximum brightness #define SPEED 115200 // serial port speed, max available +//#define CALIBRATE // uncomment to set calibration mode // If no serial data is received for a while, the LEDs are shut off // automatically. Value in milliseconds. @@ -139,8 +140,19 @@ void setup() if(bytesRemaining > 0) { if(bytesBuffered > 0) { - if (outPos < sizeof(leds)) - ledsRaw[outPos++] = buffer[indexOut++]; // Issue next byte + if (outPos < sizeof(leds)){ + #ifdef CALIBRATE + if(outPos < 3) + ledsRaw[outPos++] = buffer[indexOut++]; + else{ + ledsRaw[outPos] = ledsRaw[outPos%3]; // Sets RGB data to first LED color + outPos++; + indexOut++; + } + #else + ledsRaw[outPos++] = buffer[indexOut++]; // Issue next byte + #endif + } bytesBuffered--; bytesRemaining--; }