From 0938c1025e8423c04febda94e365e01adf986d3e Mon Sep 17 00:00:00 2001 From: Stefan Rupp Date: Fri, 14 Mar 2014 11:34:51 +0100 Subject: [PATCH] better visible LED steps --- rgbyteclock.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/rgbyteclock.c b/rgbyteclock.c index e51dd54..b3b028b 100644 --- a/rgbyteclock.c +++ b/rgbyteclock.c @@ -18,6 +18,11 @@ #include "ledcontroller.h" + +enum { LED_OFF, LED_GLOW, LED_S0, LED_S1, LED_S2, LED_S3, LED_S4, LED_S5}; +uint16_t led_values[] = {0x00, 0x00cf, 0x02ff, 0x04ff, 0x08ff, 0x10ff, 0x20ff}; + + void rgbyteclock_rounds(void) { @@ -103,21 +108,27 @@ void rgbyteclock_secwatch_glide(void) uint16_t d_m1, d_m2; uint16_t d_h1, d_h2; - d_m2 = ((mins%5)*0x7ffUL)/4; - d_h2 = ((hours%5)*0xfffUL)/4; - d_m1 = ((4-(mins%5))*0x7ffUL)/4; - d_h1 = ((4-(hours%5))*0xfffUL)/4; - + /* + d_m2 = ((mins%5)*d_bright)/4; + d_h2 = ((hours%5)*d_bright)/4; + d_m1 = ((4-(mins%5))*d_bright)/4; + d_h1 = ((4-(hours%5))*d_bright)/4; + */ + d_m2 = led_values[(mins%5)+2]; + d_h2 = led_values[(hours%5)+2]; + d_m1 = led_values[4-(mins%5)+2]; + d_h1 = led_values[4-(hours%5)+2]; + uint16_t d_dark = led_values[1]; ledcontroller_clear(); for (int led=0;led<12;led++) { - led_set(led, 0x000f, 0, 0); + led_set(led, d_dark, 0, 0); } if (l_mins != l_hours) { - led_set(l_mins, 0xf, d_m1, 0); - led_set(l_hours, 0xf, 0, d_h1); - led_set(l_mins_next, 0xf, d_m2, 0); - led_set(l_hours_next, 0xf, 0, d_h2); + led_set(l_mins, d_dark, d_m1, 0); + led_set(l_hours, d_dark, 0, d_h1); + led_set(l_mins_next, d_dark, d_m2, 0); + led_set(l_hours_next, d_dark, 0, d_h2); } else { led_set(l_mins, 0xf, d_m1, d_h1);