summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2015-02-22 21:00:40 +0100
committerFlorian Baumann <derflob@derflob.de>2015-02-22 21:00:40 +0100
commitd24a123915b0ce6d46d1fe331e0202d2db8069e6 (patch)
treedf7ebdfc07b53c2c94a230986d1fb83dbd6eb1ea
parent5db4465944129256042804dd23342c645199d1d9 (diff)
downloadStripClock-black_white.tar.gz
StripClock-black_white.tar.bz2
-rw-r--r--StripClock.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/StripClock.c b/StripClock.c
index 7b48fa0..8c1f42d 100644
--- a/StripClock.c
+++ b/StripClock.c
@@ -237,36 +237,43 @@ uint8_t updateStrip(void)
return 0;
}
+ const uint8_t cur_min_r = 4;
+ const uint8_t cur_min_g = 16;
+ const uint8_t cur_min_b = 9;
+
+ const uint8_t past_min_r = 2;
+ const uint8_t past_min_g = 2;
+ const uint8_t past_min_b = 1;
+
+ const uint8_t cur_hour_r = 1;
+ const uint8_t cur_hour_g = 5;
+ const uint8_t cur_hour_b = 16;
+
uint8_t hour_led = ((dt.hour % 12) * (LEDS / 12)) - 1;
if (hour_led == -1)
hour_led = 59;
for (uint8_t i = 0; i < LEDS; i++) {
- int16_t r, g, b = 0;
+ uint8_t r, g, b = 0;
- const int16_t cur_min_r = 4 + brightness;
- const int16_t cur_min_g = 16 + brightness;
- const int16_t cur_min_b = 1 + brightness;
- const int16_t past_min_r = 2 + brightness;
- const int16_t past_min_g = 2 + brightness;
- const int16_t past_min_b = 1 + brightness;
if (i < dt.minute - 1) {
//past minute
- r = past_min_r;
- g = past_min_g;
- b = past_min_b;
+ if (i % 5 == 4) {
+ r = 0;
+ g = 0;
+ b = 0;
+ } else {
+ r = past_min_r;
+ g = past_min_g;
+ b = past_min_b;
+ }
} else if (i == dt.minute - 1 || (i == 59 && dt.minute == 0)) {
//running minute
- r = cur_min_r + (past_min_r - cur_min_r) * (int16_t)dt.second / 60;
- g = cur_min_g + (past_min_g - cur_min_g) * (int16_t)dt.second / 60;
- b = cur_min_b + (past_min_b - cur_min_b) * (int16_t)dt.second / 60;
- } else if (i == dt.minute) {
- //next minute
- r = past_min_r + (cur_min_r - past_min_r) * (int16_t)dt.second / 60;
- g = past_min_g + (cur_min_g - past_min_g) * (int16_t)dt.second / 60;
- b = past_min_b + (cur_min_b - past_min_b) * (int16_t)dt.second / 60;
- } else if (i % 5 == 4) {
+ r = cur_min_r;
+ g = cur_min_g;
+ b = cur_min_b;
+ } else if (i % 5 == 4) {
//future hour leds
r = past_min_r;
g = past_min_g;
@@ -275,19 +282,14 @@ uint8_t updateStrip(void)
r = g = b = 0;
}
- if (i % 15 == 14) {
- r *= 5;
- g *= 10;
- b *= 5;
- } else if (i % 5 == 4) {
- r *= 7;
- g *= 7;
- b *= 6;
- }
-
if (i == hour_led) {
- g += 50 + brightness * 2;
- r += 40 + brightness * 2;
+ if (i == dt.minute - 1) {
+ b = 30;
+ } else {
+ r = cur_hour_r;
+ g = cur_hour_g;
+ b = cur_hour_b;
+ }
}
leds[i].r = r;