diff options
author | root <root@ka-ata-killa.panaceas.james.local> | 2021-11-22 11:23:35 +0000 |
---|---|---|
committer | root <root@ka-ata-killa.panaceas.james.local> | 2021-11-22 11:23:35 +0000 |
commit | f75d0b7eabe275a4330eb72dc4a4c5d2af1fb13d (patch) | |
tree | 0587532f19c2833d7ccbab1e63d74f6f7e39544e /stm32/app/hands.c | |
parent | 3028595801878f962bd362421ed3ec5af635ff45 (diff) | |
download | metric_clock-f75d0b7eabe275a4330eb72dc4a4c5d2af1fb13d.tar.gz metric_clock-f75d0b7eabe275a4330eb72dc4a4c5d2af1fb13d.tar.bz2 metric_clock-f75d0b7eabe275a4330eb72dc4a4c5d2af1fb13d.zip |
turn on cycle counter correctly, and add a for-real motor
Diffstat (limited to 'stm32/app/hands.c')
-rw-r--r-- | stm32/app/hands.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/stm32/app/hands.c b/stm32/app/hands.c index 5414d9e..7ac8bb9 100644 --- a/stm32/app/hands.c +++ b/stm32/app/hands.c @@ -5,6 +5,24 @@ unsigned hands_pos[HANDS]; unsigned hands_ready; +static unsigned calc_second_pos (MTIME *m) +{ + uint64_t p; + + p += m->second; + p *= 1000; + p += m->nanosecond / 1000000; + + p *= MOTOR_STEPS; + p /= 100000; + + + + return (unsigned) p; + +} + + static unsigned calc_minute_pos (MTIME *m) { uint64_t p; @@ -58,7 +76,7 @@ void hands_tick (void) static uint32_t last; - if ((ticks - last) < 100) return; + if ((ticks - last) < 10) return; last = ticks; @@ -72,6 +90,7 @@ void hands_tick (void) hands_pos[0] = calc_hour_pos (&m); hands_pos[1] = calc_minute_pos (&m); + //hands_pos[1] = calc_second_pos (&m); hands_ready = 1; for (i = 0, p = 0; i < HANDS; ++i) { |