The servo library not fully compatible with Arduino H7 yet?, how can i fix this issues?

Hello guys :slight_smile:
i got this warning and errors when verification the code, it looks the servo library not compatible with Arduino H7 yet, how can i fix this issues:
\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::start(uint32_t)': \Arduino\libraries\Servo\src\mbed\Servo.cpp:31:66: warning: 'void mbed::TickerBase::attach(F&&, float) [with F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not a float second count. For example use 10ms rather than 0.01f. [since mbed-os-6.0.0] [-Wdeprecated-declarations] ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f); mbed_portenta\4.0.10\cores\arduino/mbed/drivers/include/drivers/Ticker.h:92:10: note: declared here void attach(F &&func, float t) ^~

Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::call()': Arduino\libraries\Servo\src\mbed\Servo.cpp:35:80: warning: 'void mbed::TickerBase::attach(F&&, float) [with F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not a float second count. For example use 10ms rather than 0.01f. [since mbed-os-6.0.0] [-Wdeprecated-declarations] timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);
^
In file included from packages\Arduino\hardware\mbed_portenta\4.0.10\cores\arduino/mbed/mbed.h:84:0, packages\arduino\hardware\mbed_portenta\4.0.10\cores\arduino/mbed.h:8, Arduino\libraries\Servo\src\mbed\Servo.cpp:5: packages\arduino\hardware\mbed_portenta\4.0.10\cores\arduino/mbed/drivers/include/drivers/Ticker.h:92:10: note: declared here void attach(F &&func, float t)

the GPT4 told me to do that: To fix your warning, you need to replace the float parameter with a chrono duration in your code. For example, instead of writing:

timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);

You should write:

timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration * 1us);

This will make your code more precise and compatible with future versions of Mbed OS. but after editing the servo.cpp i got new errors, i dont know what to do?
Thanks :slight_smile:

Hi @ghiathkamel. I guess you didn't notice my comment on the GitHub issue you submitted:

It is important to understand the difference between warnings and errors. A warning is the compiler telling you there is something in the code that could possibly cause a problem but doesn't cause the compilation to fail. An error is a problem with the code that causes compilation to fail. In this case you have posted warnings, not errors. In order to avoid confusion, we should be careful to use the appropriate terminology when communicating about technical subjects.

The code in the library that causes the warnings should be fixed, and we will use this issue to track that task. However, as long as the library is functional you should not let the warnings distract you from progressing with your project.

1 Like