From bc38a5b77799006c2d4e36a317d632cf25316372 Mon Sep 17 00:00:00 2001 From: jackw01 Date: Sun, 9 Sep 2018 19:12:13 -0700 Subject: [PATCH] fix up trail and glow code --- constants.h | 3 +++ led-ring-clock.ino | 23 +++++------------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/constants.h b/constants.h index 8be339f..0c273bb 100644 --- a/constants.h +++ b/constants.h @@ -51,6 +51,9 @@ const bool twelveHour = true; const int hourGlowWidth = 4; // Pixels in each direction const int minuteGlowWidth = 2; // Pixels in each direction const int secondGlowWidth = 1; // Pixels in each direction +const int hourTrailLength = 1; +const int minuteTrailLength = 2; +const int secondTrailLength = 3; const int buttonClickRepeatDelayMs = 1500; const int buttonLongPressDelayMs = 300; diff --git a/led-ring-clock.ino b/led-ring-clock.ino index 20ff7b1..ada39ed 100644 --- a/led-ring-clock.ino +++ b/led-ring-clock.ino @@ -191,9 +191,11 @@ void drawDotClockTrail() { float m = minutePosition(); float s = secondPosition(); - for (float i = h - 1.0; i < h + 2.0; i++) setLed(i, hourColor(), BlendModeAdd, 1.0); - for (float i = -4.0; i < 1.0; i++) setLed(m + i, minuteColor(), BlendModeAdd, 1.0 + (i / 5.0)); - if (showSecondHand) for (float i = -3.0; i < 1.0; i++) setLed(s + i, secondColor(), BlendModeAdd, 1.0 + (i / 4.0)); + for (float i = -hourTrailLength; i < 1.0; i++) setLed(h + i, hourColor(), BlendModeAdd, mapFloat(i, -hourTrailLength, 1.0, 0.1, 1.0)); + for (float i = -minuteTrailLength; i < 1.0; i++) setLed(m + i, minuteColor(), BlendModeAdd, mapFloat(i, -minuteTrailLength, 1.0, 0.1, 1.0)); + if (showSecondHand) { + for (float i = -secondTrailLength; i < 1.0; i++) setLed(s + i, secondColor(), BlendModeAdd, mapFloat(i, -secondTrailLength, 1.0, 0.1, 1.0)); + } FastLED.show(); } @@ -215,21 +217,6 @@ void drawDotClockGlow() { setLed(i, secondColor(), BlendModeAdd, mapFloat(fabs(s - i), 0.0, secondGlowWidth, 1.0, 0.1)); } } - /* - for (int i = -6; i < ledRingSize + 6; i++) { - int j; - for (j = 0; j <= 4; j++) { - if (h + j == i || h - j == i) blendAdd(wrap(i), CRGB(255, 0, 0), 1 - mapFloat(j, 0.0, 6.0, 0.1, 0.99)); - } - for (j = 0; j <= 2; j++) { - if (m + j == i || m - j == i) blendAdd(wrap(i), CRGB(0, 255, 0), 1 - mapFloat(j, 0.0, 3.0, 0.1, 0.99)); - } - if (showSecondHand) { - for (j = 0; j <= 1; j++) { - if (s + j == i || s - j == i) blendAdd(wrap(i), CRGB(0, 0, 255), 1 - mapFloat(j, 0.0, 1.0, 0.1, 0.65)); - } - } - }*/ FastLED.show(); }