Merge pull request #10 from dmadison/development

Function variables made explicitly static, bugfix for #9
This commit is contained in:
David Madison 2017-04-23 04:42:23 -04:00 committed by GitHub
commit 1ec552edc2
1 changed files with 24 additions and 7 deletions

View File

@ -4,7 +4,7 @@
* library (http://fastled.io) for driving led strips. * library (http://fastled.io) for driving led strips.
* *
* http://github.com/dmadison/Adalight-FastLED * http://github.com/dmadison/Adalight-FastLED
* Last Updated: 2017-04-08 * Last Updated: 2017-04-23
*/ */
// --- General Settings // --- General Settings
@ -27,6 +27,8 @@ static const unsigned long
//#define CLEAR_ON_START // LEDs are cleared on reset //#define CLEAR_ON_START // LEDs are cleared on reset
//#define GROUND_PIN 10 // additional grounding pin (optional) //#define GROUND_PIN 10 // additional grounding pin (optional)
//#define CALIBRATE // sets all LEDs to the color of the first //#define CALIBRATE // sets all LEDs to the color of the first
//#define DEBUG_LED 13 // turns on the Arduino's built-in LED
// if the magic word + checksum match
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@ -67,6 +69,11 @@ void setup(){
digitalWrite(GROUND_PIN, LOW); digitalWrite(GROUND_PIN, LOW);
#endif #endif
#ifdef DEBUG_LED
pinMode(DEBUG_LED, OUTPUT);
digitalWrite(DEBUG_LED, LOW);
#endif
FastLED.addLeds<LED_TYPE, Led_Pin, COLOR_ORDER>(leds, Num_Leds); FastLED.addLeds<LED_TYPE, Led_Pin, COLOR_ORDER>(leds, Num_Leds);
FastLED.setBrightness(Brightness); FastLED.setBrightness(Brightness);
@ -80,20 +87,22 @@ void setup(){
} }
void adalight(){ void adalight(){
uint8_t static uint8_t
mode = MODE_HEADER, mode = MODE_HEADER;
static uint8_t
headPos, headPos,
hi, lo, chk; hi, lo, chk;
int16_t int16_t
c; c;
uint16_t static uint16_t
outPos; outPos;
uint32_t static uint32_t
bytesRemaining; bytesRemaining;
unsigned long unsigned long
lastByteTime,
lastAckTime,
t; t;
static unsigned long
lastByteTime,
lastAckTime;
Serial.print("Ada\n"); // Send ACK string to host Serial.print("Ada\n"); // Send ACK string to host
@ -134,6 +143,10 @@ void adalight(){
if(chk == (hi ^ lo ^ 0x55)) { if(chk == (hi ^ lo ^ 0x55)) {
// Checksum looks valid. Get 16-bit LED count, add 1 // Checksum looks valid. Get 16-bit LED count, add 1
// (# LEDs is always > 0) and multiply by 3 for R,G,B. // (# LEDs is always > 0) and multiply by 3 for R,G,B.
#ifdef DEBUG_LED
digitalWrite(DEBUG_LED, HIGH);
#endif
bytesRemaining = 3L * (256L * (long)hi + (long)lo + 1L); bytesRemaining = 3L * (256L * (long)hi + (long)lo + 1L);
outPos = 0; outPos = 0;
memset(leds, 0, Num_Leds * sizeof(struct CRGB)); memset(leds, 0, Num_Leds * sizeof(struct CRGB));
@ -166,6 +179,10 @@ void adalight(){
// End of data -- issue latch: // End of data -- issue latch:
mode = MODE_HEADER; // Begin next header search mode = MODE_HEADER; // Begin next header search
FastLED.show(); FastLED.show();
#ifdef DEBUG_LED
digitalWrite(DEBUG_LED, LOW);
#endif
} }
break; break;
} // end switch } // end switch