Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix mbed not using REFRESH_INTERVAL #132

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

Open
razvanphp wants to merge 1 commit into arduino-libraries:master
base: master
Choose a base branch
Loading
from vampirebyte:master

Conversation

Copy link

@razvanphp razvanphp commented Sep 18, 2024
edited
Loading

This pull request refactors the Servo library for mbed-based boards to utilize std::chrono durations instead of manual conversions with floating-point numbers. The 20ms interval was hardcoded for mbed platform only.

Changes:

  • Fix bug on mbed platform of not using REFRESH_INTERVAL at all
  • Modified ServoImpl::start() and ServoImpl::call() to use std::chrono::microseconds.
  • Eliminated floating-point divisions by 0.02f (hardcoded) and 1e6.
  • Ensured backward compatibility by keeping existing functionality intact.

Benefits:

  • Enhanced type safety and precision.
  • Simplified codebase and aligned with other platforms.
  • Facilitates dynamic adjustment of REFRESH_INTERVAL.

Testing:

  • Verified functionality with default REFRESH_INTERVAL of 20000 microseconds.
  • Tested with REFRESH_INTERVAL set to 10000 and 5000 microseconds.
  • Confirmed correct servo operation and signal timing using an oscilloscope.

Notes:

This change aligns the Servo library with the updated mbed OS API that favours std::chrono durations since mbedOS 6.0.0, see

https://github.com/arduino/ArduinoCore-mbed/blob/702daa02e244fb8710b48599f38786a67c590699/cores/arduino/mbed/drivers/include/drivers/Ticker.h#L85-L122

Also do not use deprecated float as parameter, switch to chrono duration
Copy link

Memory usage change @ fab0609

Board flash % RAM for global variables %
arduino:avr:leonardo 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:avr:mega 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:avr:nano 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nano33ble 💚 -448 - -448 -0.05 - -0.05 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 💚 -1868 - -1868 -0.01 - -0.01 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:mbed_portenta:envie_m7:target_core=cm4 N/A N/A N/A N/A
arduino:megaavr:nona4809 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:sam:arduino_due_x_dbg 0 - 0 0.0 - 0.0 N/A N/A
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/Knob
flash
% examples/Knob
RAM for global variables
% examples/Sweep
flash
% examples/Sweep
RAM for global variables
%
arduino:avr:leonardo 0 0.0 0 0.0 0 0.0 0 0.0
arduino:avr:mega 0 0.0 0 0.0 0 0.0 0 0.0
arduino:avr:nano 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nano:nano33ble -448 -0.05 0 0.0 -448 -0.05 0 0.0
arduino:mbed_nano:nanorp2040connect -1868 -0.01 0 0.0 -1868 -0.01 0 0.0
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A N/A N/A N/A N/A
arduino:mbed_portenta:envie_m7:target_core=cm4 N/A N/A N/A N/A N/A N/A N/A N/A
arduino:megaavr:nona4809 0 0.0 0 0.0 0 0.0 0 0.0
arduino:sam:arduino_due_x_dbg 0 0.0 N/A N/A 0 0.0 N/A N/A
arduino:samd:mkrzero 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/Knob<br>flash,%,examples/Knob<br>RAM for global variables,%,examples/Sweep<br>flash,%,examples/Sweep<br>RAM for global variables,%
arduino:avr:leonardo,0,0.0,0,0.0,0,0.0,0,0.0
arduino:avr:mega,0,0.0,0,0.0,0,0.0,0,0.0
arduino:avr:nano,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nano33ble,-448,-0.05,0,0.0,-448,-0.05,0,0.0
arduino:mbed_nano:nanorp2040connect,-1868,-0.01,0,0.0,-1868,-0.01,0,0.0
arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:mbed_portenta:envie_m7:target_core=cm4,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:megaavr:nona4809,0,0.0,0,0.0,0,0.0,0,0.0
arduino:sam:arduino_due_x_dbg,0,0.0,N/A,N/A,0,0.0,N/A,N/A
arduino:samd:mkrzero,0,0.0,0,0.0,0,0.0,0,0.0

Copy link

CLAassistant commented Sep 18, 2024
edited
Loading

CLA assistant check
All committers have signed the CLA.

@per1234 per1234 linked an issue Sep 18, 2024 that may be closed by this pull request
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Sep 18, 2024

This comment was marked as duplicate.

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

Successfully merging this pull request may close these issues.

Warnings when compiling library for Portenta H7

AltStyle によって変換されたページ (->オリジナル) /