Pārlūkot izejas kodu

added calibration progress bar

subDesTagesMitExtraKaese 3 gadi atpakaļ
vecāks
revīzija
ffce10a37d

+ 3 - 2
raspberry-pi/gui/Popup.py

@@ -1,4 +1,5 @@
 import tkinter as tk
+from tkinter.ttk import Progressbar
 import tkinter.messagebox
 import time
 import queue
@@ -15,7 +16,7 @@ class CalibrationPopUp(tk.Frame):
     self.instruction.pack(side="top", fill="both", expand=True)
     button = tk.Button(self,text="OK", command=self.calibration_state.next_state_gui, anchor="c",height=1,width=5)
     button.pack(side="top", fill="both", expand=True)
-    self.cs = tk.Label(self,text=self.calibration_state.state_clearname(), anchor="c")
+    self.cs = Progressbar(self, orient='horizontal', mode='determinate')
     self.cs.pack(side="top", fill="both", expand=True)
 
     root.bind('<Escape>', self.close)
@@ -24,7 +25,7 @@ class CalibrationPopUp(tk.Frame):
     if not self.root.winfo_exists():
       return
 
-    self.cs["text"] = self.calibration_state.state_clearname()
+    self.cs['value'] = self.calibration_state.progress
     if self.calibration_state.get_state() == self.calibration_state.WAITING_POS_1:
       self.instruction["text"] = "Move gondola to far left corner!"
     elif self.calibration_state.get_state() == self.calibration_state.WAITING_POS_2:

+ 2 - 2
raspberry-pi/gui/mainWindow.py

@@ -34,10 +34,10 @@ class MainWindow(tk.Frame):
     tk.Label(self.controls, textvariable=self.ac_dro_t1, anchor="nw").pack(side="top", fill="both", expand=False)
     tk.Label(self.controls, textvariable=self.ac_dro_t2, anchor="nw").pack(side="top", fill="both", expand=False)
 
-    calibrate_button = tk.Button(self.controls, text="Calibrate", command=self.calibrate, height=3)
+    calibrate_button = tk.Button(self.controls, text="Calibrate", command=self.calibrate, height=4)
     calibrate_button.pack(side="bottom", fill="both")
 
-    clear_button = tk.Button(self.controls, text="Clear graph", command=self.graph.clear)
+    clear_button = tk.Button(self.controls, text="Clear graph", command=self.graph.clear, height=4)
     clear_button.pack(side="bottom", fill="both")
 
   def update(self):

+ 2 - 0
raspberry-pi/sensors/acusticSensor.py

@@ -78,6 +78,7 @@ class AcusticSensor:
     if self.calibration_state.get_state() == self.calibration_state.ACCUMULATING_1:
       self.time_vals[0].append(value[0])
       self.time_vals[1].append(value[1])
+      self.calibration_state.progress = len(self.time_vals[0]) / 2
       if len(self.time_vals[0]) >= 100:
         self.cal_values["left"][0]  = statistics.mean(self.time_vals[0])
         self.cal_values["right"][1] = statistics.mean(self.time_vals[1])
@@ -87,6 +88,7 @@ class AcusticSensor:
     elif self.calibration_state.get_state() == self.calibration_state.ACCUMULATING_2:
       self.time_vals[0].append(value[0])
       self.time_vals[1].append(value[1])
+      self.calibration_state.progress = 50 + len(self.time_vals[0]) / 2
       if len(self.time_vals[0]) >= 100:
         self.cal_values["left"][1]  = statistics.mean(self.time_vals[0])
         self.cal_values["right"][0] = statistics.mean(self.time_vals[1])

+ 3 - 2
raspberry-pi/sensors/calibration.py

@@ -3,7 +3,7 @@ class CalibrationStateMashine():
 
   def __init__(self):
     self.state = 0
-    self.value_count = 0
+    self.progress = 0
 
     self.NOT_CALIBRATED = 0
     self.WAITING_POS_1  = 1
@@ -40,4 +40,5 @@ class CalibrationStateMashine():
     return self.state
 
   def reset_state(self):
-    self.state = 0
+    self.state = 0
+    self.progress = 0