Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings when compiling library for Portenta H7 #123

Open
ghiathkamel opened this issue Feb 5, 2024 · 6 comments
Open

Warnings when compiling library for Portenta H7 #123

ghiathkamel opened this issue Feb 5, 2024 · 6 comments
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@ghiathkamel
Copy link

ghiathkamel commented Feb 5, 2024

It looks like the Servo library is not compatible with Arduino Portenta H7 board yet.

I got these errors when compiling the code:

\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)

Additional context

Forum topic for discussion and support: https://forum.arduino.cc/t/the-servo-library-not-fully-compatible-with-arduino-h7-yet-how-can-i-fix-this-issues/1220513

@ghiathkamel
Copy link
Author

ghiathkamel commented Feb 5, 2024

GPT4 told me:

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 Servo.cpp I got new errors.

@per1234 per1234 changed the title maybe the servo library not compatible with Arduino H7 yet, how can i fix this issues? Library not compatible with Portenta H7 Feb 5, 2024
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Feb 5, 2024
@per1234 per1234 changed the title Library not compatible with Portenta H7 Warnings when compiling library for Portenta H7 Feb 5, 2024
@per1234
Copy link
Contributor

per1234 commented Feb 5, 2024

Hi @ghiathkamel. Thanks for submitting this issue.

I got these errors when compiling the code

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.

@ghiathkamel
Copy link
Author

Hi @ghiathkamel. Thanks for submitting this issue.

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. .

Hi per1234
Thank you very much for your reply, much appreciated
i got the warning in red color not white color so i thought it's error :)
good to know that i can go and try the code even with these warnings msgs.
please can you help me out , on Arduino H7 How can i set the servo output to 12-bit 333Hz? for 12bit output i used AnalogWriteResolution (12), and it look working but for setting the output at 333hz AnalogWriteFrequency (333) not working cuz i got errors when verifying the code, so what i need to use to get 333hz, the servo library standard output is 8bit with 50hz only, can i edit the servo.h file to get 333hz output ? but how?

please let me know!
Thanks

@per1234
Copy link
Contributor

per1234 commented Feb 6, 2024

please can you help me out , on Arduino H7 How can i set the servo output to 12-bit 333Hz?

This is not an appropriate place to request assistance with your project. You are welcome to ask over on Arduino Forum. I'm sure we'll be able to help you out over there:

https://forum.arduino.cc/c/using-arduino/programming-questions/20

@ghiathkamel
Copy link
Author

ghiathkamel commented Feb 9, 2024

to get 333Hz output i changed the servo.h file to this REFRESH_INTERVAL 3000

#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo  
#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo 
#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
#define REFRESH_INTERVAL    3000     // minimum time to refresh servos in microseconds 
#define SERVOS_PER_TIMER       12     // the maximum number of servos controlled by one timer 
#define MAX_SERVOS   (_Nbr_16timers  * SERVOS_PER_TIMER)
#define INVALID_SERVO         255     // flag indicating an invalid servo index

after changing this, there is no warning messages anymore, i did not change servo.cpp file, i dont know if i need to but it works :), what do you think?

@razvanphp

This comment was marked as off-topic.

@arduino-libraries arduino-libraries locked as too heated and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants