diff options
author | root <root@lumpy.lan> | 2021-11-30 00:24:43 +0000 |
---|---|---|
committer | root <root@lumpy.lan> | 2021-11-30 00:24:43 +0000 |
commit | 869118f74612829db47d0d681cee5b4af937b16f (patch) | |
tree | 9195fea1c0d6a002704ba2f452a4ec131923da80 /stm32/app/hands.c | |
parent | 440039cb23f786573940ec1eafa665f9de561eae (diff) | |
download | metric_clock-869118f74612829db47d0d681cee5b4af937b16f.tar.gz metric_clock-869118f74612829db47d0d681cee5b4af937b16f.tar.bz2 metric_clock-869118f74612829db47d0d681cee5b4af937b16f.zip |
Diffstat (limited to 'stm32/app/hands.c')
-rw-r--r-- | stm32/app/hands.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/stm32/app/hands.c b/stm32/app/hands.c index f1543ac..4eda256 100644 --- a/stm32/app/hands.c +++ b/stm32/app/hands.c @@ -70,8 +70,6 @@ void hands_tick (void) EPOCH e; UTC u; MTIME m; - static unsigned old_pos[HANDS]; - unsigned i, p; static uint32_t last; @@ -87,18 +85,19 @@ void hands_tick (void) u = time_epoch_to_utc (e); m = time_to_metric (e, u); - #if 0 hands_pos[0] = calc_hour_pos (&m); -if ((e.s & 31) <5) { - hands_pos[1] =hands_pos[0]; -} else { - hands_pos[1] = calc_minute_pos (&m); -} + if ((e.s & 31) < 5) + hands_pos[1] = hands_pos[0]; + + else + hands_pos[1] = calc_minute_pos (&m); + #endif hands_pos[0] = calc_second_pos (&m); + hands_pos[1] = calc_hour_pos (&m); hands_pos[1] = calc_minute_pos (&m); @@ -106,18 +105,23 @@ if ((e.s & 31) <5) { hands_ready = 1; #if 0 - for (i = 0, p = 0; i < HANDS; ++i) { - if (hands_pos[i] != old_pos[i]) p++; + { + static unsigned old_pos[HANDS]; + unsigned i; - old_pos[i] = hands_pos[i]; + for (i = 0, p = 0; i < HANDS; ++i) { + if (hands_pos[i] != old_pos[i]) p++; - } + old_pos[i] = hands_pos[i]; + + } - if (p) { - printf("Epoch %d.%09d\r\n",(unsigned) e.s,(unsigned) e.ns); - time_print_utc ("UTC: ", &u, NULL); - time_print_metric ("Metric: ", &m, NULL); - printf ("Hands: hour %4d/%4d min %4d/%4d\r\n", hands_pos[0], MOTOR_STEPS, hands_pos[1], MOTOR_STEPS); + if (p) { + printf ("Epoch %d.%09d\r\n", (unsigned) e.s, (unsigned) e.ns); + time_print_utc ("UTC: ", &u, NULL); + time_print_metric ("Metric: ", &m, NULL); + printf ("Hands: hour %4d/%4d min %4d/%4d\r\n", hands_pos[0], MOTOR_STEPS, hands_pos[1], MOTOR_STEPS); + } } #endif |