From a20ca0e10841456ac8ab92bd05ba012e85e18ec3 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 11:01:46 -0500 Subject: [PATCH 01/13] Made ground pin explicitly optional --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index 24056f8..e461837 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -5,9 +5,10 @@ #define NUM_LEDS 80 // strip length #define LED_PIN 6 // Arduino data output pin -#define GROUND_PIN 10 // additional grounding pin (optional) #define BRIGHTNESS 255 // maximum brightness #define SPEED 115200 // serial port speed, max available + +//#define GROUND_PIN 10 // additional grounding pin (optional) //#define CALIBRATE // uncomment to set calibration mode // If no serial data is received for a while, the LEDs are shut off @@ -41,8 +42,11 @@ static const uint8_t magic[] = { void setup() { - pinMode(GROUND_PIN, OUTPUT); - digitalWrite(GROUND_PIN, LOW); + #ifdef GROUND_PIN + pinMode(GROUND_PIN, OUTPUT); + digitalWrite(GROUND_PIN, LOW); + #endif + FastLED.addLeds(leds, NUM_LEDS); // Dirty trick: the circular buffer for serial data is 256 bytes, From fb6d13452626791bc1de73179da5f31113dd2941 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 11:02:54 -0500 Subject: [PATCH 02/13] FastLED library include to use system library --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index e461837..917a814 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -1,7 +1,7 @@ // Slightly modified Adalight protocol implementation that uses FastLED // library (http://fastled.io) for driving WS2811/WS2812 led strip -#include "FastLED.h" +#include #define NUM_LEDS 80 // strip length #define LED_PIN 6 // Arduino data output pin From 3a9b6157d07d07a1766dc895d7351d74599b7c04 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 11:19:03 -0500 Subject: [PATCH 03/13] Separated and cleaned settings area --- .../LEDstream_WS2812B/LEDstream_WS2812B.ino | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index 917a814..099b7e1 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -1,19 +1,25 @@ // Slightly modified Adalight protocol implementation that uses FastLED // library (http://fastled.io) for driving WS2811/WS2812 led strip -#include +#include -#define NUM_LEDS 80 // strip length -#define LED_PIN 6 // Arduino data output pin -#define BRIGHTNESS 255 // maximum brightness -#define SPEED 115200 // serial port speed, max available +// -------------------------------------------------------------------- -//#define GROUND_PIN 10 // additional grounding pin (optional) +// -- General Settings +#define NUM_LEDS 80 // strip length +#define LED_PIN 6 // Arduino data output pin +#define BRIGHTNESS 255 // maximum brightness + +// --- Serial Settings +#define SPEED 115200 // serial port speed, max available +static const unsigned long // time before LEDs are shut off, if no data + serialTimeout = 150000; // 150 seconds + +// -- Optional Settings (Uncomment to add) +//#define GROUND_PIN 10 // additional grounding pin (optional) //#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. -static const unsigned long serialTimeout = 150000; // 150 seconds +// -------------------------------------------------------------------- CRGB leds[NUM_LEDS]; uint8_t * ledsRaw = (uint8_t *)leds; From 4cf7d401e3b0c4d596439fc690c3d1820ee0e3e0 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 11:29:46 -0500 Subject: [PATCH 04/13] Generalized FastLED strip parameters --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index 099b7e1..f497dd5 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -1,8 +1,6 @@ // Slightly modified Adalight protocol implementation that uses FastLED // library (http://fastled.io) for driving WS2811/WS2812 led strip -#include - // -------------------------------------------------------------------- // -- General Settings @@ -10,6 +8,10 @@ #define LED_PIN 6 // Arduino data output pin #define BRIGHTNESS 255 // maximum brightness +// --- FastLED Setings +#define LED_TYPE WS2812B // led strip type for FastLED +#define COLOR_ORDER GRB // color order for bitbang + // --- Serial Settings #define SPEED 115200 // serial port speed, max available static const unsigned long // time before LEDs are shut off, if no data @@ -21,6 +23,8 @@ static const unsigned long // time before LEDs are shut off, if no data // -------------------------------------------------------------------- +#include + CRGB leds[NUM_LEDS]; uint8_t * ledsRaw = (uint8_t *)leds; @@ -53,7 +57,7 @@ void setup() digitalWrite(GROUND_PIN, LOW); #endif - FastLED.addLeds(leds, NUM_LEDS); + FastLED.addLeds(leds, NUM_LEDS); // Dirty trick: the circular buffer for serial data is 256 bytes, // and the "in" and "out" indices are unsigned 8-bit types -- this From 821c3633a9bde8350e92606a617bae0b2f638f78 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 11:45:13 -0500 Subject: [PATCH 05/13] Added missing brightness implementation --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index f497dd5..3e2eaa6 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -58,6 +58,7 @@ void setup() #endif FastLED.addLeds(leds, NUM_LEDS); + FastLED.setBrightness(BRIGHTNESS); // Dirty trick: the circular buffer for serial data is 256 bytes, // and the "in" and "out" indices are unsigned 8-bit types -- this From e57f6021887bc689e48d312ba32758bf9478fda7 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 12:02:29 -0500 Subject: [PATCH 06/13] Replaced arduino file header comments --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index 3e2eaa6..9b64b33 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -1,7 +1,14 @@ -// Slightly modified Adalight protocol implementation that uses FastLED -// library (http://fastled.io) for driving WS2811/WS2812 led strip - -// -------------------------------------------------------------------- +/* + * LEDstream_WS2812B + * + * Modified version of Adalight protocol that uses the FastLED + * library (http://fastled.io) for driving led strips. + * + * http://github.com/dmadison/Adalight-FastLED + * + * Modifications by David Madison (@dmadison) + * Last Updated: 2016-12-21 + */ // -- General Settings #define NUM_LEDS 80 // strip length From f88f98b31b95d8146cc865c979a9b30be02f2cfc Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 12:21:39 -0500 Subject: [PATCH 07/13] Moved all adalight code to a separate function --- Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino index 9b64b33..a22a7b2 100644 --- a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino +++ b/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino @@ -57,8 +57,7 @@ static const uint8_t magic[] = { #define MODE_HEADER 0 #define MODE_DATA 2 -void setup() -{ +void setup(){ #ifdef GROUND_PIN pinMode(GROUND_PIN, OUTPUT); digitalWrite(GROUND_PIN, LOW); @@ -67,12 +66,19 @@ void setup() FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(BRIGHTNESS); + Serial.begin(SPEED); + + adalight(); +} + +void adalight(){ // Dirty trick: the circular buffer for serial data is 256 bytes, // and the "in" and "out" indices are unsigned 8-bit types -- this // much simplifies the cases where in/out need to "wrap around" the // beginning/end of the buffer. Otherwise there'd be a ton of bit- // masking and/or conditional code every time one of these indices // needs to change, slowing things down tremendously. + uint8_t buffer[256], indexIn = 0, @@ -91,8 +97,6 @@ void setup() int32_t outPos = 0; - Serial.begin(SPEED); // Teensy/32u4 disregards baud rate; is OK! - Serial.print("Ada\n"); // Send ACK string to host lastByteTime = lastAckTime = millis(); @@ -188,5 +192,5 @@ void setup() void loop() { - // Not used. See note in setup() function. + // Not used. See note in adalight() function. } From 8b71f7febcb59b31e572fa5502a8a0e85061b7fa Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 12:24:52 -0500 Subject: [PATCH 08/13] Renamed file to LEDstream_FastLED.ino --- .../{LEDstream_WS2812B.ino => LEDstream_FastLED.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Arduino/LEDstream_WS2812B/{LEDstream_WS2812B.ino => LEDstream_FastLED.ino} (100%) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino b/Arduino/LEDstream_WS2812B/LEDstream_FastLED.ino similarity index 100% rename from Arduino/LEDstream_WS2812B/LEDstream_WS2812B.ino rename to Arduino/LEDstream_WS2812B/LEDstream_FastLED.ino From a4f429258f5de52231d2bcd2ab2c7de0eec6d7a8 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 12:33:09 -0500 Subject: [PATCH 09/13] Renamed LEDstream_WS2812B folder --- .../LEDstream_FastLED.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Arduino/{LEDstream_WS2812B => LEDstream_FastLED}/LEDstream_FastLED.ino (100%) diff --git a/Arduino/LEDstream_WS2812B/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino similarity index 100% rename from Arduino/LEDstream_WS2812B/LEDstream_FastLED.ino rename to Arduino/LEDstream_FastLED/LEDstream_FastLED.ino From e84ea6ab3f08f225379caf9edcb632e59915e909 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 12:39:00 -0500 Subject: [PATCH 10/13] Changed filename reference in 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 a22a7b2..82921ad 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -1,5 +1,5 @@ /* - * LEDstream_WS2812B + * LEDstream_FastLED * * Modified version of Adalight protocol that uses the FastLED * library (http://fastled.io) for driving led strips. From 0ca83e0bafe9be8aa7f03f4192a1bd1d5048fce4 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 13:10:24 -0500 Subject: [PATCH 11/13] Updated README with generalized FastLED changes --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e9b182a..963ce3f 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,29 @@ ## Synopsis -This is the standard Adalight library, modified to work with the FastLED library ([fastled.io](http://fastled.io)) and 3-pin WS2812B LED strips (2016-era Adafruit NeoPixels). +This is the Adalight library with the Arduino code modified to use [FastLED](https://github.com/FastLED/FastLED) ([fastled.io](http://fastled.io)). This expands Adalight to, in theory, work with [any supported FastLED strip](https://github.com/FastLED/FastLED/wiki/Chipset-reference) including WS2812B (aka Adafruit NeoPixels). -In addition to ambilight setups, the protocol can be used to stream any color data from a computer to a WS2812B strip (data rate limited by serial throughput). +In addition to ambilight setups, the protocol can be used to stream *any* color data from a computer to supported LED strips (data rate limited by serial throughput). ## Configuration -Open the WS2812B file in the Arduino IDE and edit the definitions at the top for your setup. Specifically: +Open the LEDstream_FastLED file in the Arduino IDE and edit the setting definitions at the top for your setup. These include: - Number of LEDs - LED data pin -- LED grounding pin (optional) -- Brightness +- Max brightness +- LED type +- LED color order - Serial speed - Serial timeout length +There are also optional settings to 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. The Processing files are included, though I would recommend using Patrick Siegler's (@psieg) fork of Lightpacks's Prismatik, which you can find [here](https://github.com/psieg/Lightpack). -## Tutorial - -If you'd like you can follow Adafruit's tutorial, which is fairly comprehensive for the WS2801 they use but is otherwise out of date. You can find the tutorial here: - - +## Issues and LED-types +I've only tested the code with the WS2812B strips I have on hand, but so far it performs flawlessly. If you find an issue with the code or can confirm that it works with another chipset, please let me know! ## License From 2e1e3793a6cea6c58e50e7f05f4a8df5280dfa82 Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 13:23:19 -0500 Subject: [PATCH 12/13] Removed byline in arduino header comment --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 82921ad..f7bfd89 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -1,12 +1,9 @@ -/* - * LEDstream_FastLED +/* LEDstream_FastLED * * Modified version of Adalight protocol that uses the FastLED * library (http://fastled.io) for driving led strips. * * http://github.com/dmadison/Adalight-FastLED - * - * Modifications by David Madison (@dmadison) * Last Updated: 2016-12-21 */ From 1a2b6b8a7b6fb4445b1ecfd52154307021e082fe Mon Sep 17 00:00:00 2001 From: David Madison Date: Wed, 21 Dec 2016 14:13:59 -0500 Subject: [PATCH 13/13] Rewrote calibration flag description --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index f7bfd89..134c97e 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -21,9 +21,9 @@ static const unsigned long // time before LEDs are shut off, if no data serialTimeout = 150000; // 150 seconds -// -- Optional Settings (Uncomment to add) +// -- Optional Settings (uncomment to add) //#define GROUND_PIN 10 // additional grounding pin (optional) -//#define CALIBRATE // uncomment to set calibration mode +//#define CALIBRATE // sets all LEDs to the color of the first // --------------------------------------------------------------------