-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
machine: Add wait_opposite param to time_pulse_us func. #16160
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?
machine: Add wait_opposite param to time_pulse_us func. #16160
Conversation
Code size report:
|
7a9b45d
to
f59833b
Compare
Thanks for mentioning me. I considered creating that feature, but as optional argument to time_pulse_us() instead of a new method. That looks like a smaller change, even if the additional code size might be the same.. |
f59833b
to
e29b760
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #16160 +/- ##
==========================================
- Coverage 98.54% 98.53% -0.01%
==========================================
Files 169 169
Lines 21877 21882 +5
==========================================
+ Hits 21558 21561 +3
- Misses 319 321 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f25ae18
to
b9d6cf0
Compare
b9d6cf0
to
aa1cba8
Compare
90f267b
to
28906bc
Compare
dd7b953
to
b6bcf72
Compare
Remove additionnal synchronization time_pulse_us() from tests/extmod_hardware/machine_pwm.py |
b6bcf72
to
e2a1c3a
Compare
If the pin is initially equal to *pulse_level* then first waits until the pin input becomes different from *pulse_level*. Then the function waits until the pin input becomes equal to *pulse_level*, then the func counts the duration that the pin is equal to *pulse_level*. Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com> Co-Authored-By: Robert Hammelrath <12476868+robert-hh@users.noreply.github.com>
e2a1c3a
to
27486f2
Compare
time_pulse_us(pin, pulse_level, timeout_us=1000000, wait_opposite=false, /)
If
wait_opposite
is true, if the pin is initially equal to pulse_level then firstwaits until the pin input becomes different from pulse_level.
Then if the current input value of the pin is different to pulse_level,
the function first waits until the pin input becomes equal to pulse_level,
then times the duration that the pin is equal to pulse_level.
The advantage is that there is no need for additional synchronization before measuring the pulse duration.
A little bit longer, but with higher accuracy.
The jitter of the pulse measurement process is about 5-15 μs on the ESP32 board.
Idia from @robert-hh #16147 (comment)
This function is used in DRAFT PR for tests
PWM from 10845 and time_hardware_pulse_us() and test from 16147. #16161
The tests results show the functionality of the function over the entire ESP32 PWM frequency range from 1Hz to 40MHz.