Browse Source

Make distance measuring more accurate

master
Elis Axelsson 4 years ago
parent
commit
3e7d9bee4b
  1. 10
      code/table.py

10
code/table.py

@ -26,7 +26,15 @@ class Table:
Might return False if measuring error.
"""
distance = self.hcsr04.distance_cm()
distances = []
# Measure a bunch of times...
for x in range(0, 20):
distances.append(self.hcsr04.distance_cm())
# Take the longest distance, I've not seen any that is too far
distance = max(distances)
if distance > 0:
return distance

Loading…
Cancel
Save