From 9b304aec93df91363150c6851586a45a35174f5c Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 1 Sep 2023 16:37:46 +0200 Subject: [PATCH] speed kartculator --- 306-controller_interface.X/app/kartculator.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/306-controller_interface.X/app/kartculator.c b/306-controller_interface.X/app/kartculator.c index 3b271b5..88a490b 100644 --- a/306-controller_interface.X/app/kartculator.c +++ b/306-controller_interface.X/app/kartculator.c @@ -21,7 +21,15 @@ void calcPosition(uint8_t joy_pos){ } void calcSpeed(int32_t rpm) { - + int32_t calcSpeed; + if(rpm>=0){ + calcSpeed = rpm; + } else { + calcSpeed = -rpm; + } + calcSpeed *= 1000; + calcSpeed /= KART_CST.CONTROL_SPEED_FACTOR; + eKart.speed = (uint8_t) calcSpeed; } int16_t getTorque() {