Skip to content

Commit 68bf9ea

Browse files
bessmanCloudyPadmal
andcommitted
Fix echo length calculation
Co-authored-by: Padmal <CloudyPadmal@users.noreply.github.com>
1 parent 0813879 commit 68bf9ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pslab/external/hcsr04.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def estimate_distance(
108108
self._pwm.set_state(**{self._trig.lower(): 0})
109109
(t,) = self._la.fetch_data()
110110
self._sanity_check(len(t), 2 * average)
111-
high_times = t[::2] - t[1::2]
111+
high_times = t[1::2] - t[::2]
112112
return speed_of_sound * high_times.mean() / 2 * 1e-6
113113

114114
def _sanity_check(self, events: int, expected_events: int):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy