Move reset relay function to class

master
Elis Axelsson 5 years ago
parent ad57b92bca
commit 6025147226
  1. 10
      code/main.py
  2. 11
      code/table.py

@ -9,14 +9,6 @@ def getMovement():
return sensor.value()
def resetRelay():
relayUp = machine.Pin(pins.D5, mode=machine.Pin.OUT)
relayDown = machine.Pin(pins.D6, mode=machine.Pin.OUT)
relayUp.value(1)
relayDown.value(1)
def toggleRaiseUp():
relayUp = machine.Pin(pins.D5, mode=machine.Pin.OUT)
@ -30,8 +22,6 @@ def toggleLowerDown():
def goCrazy():
resetRelay()
while True:
print("Lowest Distance: " + str(getDistance()))
print("Movement: " + str(getMovement()))

@ -15,6 +15,9 @@ class Table:
self.relay_up = machine.Pin(pins.D5, mode=machine.Pin.OUT)
self.relay_down = machine.Pin(pins.D6, mode=machine.Pin.OUT)
# Reset both relays on set up
self.resetRelays()
def currentHeight(self):
"""
Get current height of the table in CM.
@ -27,3 +30,11 @@ class Table:
return distance
return False
def resetRelays(self):
"""
Reset the values of both up and down relays.
"""
self.relay_up.value(1)
self.relay_down.value(1)

Loading…
Cancel
Save