-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[pulse_counter] Fix volatile increment/decrement deprecation warnings #7954
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes warnings about deprecated use of ++ and -- operators on volatile-qualified types in the pulse counter component. Replaces volatile variables with proper interrupt-safe access using ESPHome's InterruptLock. The warnings being fixed are: ```log src/esphome/components/pulse_counter/pulse_counter_sensor.cpp:32:12: warning: '++' expression of 'volatile'-qualified type is deprecated [-Wvolatile] src/esphome/components/pulse_counter/pulse_counter_sensor.cpp:35:12: warning: '--' expression of 'volatile'-qualified type is deprecated [-Wvolatile] ``` Changes: - Removed volatile qualifier from counter and last_pulse variables - Added InterruptLock protection around critical sections - Changed increment/decrement operators to += 1 and -= 1 - Split critical sections to minimize interrupt disable time This change maintains the same functionality while providing proper interrupt safety across all supported platforms (ESP8266, ESP32 variants, and RP2040).
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #7954 +/- ##
==========================================
+ Coverage 53.70% 53.83% +0.12%
==========================================
Files 50 50
Lines 9408 9820 +412
Branches 1654 1353 -301
==========================================
+ Hits 5053 5287 +234
- Misses 4056 4207 +151
- Partials 299 326 +27 ☔ View full report in Codecov by Sentry. |
edwardtfn
added a commit
to edwardtfn/esphome
that referenced
this pull request
Dec 13, 2024
Similar to the [pulse counter fix](esphome#7954), this PR addresses warnings about deprecated use of volatile-qualified variables in the rotary encoder component. Replaces the volatile counter with proper interrupt-safe access using ESPHome's InterruptLock. The main issue is the volatile counter in RotaryEncoderSensorStore that's modified in interrupt context. This change provides proper synchronization while maintaining the same functionality across all supported platforms. Changes: - Removed volatile qualifier from counter in RotaryEncoderSensorStore - Added InterruptLock protection around counter modifications in ISR - Counter is already properly protected with InterruptLock in the main loop - Changed increment/decrement operations to += 1 and -= 1 This ensures proper interrupt safety while fixing the volatile deprecation warnings. The change is compatible with all ESPHome supported platforms (ESP8266, ESP32 variants, and RP2040). This is a similar change to esphome#7954 (pulse counter fix) but for the rotary encoder component.
14 tasks
clydebarrow
approved these changes
Dec 13, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
Fixes warnings about deprecated use of ++ and -- operators on volatile-qualified types in the pulse counter component. Replaces volatile variables with proper interrupt-safe access using ESPHome's InterruptLock.
The warnings being fixed are:
Changes:
This change maintains the same functionality.
Types of changes
Related issue or feature (if applicable):
BETA
Warning on deprecated expression onpulse_counter
issues#6544Pull request in esphome-docs with documentation (if applicable): N/A
Test Environment
Example entry for
config.yaml
: N/AChecklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: