Remove resetRelays() function and add move() function that can move

up, down or reset
master
Elis Axelsson 5 years ago
parent 6025147226
commit 7ef5553f23
  1. 20
      code/table.py

@ -16,7 +16,7 @@ class Table:
self.relay_down = machine.Pin(pins.D6, mode=machine.Pin.OUT)
# Reset both relays on set up
self.resetRelays()
self.move(0)
def currentHeight(self):
"""
@ -31,10 +31,20 @@ class Table:
return False
def resetRelays(self):
def move(self, direction):
"""
Reset the values of both up and down relays.
Direction should be an integer:
- 1 to move up
- 0 to stop movement
- -1 to move down
"""
self.relay_up.value(1)
self.relay_down.value(1)
if direction == 1:
self.relay_down.value(0)
self.relay_up.value(1)
elif direction == -1:
self.relay_down.value(1)
self.relay_up.value(0)
else:
self.relay_up.value(1)
self.relay_down.value(1)

Loading…
Cancel
Save