|
@@ -4,8 +4,17 @@ import uasyncio as asyncio
|
4
|
4
|
from poll import set_target_temp, get_current_temp
|
5
|
5
|
|
6
|
6
|
def draw_graph(lcd, min, val, max):
|
7
|
|
- # TODO
|
8
|
|
- lcd.text("{} -> {} -> {}".format(min, val, max), 0, 100, lcd.white)
|
|
7
|
+ if max == min:
|
|
8
|
+ lcd.text("{} -> {} -> {}".format(min, val, max), 0, 100, lcd.white)
|
|
9
|
+ return
|
|
10
|
+
|
|
11
|
+ w = lcd.width - 10
|
|
12
|
+ ratio = (val - min) / (max - min)
|
|
13
|
+ wfull = int(w * ratio)
|
|
14
|
+ wempty = w - wfull
|
|
15
|
+ lcd.rect(4, 100, wfull + 1, 50, lcd.green, True)
|
|
16
|
+ lcd.rect(4 + wfull, 100, wempty + 2, 50, lcd.green, False)
|
|
17
|
+ lcd.text("{}".format(val), int(lcd.width / 2), 125, lcd.white)
|
9
|
18
|
|
10
|
19
|
class StateWaitTemp:
|
11
|
20
|
def __init__(self, lcd):
|
|
@@ -64,7 +73,11 @@ class StateWaitTemp:
|
64
|
73
|
return 4 # heat off
|
65
|
74
|
|
66
|
75
|
async with self.lock:
|
67
|
|
- draw_graph(self.lcd, self.min, self.temp, self.max)
|
|
76
|
+ if self.temp == 0.0:
|
|
77
|
+ self.lcd.text("Setting temperature...", 0, 100, self.lcd.white)
|
|
78
|
+ else:
|
|
79
|
+ draw_graph(self.lcd, self.min, self.temp, self.max)
|
|
80
|
+
|
68
|
81
|
if self.temp >= self.max:
|
69
|
82
|
print("switch, {} >= {}".format(self.temp, self.max))
|
70
|
83
|
return 7 # wait for time
|