diff --git a/code/table.py b/code/table.py index 09281aa..dfef0a9 100644 --- a/code/table.py +++ b/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)