diff --git a/time_machine/machine.py b/time_machine/machine.py index efd746d5e8876b667a446e51261576333b533da6..e1aab8758b7e74a2800aa70711d99d8f394ca95d 100644 --- a/time_machine/machine.py +++ b/time_machine/machine.py @@ -107,9 +107,14 @@ def wait_btn(): return g.wait_for_edge(btn_pin, g.RISING, bouncetime=500) #g.wait_for_edge(btn_pin, g.RISING) +class Modes: + button = 0 + flask_raise = 1 + def main(): global state, pins last_time = 0 + mode = Modes.button while True: if state == States.no_hafv: print @@ -120,26 +125,36 @@ def main(): elif state == States.hafv_ready: print "Hafv redo" - lcd_info("Starta med knapp", last_time) - wait_btn() + if mode == Modes.button: + lcd_info("Starta med knapp", last_time) + wait_btn() + elif mode == Modes.flask_raise: + lcd_info("Starta med lyft", last_time) + wait_for_bottle_remove() + state = States.hafv_active start_time = time_ms() elif state == States.hafv_active: print "currently Hafving" lcd_info("Klockar", last_time) - if not bottle_check(pins): + + if mode == Mode.button and not bottle_check(pins): print "Early start" lcd_info("Tjuvstart!", last_time) wait_btn() state = States.no_hafv continue + print "Raise the bottle" - wait_for_bottle_remove() - print "BOTTLE RAISED" + + # TODO we actually don't need this, but it was + # here before so it stays until I refactor this. + if mode == Modes.button: + wait_for_bottle_remove() + print "BOTTLE RAISED" + print "Place back bottle after hafv" - wait_for_bottle_place() - print "BOTTLE PLACED" # Wait for bottle placed is in a loop because if the time # is under 1 secound then we want to wait again. This is