From d46782ca68dab6d9e5448b63bd85bfadc469092c Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 15:34:57 -0400 Subject: [PATCH 01/12] Removed date No reason to keep track in both vc and the file --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index a662252..b55d79b 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -4,7 +4,6 @@ * library (http://fastled.io) for driving led strips. * * http://github.com/dmadison/Adalight-FastLED - * Last Updated: 2017-05-05 */ // --- General Settings From edf0fef088b19afa639f2ffc055e94caa83bdc57 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 15:40:09 -0400 Subject: [PATCH 02/12] Increased max number of LEDs 21,845 should be the new max (untested) --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index b55d79b..76c9fa3 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -7,8 +7,9 @@ */ // --- General Settings -static const uint8_t - Num_Leds = 80, // strip length +static const uint16_t + Num_Leds = 80; // strip length +static const uint8_t Led_Pin = 6, // Arduino data output pin Brightness = 255; // maximum brightness From ed8eab001b6b05437a41f79ea5d33f02953e06de Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 15:58:47 -0400 Subject: [PATCH 03/12] Added LGPL license While the program is already licensed under LGPL, adding into the program file itself to be clear. --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 76c9fa3..a261182 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -4,6 +4,21 @@ * library (http://fastled.io) for driving led strips. * * http://github.com/dmadison/Adalight-FastLED + * + * -------------------------------------------------------------------- + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * -------------------------------------------------------------------- */ // --- General Settings From c559b3949f402f15146d71da046960bbb53ad7d1 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 16:28:17 -0400 Subject: [PATCH 04/12] Added serial buffer flush option --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index a261182..d581359 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -40,6 +40,7 @@ static const uint16_t // --- Optional Settings (uncomment to add) //#define CLEAR_ON_START // LEDs are cleared on reset +//#define SERIAL_FLUSH // Serial buffer cleared on LED latch //#define GROUND_PIN 10 // additional grounding pin (optional) //#define CALIBRATE // sets all LEDs to the color of the first @@ -214,6 +215,9 @@ void dataMode(){ FastLED.show(); D_FPS; D_LED(OFF); + #ifdef SERIAL_FLUSH + serialFlush(); + #endif } } @@ -245,3 +249,9 @@ void timeouts(){ } } } + +void serialFlush(){ + while(Serial.available() > 0) { + byte r = Serial.read(); + } +} From 4bcf36b6cc41c08944a2c5973ed19895873acc92 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 17:04:22 -0400 Subject: [PATCH 05/12] Changed mode to use enum --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index d581359..ca78bd7 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -78,11 +78,8 @@ static const uint8_t magic[] = { #define LOCHECK (MAGICSIZE + 1) #define CHECKSUM (MAGICSIZE + 2) -#define MODE_HEADER 0 -#define MODE_DATA 1 +enum processModes_t {Header, Data} mode = Header; -static uint8_t - mode = MODE_HEADER; static int16_t c; static uint16_t @@ -150,10 +147,10 @@ void adalight(){ lastByteTime = lastAckTime = t; // Reset timeout counters switch(mode) { - case MODE_HEADER: + case Header: headerMode(); break; - case MODE_DATA: + case Data: dataMode(); break; } @@ -194,7 +191,7 @@ void headerMode(){ bytesRemaining = 3L * (256L * (long)hi + (long)lo + 1L); outPos = 0; memset(leds, 0, Num_Leds * sizeof(struct CRGB)); - mode = MODE_DATA; // Proceed to latch wait mode + mode = Data; // Proceed to latch wait mode } headPos = 0; // Reset header position regardless of checksum result break; @@ -211,7 +208,7 @@ void dataMode(){ if(bytesRemaining == 0) { // End of data -- issue latch: - mode = MODE_HEADER; // Begin next header search + mode = Header; // Begin next header search FastLED.show(); D_FPS; D_LED(OFF); From cbc5252391a9c1ec2045e7d153b271e13fd0d2e4 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 17:06:36 -0400 Subject: [PATCH 06/12] Removed 'protocol' from header comment --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index ca78bd7..d41f606 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -1,6 +1,6 @@ /* LEDstream_FastLED * - * Modified version of Adalight protocol that uses the FastLED + * Modified version of Adalight that uses the FastLED * library (http://fastled.io) for driving led strips. * * http://github.com/dmadison/Adalight-FastLED From 84d58138520a703ba21d07801876983ed4ab389d Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 17:10:57 -0400 Subject: [PATCH 07/12] Enabled 'serial flush' by default --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index d41f606..f189276 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -40,7 +40,7 @@ static const uint16_t // --- Optional Settings (uncomment to add) //#define CLEAR_ON_START // LEDs are cleared on reset -//#define SERIAL_FLUSH // Serial buffer cleared on LED latch +#define SERIAL_FLUSH // Serial buffer cleared on LED latch //#define GROUND_PIN 10 // additional grounding pin (optional) //#define CALIBRATE // sets all LEDs to the color of the first From 4cb6aa1096123b59264fc20aaa3f0c8b1bd38206 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 17:16:55 -0400 Subject: [PATCH 08/12] Removed 'max available' comment for baud rate The code works at higher baud rates. My setup, currently, runs at 250000 baud. --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index f189276..185592c 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -34,7 +34,7 @@ static const uint8_t // --- Serial Settings static const unsigned long - SerialSpeed = 115200; // serial port speed, max available + SerialSpeed = 115200; // serial port speed static const uint16_t SerialTimeout = 150; // time before LEDs are shut off if no data (in seconds) From fc4ccd693ee161218e83eaaeec6bbc7342249035 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 17:47:19 -0400 Subject: [PATCH 09/12] Added mode reset during LED clear Prevents partial frames being shown if the LEDs are cleared in the middle of data parsing. --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 185592c..781a5df 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -242,6 +242,7 @@ void timeouts(){ if((t - lastByteTime) > SerialTimeout * 1000) { memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes FastLED.show(); + mode = Header; lastByteTime = t; // Reset counter } } From aacedb9725d380a896f460a63d3b6b90449dc1ac Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 17:51:43 -0400 Subject: [PATCH 10/12] Moved 'clear on start' position in settings list Emphasis on serial flush being enabled by default. Also looks better visually. --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 781a5df..01db0e1 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -39,8 +39,8 @@ static const uint16_t SerialTimeout = 150; // time before LEDs are shut off if no data (in seconds) // --- Optional Settings (uncomment to add) -//#define CLEAR_ON_START // LEDs are cleared on reset #define SERIAL_FLUSH // Serial buffer cleared on LED latch +//#define CLEAR_ON_START // LEDs are cleared on reset //#define GROUND_PIN 10 // additional grounding pin (optional) //#define CALIBRATE // sets all LEDs to the color of the first From 774316752e73d2e746a0b6a194612bdf3e8d4f95 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 18:03:22 -0400 Subject: [PATCH 11/12] Update README.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 248fc58..507e77f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ In addition to ambilight setups, the protocol can be used to stream *any* color For this sketch to work, you'll need to have a copy of the FastLED library. You can download FastLED [from GitHub](https://github.com/FastLED/FastLED) or through the libraries manager of the Arduino IDE. This program was writen using FastLED 3.1.3 - note that earlier versions of FastLED are untested and may not work properly. -## Configuration +## Basic Setup Open the LEDstream_FastLED file in the Arduino IDE and customize the settings at the top for your setup. You will need to change: @@ -18,16 +18,18 @@ Open the LEDstream_FastLED file in the Arduino IDE and customize the settings at - LED data pin - LED type -Additional settings allow for adjusting: +Upload to your Arduino and use a corresponding PC application to stream color data. You can get the Processing files from the [main Adalight repository](https://github.com/adafruit/Adalight), though I would recommend using [Patrick Siegler's](https://github.com/psieg/) fork of Lightpacks's Prismatik, which you can find [here](https://github.com/psieg/Lightpack/releases). + +## Additional Settings + +There are additional settings to allow for adjusting: - Max brightness - LED color order - Serial speed - Serial timeout length -There are also optional settings to clear the LEDs on reset, configure a dedicated ground pin, and to put the Arduino into a "calibration" mode, where all LED colors match the first LED. - -Upload to your Arduino and use a corresponding PC application to stream color data. You can get the Processing files from the [main Adalight repository](https://github.com/adafruit/Adalight), though I would recommend using [Patrick Siegler's](https://github.com/psieg/) fork of Lightpacks's Prismatik, which you can find [here](https://github.com/psieg/Lightpack/releases). +There are also optional settings to clear the LEDs on reset, configure a dedicated ground pin, and to put the Arduino into a "calibration" mode, where all LED colors match the first LED. To help with flickering, the option to flush the serial buffer after every latch is enabled by default. ## Debug Settings From 9fa76f44ea87cb7436833fc43e8a6ab6d8e81061 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 8 Jun 2017 19:34:55 -0400 Subject: [PATCH 12/12] Linked ambilight project page --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 507e77f..9c2c8e5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ In addition to ambilight setups, the protocol can be used to stream *any* color For this sketch to work, you'll need to have a copy of the FastLED library. You can download FastLED [from GitHub](https://github.com/FastLED/FastLED) or through the libraries manager of the Arduino IDE. This program was writen using FastLED 3.1.3 - note that earlier versions of FastLED are untested and may not work properly. +For more information on my own ambilight setup, see [the project page](http://www.partsnotincluded.com/projects/ambilight/) on [PartsNotIncluded.com](http://www.partsnotincluded.com/). + ## Basic Setup Open the LEDstream_FastLED file in the Arduino IDE and customize the settings at the top for your setup. You will need to change: