From fab06090cb7e3cd20e0ed7bd7d9a22619e770766 Mon Sep 17 00:00:00 2001 From: Razvan Grigore Date: Wed, 18 Sep 2024 07:20:52 +0300 Subject: [PATCH] Fix mbed not using REFRESH_INTERVAL Also do not use deprecated float as parameter, switch to chrono duration --- src/mbed/Servo.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mbed/Servo.cpp b/src/mbed/Servo.cpp index efb67f9..020b2f9 100644 --- a/src/mbed/Servo.cpp +++ b/src/mbed/Servo.cpp @@ -1,5 +1,6 @@ #if defined(ARDUINO_ARCH_MBED) +#include #include #include #include @@ -28,11 +29,11 @@ class ServoImpl { void start(uint32_t duration_us) { duration = duration_us; - ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f); + ticker.attach(mbed::callback(this, &ServoImpl::call), std::chrono::microseconds(REFRESH_INTERVAL)); } void call() { - timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6); + timeout.attach(mbed::callback(this, &ServoImpl::toggle), std::chrono::microseconds(duration)); toggle(); }