Skip to content

Commit 68bf9ea

Browse files
bessmanCloudyPadmal
andcommitted
Fix echo length calculation
Co-authored-by: Padmal <[email protected]>
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

+1-1
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)