Skip to content

Commit fab0609

Browse files
committed
Fix mbed not using REFRESH_INTERVAL
Also do not use deprecated float as parameter, switch to chrono duration
1 parent 8297c32 commit fab0609

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/mbed/Servo.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if defined(ARDUINO_ARCH_MBED)
22

3+
#include <chrono>
34
#include <Arduino.h>
45
#include <Servo.h>
56
#include <mbed.h>
@@ -28,11 +29,11 @@ class ServoImpl {
2829

2930
void start(uint32_t duration_us) {
3031
duration = duration_us;
31-
ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);
32+
ticker.attach(mbed::callback(this, &ServoImpl::call), std::chrono::microseconds(REFRESH_INTERVAL));
3233
}
3334

3435
void call() {
35-
timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);
36+
timeout.attach(mbed::callback(this, &ServoImpl::toggle), std::chrono::microseconds(duration));
3637
toggle();
3738
}
3839

0 commit comments

Comments
 (0)