From 1f9e4ebd3c188cec1c0ff2796ed9bfad9b188229 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Tue, 17 Dec 2024 16:25:20 +0100 Subject: [PATCH] FIX cast with chrono duration --- common/speedometer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/speedometer.cpp b/common/speedometer.cpp index c68b20a..a24d685 100644 --- a/common/speedometer.cpp +++ b/common/speedometer.cpp @@ -110,7 +110,7 @@ void Speedometer::computeSpeed() { // TODO : done //Distance run with one pedal turn = tray size / rear gear size * circumference of the wheel constexpr float ms_in_hour = static_cast(3600 * 1000); - float pedal_rotation_per_hour = ms_in_hour / static_cast(_pedalRotationTime.count()); + float pedal_rotation_per_hour = ms_in_hour / std::chrono::duration_cast(_pedalRotationTime).count(); float gear_ratio = static_cast(kTraySize) / static_cast(this->_gearSize); float wheel_dist_km = static_cast(this->kWheelCircumference) / 1000.0; this->_currentSpeed = gear_ratio * wheel_dist_km * pedal_rotation_per_hour; @@ -141,4 +141,4 @@ void Speedometer::computeDistance() { _lastTime = _timer.elapsed_time(); } -} // namespace bike_computer \ No newline at end of file +} // namespace bike_computer