From 090532f841edf82afc6f1983bac2b8beff0e781a Mon Sep 17 00:00:00 2001 From: David Madison Date: Sun, 19 Mar 2017 15:04:36 -0400 Subject: [PATCH 1/6] Changed settings to use constants For type safety --- .../LEDstream_FastLED/LEDstream_FastLED.ino | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 134c97e..8d45fd2 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -4,22 +4,23 @@ * library (http://fastled.io) for driving led strips. * * http://github.com/dmadison/Adalight-FastLED - * Last Updated: 2016-12-21 + * Last Updated: 2017-03-19 */ // -- General Settings -#define NUM_LEDS 80 // strip length -#define LED_PIN 6 // Arduino data output pin -#define BRIGHTNESS 255 // maximum brightness +static const uint8_t Num_Leds = 80; // strip length +static const uint8_t Led_Pin = 6; // Arduino data output pin +static const uint8_t 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 + SerialSpeed = 115200; // serial port speed, max available static const unsigned long // time before LEDs are shut off, if no data - serialTimeout = 150000; // 150 seconds + SerialTimeout = 150000; // 150 seconds // -- Optional Settings (uncomment to add) //#define GROUND_PIN 10 // additional grounding pin (optional) @@ -29,7 +30,7 @@ static const unsigned long // time before LEDs are shut off, if no data #include -CRGB leds[NUM_LEDS]; +CRGB leds[Num_Leds]; uint8_t * ledsRaw = (uint8_t *)leds; // A 'magic word' (along with LED count & checksum) precedes each block @@ -60,10 +61,10 @@ void setup(){ digitalWrite(GROUND_PIN, LOW); #endif - FastLED.addLeds(leds, NUM_LEDS); - FastLED.setBrightness(BRIGHTNESS); + FastLED.addLeds(leds, Num_Leds); + FastLED.setBrightness(Brightness); - Serial.begin(SPEED); + Serial.begin(SerialSpeed); adalight(); } @@ -119,8 +120,8 @@ void adalight(){ lastAckTime = t; // Reset counter } // If no data received for an extended time, turn off all LEDs. - if((t - lastByteTime) > serialTimeout) { - memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); //filling Led array by zeroes + if((t - lastByteTime) > SerialTimeout) { + memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes FastLED.show(); lastByteTime = t; // Reset counter } @@ -145,7 +146,7 @@ void adalight(){ bytesRemaining = 3L * (256L * (long)hi + (long)lo + 1L); bytesBuffered -= 3; outPos = 0; - memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); + memset(leds, 0, Num_Leds * sizeof(struct CRGB)); mode = MODE_DATA; // Proceed to latch wait mode } else { From b591ed106a04af8118d0e52b61bf8e77966c55fb Mon Sep 17 00:00:00 2001 From: David Madison Date: Sun, 19 Mar 2017 18:48:14 -0400 Subject: [PATCH 2/6] Cleaned up header settings --- .../LEDstream_FastLED/LEDstream_FastLED.ino | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 8d45fd2..4959bee 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -7,10 +7,11 @@ * Last Updated: 2017-03-19 */ -// -- General Settings -static const uint8_t Num_Leds = 80; // strip length -static const uint8_t Led_Pin = 6; // Arduino data output pin -static const uint8_t Brightness = 255; // maximum brightness +// --- General Settings +static const uint8_t + Num_Leds = 80, // strip length + Led_Pin = 6, // Arduino data output pin + Brightness = 255; // maximum brightness // --- FastLED Setings #define LED_TYPE WS2812B // led strip type for FastLED @@ -18,11 +19,11 @@ static const uint8_t Brightness = 255; // maximum brightness // --- Serial Settings static const unsigned long - SerialSpeed = 115200; // serial port speed, max available -static const unsigned long // time before LEDs are shut off, if no data - SerialTimeout = 150000; // 150 seconds + SerialSpeed = 115200, // serial port speed, max available + SerialTimeout = 150000; // time before LEDs are shut off, if no data + // (150 seconds) -// -- Optional Settings (uncomment to add) +// --- Optional Settings (uncomment to add) //#define GROUND_PIN 10 // additional grounding pin (optional) //#define CALIBRATE // sets all LEDs to the color of the first @@ -66,6 +67,9 @@ void setup(){ Serial.begin(SerialSpeed); + Serial.println(Num_Leds); + Serial.println(Led_Pin); + adalight(); } From 8485478da561c73c7e4ce6c4c514e20943019902 Mon Sep 17 00:00:00 2001 From: David Madison Date: Sun, 19 Mar 2017 18:53:10 -0400 Subject: [PATCH 3/6] Updated adalight data types --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 4959bee..3fb3db9 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -88,16 +88,16 @@ void adalight(){ mode = MODE_HEADER, hi, lo, chk, i; int16_t - bytesBuffered = 0, c; - int32_t - bytesRemaining; + uint16_t + bytesBuffered = 0; + uint32_t + bytesRemaining, + outPos; unsigned long lastByteTime, lastAckTime, t; - int32_t - outPos = 0; Serial.print("Ada\n"); // Send ACK string to host From 47305050b89c012802578ccaf6a5b370ef6f5537 Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 27 Mar 2017 15:14:02 -0400 Subject: [PATCH 4/6] Added 'clear on start' flag --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 3fb3db9..9f42728 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -24,6 +24,7 @@ static const unsigned long // (150 seconds) // --- Optional Settings (uncomment to add) +//#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 @@ -65,6 +66,10 @@ void setup(){ FastLED.addLeds(leds, Num_Leds); FastLED.setBrightness(Brightness); + #ifdef CLEAR_ON_START + FastLED.show(); + #endif + Serial.begin(SerialSpeed); Serial.println(Num_Leds); From 972f0e7d0e20afd11b22b6a3a17cb966f4dcfb26 Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 27 Mar 2017 15:20:02 -0400 Subject: [PATCH 5/6] Removed debug serial lines --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 3 --- 1 file changed, 3 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 9f42728..19d4c22 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -72,9 +72,6 @@ void setup(){ Serial.begin(SerialSpeed); - Serial.println(Num_Leds); - Serial.println(Led_Pin); - adalight(); } From cb8be4a19007c1388171cbffad7770e62e736bbf Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 27 Mar 2017 15:22:53 -0400 Subject: [PATCH 6/6] Updated date --- 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 19d4c22..1a0cfff 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -4,7 +4,7 @@ * library (http://fastled.io) for driving led strips. * * http://github.com/dmadison/Adalight-FastLED - * Last Updated: 2017-03-19 + * Last Updated: 2017-03-27 */ // --- General Settings