diff options
Diffstat (limited to 'tube-rotator/stepper.c')
-rw-r--r-- | tube-rotator/stepper.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tube-rotator/stepper.c b/tube-rotator/stepper.c index 064db5a..a498b43 100644 --- a/tube-rotator/stepper.c +++ b/tube-rotator/stepper.c @@ -23,6 +23,7 @@ #include <avr/sfr_defs.h> #include <avr/interrupt.h> #include <util/atomic.h> +#include <math.h> #include "stepper.h" @@ -125,3 +126,8 @@ uint16_t stepper_get_speed(void) { return target_speed; } + +uint8_t stepper_get_speed_rpm(void) +{ + return (uint8_t)lround( ( (double)F_CPU / (double)(51200 * (target_speed + 1) ) ) * 60.0 ); +} |