Thomas Buck пре 1 година
родитељ
комит
bab56a5efa
1 измењених фајлова са 16 додато и 12 уклоњено
  1. 16
    12
      python-test/states.py

+ 16
- 12
python-test/states.py Прегледај датотеку

@@ -1,15 +1,6 @@
1 1
 #!/usr/bin/env python
2 2
 
3 3
 import uasyncio as asyncio
4
-from lcd import LCD
5
-from state_scan import StateScan
6
-from state_connect import StateConnect
7
-from state_select import StateSelect
8
-from state_heat import StateHeat
9
-from state_wait_temp import StateWaitTemp
10
-from state_wait_time import StateWaitTime
11
-from state_pump import StatePump
12
-from state_notify import StateNotify
13 4
 
14 5
 class States:
15 6
     def __init__(self, lcd):
@@ -38,25 +29,30 @@ class States:
38 29
             self.current = next
39 30
             self.states[self.current].enter(val)
40 31
 
41
-if True:#__name__ == "__main__":
42
-    lcd = LCD()
43
-    lcd.brightness(1.0)
32
+from lcd import LCD
33
+lcd = LCD()
34
+lcd.brightness(1.0)
44 35
 
36
+try:
45 37
     states = States(lcd)
46 38
 
47 39
     # 0 - Scan
40
+    from state_scan import StateScan
48 41
     scan = StateScan(lcd)
49 42
     states.add(scan)
50 43
 
51 44
     # 1 - Connect
45
+    from state_connect import StateConnect
52 46
     conn = StateConnect(lcd, True)
53 47
     states.add(conn)
54 48
 
55 49
     # 2 - Select
50
+    from state_select import StateSelect
56 51
     select = StateSelect(lcd)
57 52
     states.add(select)
58 53
 
59 54
     # 3 - Heater On
55
+    from state_heat import StateHeat
60 56
     heatOn = StateHeat(lcd, True)
61 57
     states.add(heatOn)
62 58
 
@@ -69,20 +65,28 @@ if True:#__name__ == "__main__":
69 65
     states.add(disconn)
70 66
 
71 67
     # 6 - Wait for temperature
68
+    from state_wait_temp import StateWaitTemp
72 69
     waitTemp = StateWaitTemp(lcd)
73 70
     states.add(waitTemp)
74 71
 
75 72
     # 7 - Wait for time
73
+    from state_wait_time import StateWaitTime
76 74
     waitTime = StateWaitTime(lcd)
77 75
     states.add(waitTime)
78 76
 
79 77
     # 8 - Pump
78
+    from state_pump import StatePump
80 79
     pump = StatePump(lcd)
81 80
     states.add(pump)
82 81
 
83 82
     # 9 - Notify
83
+    from state_notify import StateNotify
84 84
     notify = StateNotify(lcd)
85 85
     states.add(notify)
86 86
 
87 87
     while True:
88 88
         states.run()
89
+except Exception as e:
90
+    lcd.fill(self.lcd.black)
91
+    lcd.text(str(e), 0, int(lcd.height / 2) - 5, lcd.white)
92
+    lcd.show()

Loading…
Откажи
Сачувај