Thomas Buck 1 anno fa
parent
commit
3db027bc17

+ 3
- 0
python-test/lcd.py Vedi File

@@ -243,3 +243,6 @@ class LCD(framebuf.FrameBuffer):
243 243
         if v > 0.0:
244 244
             self.arc(int(x0), int(y0), int(w), int(w), c_circle, -90, int(v * 360) - 90)
245 245
         self.ring(int(x0), int(y0), int(w / 2), c_border)
246
+
247
+    def textC(self, s, x, y, c):
248
+        self.text(s, x - int(len(s) * 8 / 2), y - 5, c)

+ 3
- 3
python-test/state_connect.py Vedi File

@@ -66,12 +66,12 @@ class StateConnect:
66 66
                     return 0
67 67
             else:
68 68
                 if self.state == False:
69
-                    self.lcd.text("Disconnecting...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
69
+                    self.lcd.textC("Disconnecting...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
70 70
                 else:
71 71
                     if self.step == False:
72
-                        self.lcd.text("Connecting...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
72
+                        self.lcd.textC("Connecting...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
73 73
                     else:
74 74
                         self.lcd.pie(self.lcd.width / 2, self.lcd.height / 2, self.lcd.width - 30, self.lcd.red, self.lcd.green, self.iteration)
75
-                        self.lcd.text("Fetching parameters...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
75
+                        self.lcd.textC("Fetching parameters...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
76 76
 
77 77
         return -1

+ 3
- 3
python-test/state_heat.py Vedi File

@@ -66,10 +66,10 @@ class StateHeat:
66 66
             else:
67 67
                 if self.state == False:
68 68
                     if self.state == False:
69
-                        self.lcd.text("Turning heater off...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
69
+                        self.lcd.textC("Turning heater off...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
70 70
                     else:
71
-                        self.lcd.text("Resetting temperature...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
71
+                        self.lcd.textC("Resetting temperature...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
72 72
                 else:
73
-                    self.lcd.text("Turning heater on...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
73
+                    self.lcd.textC("Turning heater on...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
74 74
 
75 75
         return -1

+ 2
- 2
python-test/state_pump.py Vedi File

@@ -57,9 +57,9 @@ class StatePump:
57 57
                 if now - self.start <= self.duration:
58 58
                     draw_graph(self.lcd, 0.0, now - self.start, self.duration)
59 59
                 else:
60
-                    self.lcd.text("Turning off pump...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
60
+                    self.lcd.textC("Turning off pump...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
61 61
             else:
62
-                self.lcd.text("Turning on pump...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
62
+                self.lcd.textC("Turning on pump...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
63 63
 
64 64
             if self.done:
65 65
                 if self.value[2] >= (len(workflow["steps"]) - 1):

+ 3
- 3
python-test/state_wait_temp.py Vedi File

@@ -5,13 +5,13 @@ from poll import set_target_temp, get_current_temp
5 5
 
6 6
 def draw_graph(lcd, min, val, max):
7 7
     if max == min:
8
-        lcd.text("{} -> {} -> {}".format(min, val, max), 0, int(lcd.height / 2) - 5, lcd.white)
8
+        lcd.textC("{} -> {} -> {}".format(min, val, max), int(self.lcd.width / 2), int(lcd.height / 2), lcd.white)
9 9
         return
10 10
 
11 11
     ratio = (val - min) / (max - min)
12 12
     lcd.pie(lcd.width / 2, lcd.height / 2, lcd.width - 30, lcd.red, lcd.green, ratio)
13 13
 
14
-    lcd.text("{} / {}".format(val, max), int(lcd.width / 2), int(lcd.height / 2) - 5, lcd.white)
14
+    lcd.textC("{} / {}".format(val, max), int(lcd.width / 2), int(lcd.height / 2), lcd.white)
15 15
 
16 16
 class StateWaitTemp:
17 17
     def __init__(self, lcd):
@@ -64,7 +64,7 @@ class StateWaitTemp:
64 64
 
65 65
         async with self.lock:
66 66
             if self.temp == 0.0:
67
-                self.lcd.text("Setting temperature...", 0, int(self.lcd.height / 2) - 5, self.lcd.white)
67
+                self.lcd.textC("Setting temperature...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
68 68
             else:
69 69
                 draw_graph(self.lcd, self.min, self.temp, self.max)
70 70
 

Loading…
Annulla
Salva