Browse Source

clear background for text overlaid on chart

Thomas Buck 1 year ago
parent
commit
5b89d34f09
3 changed files with 10 additions and 4 deletions
  1. 8
    2
      python-test/lcd.py
  2. 1
    1
      python-test/state_connect.py
  3. 1
    1
      python-test/state_wait_temp.py

+ 8
- 2
python-test/lcd.py View File

@@ -248,8 +248,14 @@ class LCD(framebuf.FrameBuffer):
248 248
             self.arc(int(x0), int(y0), int(w), int(w), c_circle, -90, int(v * 360) - 90)
249 249
         self.ring(int(x0), int(y0), int(w / 2), c_border)
250 250
 
251
-    def textC(self, s, x, y, c):
252
-        self.text(s, x - int(len(s) * 8 / 2), y - 5, c)
251
+    def textC(self, s, x, y, c, bgColor = None):
252
+        xStart = x - int(len(s) * 8 / 2)
253
+        yStart = y - 5
254
+
255
+        if bgColor != None:
256
+            self.rect(xStart, yStart - 1, len(s) * 8, 10, bgColor, True)
257
+
258
+        self.text(s, xStart, yStart, c)
253 259
 
254 260
     def textLine(self, s, c, off = 0):
255 261
         charsPerLine = int(self.width / 8)

+ 1
- 1
python-test/state_connect.py View File

@@ -77,6 +77,6 @@ class StateConnect:
77 77
                         self.lcd.textC("Connecting...", int(self.lcd.width / 2), int(self.lcd.height / 2), self.lcd.white)
78 78
                     else:
79 79
                         draw_graph(self.lcd, 0, int(self.iteration * 10), 10)
80
-                        self.lcd.textC("Fetching parameters...", int(self.lcd.width / 2), int(self.lcd.height / 2) - 10, self.lcd.white)
80
+                        self.lcd.textC("Fetching parameters...", int(self.lcd.width / 2), int(self.lcd.height / 2) - 10, self.lcd.white, self.lcd.black)
81 81
 
82 82
         return -1

+ 1
- 1
python-test/state_wait_temp.py View File

@@ -46,7 +46,7 @@ def draw_graph(lcd, min, val, max):
46 46
     ratio = (val - min) / (max - min)
47 47
     lcd.pie(lcd.width / 2, lcd.height / 2, lcd.width - 42, lcd.white, c, ratio)
48 48
 
49
-    lcd.textC("{} / {}".format(val, max), int(lcd.width / 2), int(lcd.height / 2), lcd.white)
49
+    lcd.textC("{} / {}".format(val, max), int(lcd.width / 2), int(lcd.height / 2), lcd.white, lcd.black)
50 50
 
51 51
 class StateWaitTemp:
52 52
     def __init__(self, lcd):

Loading…
Cancel
Save