Browse Source

Reverse some calculations to measure distance to the ceiling instead

of the floor
master
Elis Axelsson 5 years ago
parent
commit
f65f083347
  1. 14
      code/table.py

14
code/table.py

@ -68,21 +68,23 @@ class Table:
- Zero distances is stop
"""
# Calculate target height
targetHeight = self.currentHeight() + distance
# Calculate target height (Assuming we're measuring the distance
# to the ceiling)
targetHeight = self.currentHeight() - distance
# Default to not move in any direction
direction = 0
while True:
# Calculate how far to move
currentHeightDiff = targetHeight - self.currentHeight()
currentHeightDiff = (self.currentHeight() - targetHeight) * -1
# Calculate which direction to move in
# Calculate which direction to move in (Assuming that we're
# measuring the diff height to the ceiling)
if currentHeightDiff > 1:
direction = 1
elif currentHeightDiff < -1:
direction = -1
elif currentHeightDiff < -1:
direction = 1
else:
# Reset the relays
self.triggerRelay(0)

Loading…
Cancel
Save