-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix(ledc): Allow setting AnalogWrite frequency and resolution before calling analogWrite #11756
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
base: master
Are you sure you want to change the base?
Conversation
👋 Hello P-R-O-C-H-Y, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
82b13e5
to
bd405d2
Compare
Test Results 76 files 76 suites 13m 10s ⏱️ Results for commit bd405d2. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the behavior of analogWriteFrequency
and analogWriteResolution
functions to allow setting frequency and resolution parameters before calling analogWrite
. Previously, these functions would fail if called before the pin was attached to the LEDC bus.
- Added pin attachment checks to both functions before attempting to change pin-specific settings
- Functions now fall back to updating global settings when pin is not yet attached
- Eliminates error messages when configuring frequency/resolution before analogWrite
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Description of Change
This pull request improves the behavior of
analogWriteFrequency
andanalogWriteResolution
functions in theesp32-hal-ledc.c
file. The changes ensure that when a pin is not yet attached to the LEDC bus, frequency and resolution updates are applied to the global settings that are later used when callinganalogWrite
.Improvements to pin-specific configuration:
analogWriteFrequency
to check if the pin is attached to the LEDC bus and apply the frequency change to the pin, falling back to updating the global frequency if not attached.analogWriteResolution
to check if the pin is attached to the LEDC bus and apply the resolution change to the pin, falling back to updating the global resolution if not attached.Test Scenarios
Tested using simple sketch on ESP32.
Before:
After:
Related links
Closes #11670