diff --git a/main.c b/main.c index 0acf287..f531e7d 100644 --- a/main.c +++ b/main.c @@ -114,11 +114,12 @@ static void clock_hours(void) } } -/* set hour progress on clock LEDs - * the hour/time time indication are full arcs, not only position - * whatever arc is smaller is displayed first - * green is for minutes, blur for hours */ -static void clock_hour(uint32_t time) +/* show time on LED clock + * show hours and minutes progress as full arcs + * show second position as marker + * the brightness of the LED shows the progress of the unit + * hours are blue, minutes green, seconds red */ +static void clock_show_time(uint32_t time) { uint32_t led_hour = (WS2812B_LEDS*(255*(uint64_t)(time%ticks_midday)))/ticks_midday; // scale to LED brightnesses for hours uint32_t led_minute = (WS2812B_LEDS*(255*(uint64_t)(time%ticks_hour)))/ticks_hour; // scale to LED brightnesses for minutes @@ -173,6 +174,10 @@ static void clock_hour(uint32_t time) led_hour -= clock_leds[led*3+2]; } } + // don't show seconds on full minute (better for first time setting, barely visible else) + if (time%ticks_minute==0) { + return; + } uint16_t led_second = (WS2812B_LEDS*(time%ticks_minute))/ticks_minute; // get LED for seconds uint8_t brightness_second = (255*(time%ticks_second))/ticks_second; // get brightness for seconds // set second LED @@ -221,6 +226,7 @@ int main(void) ws2812b_setup(); // setup WS2812b LEDs clock_hours(); // show hour markers + clock_clear(); // clear all LEDs leds_set(); // set the colors of all LEDs ws2812b_transmit(); // transmit set color @@ -228,15 +234,28 @@ int main(void) led_on(); // switch on LED to indicate setup completed uint32_t time = 0; // the time to display - bool clear = true; // clear or display time - - while (true) { - clock_hour(time); // set an increment time + uint32_t current_time = 6*ticks_hour+45*ticks_minute+15*ticks_second+ticks_second/4; + printf("setting current time\n"); + while (time