Ver código fonte

update gui when there are no values

subDesTagesMitExtraKaese 3 anos atrás
pai
commit
8b46a6ac61
2 arquivos alterados com 23 adições e 23 exclusões
  1. 6 5
      raspberry-pi/gui/graph.py
  2. 17 18
      raspberry-pi/gui/mainWindow.py

+ 6 - 5
raspberry-pi/gui/graph.py

@@ -68,12 +68,13 @@ class Graph(tk.Canvas):
       for point in data[i]:
         coord[i].append(self.pointToCoord(point))
 
-    self.lastPoints = [line[-1] for line in data]
-    #fade out old lines by mixing with background
     self.canvas = Image.blend(self.canvas, self.bg, 1/100)
-    draw = ImageDraw.Draw(self.canvas)
-    for i in range(len(coord)):
-      draw.line(coord[i], fill=self.colors[i], width=self.lineWidth+2, joint='curve')
+    if len(data[0]) > 0:
+      self.lastPoints = [line[-1] for line in data]
+      #fade out old lines by mixing with background
+      draw = ImageDraw.Draw(self.canvas)
+      for i in range(len(coord)):
+        draw.line(coord[i], fill=self.colors[i], width=self.lineWidth+2, joint='curve')
 
     # draw to tk.Canvas
     self.photo = ImageTk.PhotoImage(self.canvas)

+ 17 - 18
raspberry-pi/gui/mainWindow.py

@@ -59,25 +59,24 @@ class MainWindow(tk.Frame):
         self.ac_dro_val_count += 1
     
     # graph shows all values as a line
-    if len(ac_positions) > 0:
-      self.graph.update([ac_positions])
-
-      # readouts will only be updated so often
-      if self.controlsUpdateTime + 0.4 < time.time():
-        self.controlsUpdateTime = time.time()
-        # they display the average of all values
-        if self.ac_dro_val_count > 0:
-          self.ac_dro_val_sums /= self.ac_dro_val_count
-        else:
-          self.ac_dro_val_sums.fill(0)
-
-        self.ac_dro_x.set("X: {:.1f} mm".format(self.ac_dro_val_sums[0]))
-        self.ac_dro_y.set("Y: {:.1f} mm".format(self.ac_dro_val_sums[1]))
-        self.ac_dro_t1.set("t1: {:.3f} ms".format(self.ac_dro_val_sums[2]/1000))
-        self.ac_dro_t2.set("t2: {:.3f} ms".format(self.ac_dro_val_sums[3]/1000))
-
+    self.graph.update([ac_positions])
+
+    # readouts will only be updated so often
+    if self.controlsUpdateTime + 0.4 < time.time():
+      self.controlsUpdateTime = time.time()
+      # they display the average of all values
+      if self.ac_dro_val_count > 0:
+        self.ac_dro_val_sums /= self.ac_dro_val_count
+      else:
         self.ac_dro_val_sums.fill(0)
-        self.ac_dro_val_count = 0
+
+      self.ac_dro_x.set("X: {:.1f} mm".format(self.ac_dro_val_sums[0]))
+      self.ac_dro_y.set("Y: {:.1f} mm".format(self.ac_dro_val_sums[1]))
+      self.ac_dro_t1.set("t1: {:.3f} ms".format(self.ac_dro_val_sums[2]/1000))
+      self.ac_dro_t2.set("t2: {:.3f} ms".format(self.ac_dro_val_sums[3]/1000))
+
+      self.ac_dro_val_sums.fill(0)
+      self.ac_dro_val_count = 0
 
     if self.popup:
       self.popup.update()