Skip to content

Instantly share code, notes, and snippets.

@aboyett
Created October 30, 2016 21:05
Show Gist options
  • Save aboyett/23ccea0b89fe5feef1fe330f43c04840 to your computer and use it in GitHub Desktop.
Save aboyett/23ccea0b89fe5feef1fe330f43c04840 to your computer and use it in GitHub Desktop.
--- wonky-timer.ino 2016-10-30 13:53:06.501195684 -0700
+++ wonky-timer.nofastled.ino 2016-10-30 13:53:44.877448425 -0700
@@ -30,14 +30,14 @@
void blinkRed() {
leds[0] = CRGB::Red;
log("before red ");
- FastLED.show();
+ //FastLED.show();
log("after red ");
}
void blinkBlack() {
leds[0] = CRGB::Red;
log("before black");
- FastLED.show();
+ //FastLED.show();
log("after black");
}
Starting firmware.
before red 0 19668 ls:19668 r: 19668 b: 20668 Sun Oct 30 20:49:56 2016
after red 0 35790 ls:19668 r: 19668 b: 20668 Sun Oct 30 20:49:57 2016
before black 0 20668 ls:20668 r: 21668 b: 20668 Sun Oct 30 20:49:57 2016
after black 0 55460 ls:20668 r: 21668 b: 20668 Sun Oct 30 20:49:58 2016
before red 1 21668 ls:21668 r: 21668 b: 22668 Sun Oct 30 20:49:58 2016
after red 1 56460 ls:21668 r: 21668 b: 22668 Sun Oct 30 20:49:59 2016
before black 1 22668 ls:22668 r: 23668 b: 22668 Sun Oct 30 20:49:59 2016
after black 1 57460 ls:22668 r: 23668 b: 22668 Sun Oct 30 20:50:00 2016
before red 2 23668 ls:23668 r: 23668 b: 24668 Sun Oct 30 20:50:00 2016
after red 2 58460 ls:23668 r: 23668 b: 24668 Sun Oct 30 20:50:01 2016
before black 2 24668 ls:24668 r: 25668 b: 24668 Sun Oct 30 20:50:01 2016
after black 2 59460 ls:24668 r: 25668 b: 24668 Sun Oct 30 20:50:02 2016
before red 3 25668 ls:25668 r: 25668 b: 26668 Sun Oct 30 20:50:02 2016
after red 3 60460 ls:25668 r: 25668 b: 26668 Sun Oct 30 20:50:03 2016
before black 3 26668 ls:26668 r: 27668 b: 26668 Sun Oct 30 20:50:03 2016
after black 3 61460 ls:26668 r: 27668 b: 26668 Sun Oct 30 20:50:04 2016
before red 4 27668 ls:27668 r: 27668 b: 28668 Sun Oct 30 20:50:04 2016
after red 4 62460 ls:27668 r: 27668 b: 28668 Sun Oct 30 20:50:05 2016
before black 4 28668 ls:28668 r: 29668 b: 28668 Sun Oct 30 20:50:05 2016
after black 4 63460 ls:28668 r: 29668 b: 28668 Sun Oct 30 20:50:06 2016
before red 5 29668 ls:29668 r: 29668 b: 30668 Sun Oct 30 20:50:07 2016
after red 5 64460 ls:29668 r: 29668 b: 30668 Sun Oct 30 20:50:07 2016
before black 5 30668 ls:30668 r: 31668 b: 30668 Sun Oct 30 20:50:08 2016
after black 5 65460 ls:30668 r: 31668 b: 30668 Sun Oct 30 20:50:08 2016
before red 6 31668 ls:31668 r: 31668 b: 32668 Sun Oct 30 20:50:09 2016
after red 6 66460 ls:31668 r: 31668 b: 32668 Sun Oct 30 20:50:09 2016
before black 6 32668 ls:32668 r: 33668 b: 32668 Sun Oct 30 20:50:10 2016
after black 6 67460 ls:32668 r: 33668 b: 32668 Sun Oct 30 20:50:10 2016
Starting firmware.
before red 0 20848 ls:20848 r: 20848 b: 21848 Sun Oct 30 21:02:27 2016
after red 0 20848 ls:20848 r: 20848 b: 21848 Sun Oct 30 21:02:27 2016
before black 0 21848 ls:21848 r: 22848 b: 21848 Sun Oct 30 21:02:28 2016
after black 0 21848 ls:21848 r: 22848 b: 21848 Sun Oct 30 21:02:28 2016
before red 1 22848 ls:22848 r: 22848 b: 23848 Sun Oct 30 21:02:29 2016
after red 1 22848 ls:22848 r: 22848 b: 23848 Sun Oct 30 21:02:29 2016
before black 1 23848 ls:23848 r: 24848 b: 23848 Sun Oct 30 21:02:30 2016
after black 1 23848 ls:23848 r: 24848 b: 23848 Sun Oct 30 21:02:31 2016
before red 2 24848 ls:24848 r: 24848 b: 25848 Sun Oct 30 21:02:31 2016
after red 2 24848 ls:24848 r: 24848 b: 25848 Sun Oct 30 21:02:32 2016
before black 2 25848 ls:25848 r: 26848 b: 25848 Sun Oct 30 21:02:32 2016
after black 2 25848 ls:25848 r: 26848 b: 25848 Sun Oct 30 21:02:33 2016
before red 3 26848 ls:26848 r: 26848 b: 27848 Sun Oct 30 21:02:33 2016
after red 3 26848 ls:26848 r: 26848 b: 27848 Sun Oct 30 21:02:34 2016
before black 3 27848 ls:27848 r: 28848 b: 27848 Sun Oct 30 21:02:34 2016
after black 3 27848 ls:27848 r: 28848 b: 27848 Sun Oct 30 21:02:35 2016
before red 4 28848 ls:28848 r: 28848 b: 29848 Sun Oct 30 21:02:35 2016
after red 4 28848 ls:28848 r: 28848 b: 29848 Sun Oct 30 21:02:36 2016
before black 4 29848 ls:29848 r: 30848 b: 29848 Sun Oct 30 21:02:36 2016
after black 4 29848 ls:29848 r: 30848 b: 29848 Sun Oct 30 21:02:37 2016
before red 5 30848 ls:30848 r: 30848 b: 31848 Sun Oct 30 21:02:37 2016
after red 5 30848 ls:30848 r: 30848 b: 31848 Sun Oct 30 21:02:38 2016
before black 5 31848 ls:31848 r: 32848 b: 31848 Sun Oct 30 21:02:39 2016
after black 5 31848 ls:31848 r: 32848 b: 31848 Sun Oct 30 21:02:39 2016
// allow SYSTICK interrupt to fire
#define FASTLED_ALLOW_INTERRUPTS 1
// This #include statement was automatically added by the Particle IDE.
#include "FastLED/FastLED.h"
FASTLED_USING_NAMESPACE;
// How many leds in your strip?
#define NUM_LEDS 12
#define DATA_PIN 3
// Define the array of leds
CRGB leds[NUM_LEDS];
int count = 0;
long loopstart, millis_after_show, redtime, blacktime; // loopstart is the time each loop starts
String msg;
#define BLINK_INTERVAL 1000
void log(String color) {
msg = String(count) + " " + String(millis()) + " ls:" + loopstart + " r: " + redtime + " b: " + blacktime + " " + Time.timeStr();
Serial.println(color + " " + msg);
}
void pauseAndLog(String color, int numPause = 1, int duration = 1000) {
log(color);
for(int i = 0; i < numPause; i++) {delay(duration);}
}
void blinkRed() {
leds[0] = CRGB::Red;
log("before red ");
FastLED.show();
log("after red ");
}
void blinkBlack() {
leds[0] = CRGB::Red;
log("before black");
FastLED.show();
log("after black");
}
void setup() {
Serial.begin(115200);
delay(15000);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
Serial.println("Starting firmware.");
loopstart = millis();
redtime = loopstart + BLINK_INTERVAL;
blacktime = redtime + BLINK_INTERVAL;
}
void loop() {
loopstart = millis();
if(loopstart >= redtime) {
blinkRed();
redtime += 2 * BLINK_INTERVAL;
}
if(loopstart >= blacktime) {
blinkBlack();
blacktime += 2 * BLINK_INTERVAL;
count++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment