ソースを参照

changed calibration Popup

w.mueller 3 年 前
コミット
3772009cd2

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

@@ -11,7 +11,7 @@ import logHandler
 
 
 class MainWindow(tk.Frame):
-  def __init__(self, root, ac_sensor, ac_queue, ac_cal_state):
+  def __init__(self, root, ac_sensor, ac_queue, ac_cal_state, conf):
     self.root = root
     self.popup = None
     self.log_window = None
@@ -19,6 +19,7 @@ class MainWindow(tk.Frame):
     self.ac_sensor = ac_sensor
     self.ac_queue = ac_queue
     self.log_handler = logHandler.get_log_handler()
+    self.conf = conf
 
     tk.Frame.__init__(self, root)
     # data plot at left side
@@ -116,7 +117,7 @@ class MainWindow(tk.Frame):
       self.pu_root.geometry(f'500x200+{int(x)}+{int(y)}')
       # deactivate mainWindow
       self.pu_root.grab_set()
-      self.popup = CalibrationPopUp(self.pu_root, self.ac_cal_state)
+      self.popup = CalibrationPopUp(self.pu_root, self.ac_cal_state, self.conf)
       self.popup.pack(side="top", fill="both", expand=True)
 
   def open_log(self):

+ 7 - 3
raspberry-pi/gui/popup.py

@@ -3,12 +3,14 @@ from tkinter.ttk import Progressbar
 import pyglet
 
 class CalibrationPopUp(tk.Frame):
-  def __init__(self, root, calibration_state):
+  def __init__(self, root, calibration_state, conf):
     self.root = root
     self.font = pyglet.font.add_file("gui/SourceSansPro-Semibold.otf")
     self.calibration_state = calibration_state
     tk.Frame.__init__(self, root)
     self.pendingClose = False
+    self.conf = conf
+
 
     self.instruction = tk.Label(self,text="Start Calibration", anchor="c",font=("SourceSansPro-Semibold", 18))
     self.instruction.pack(side="top", fill="both", expand=True)
@@ -26,9 +28,11 @@ class CalibrationPopUp(tk.Frame):
     self.cs['value'] = self.calibration_state.progress
     # read state from state machine
     if self.calibration_state.get_state() == self.calibration_state.WAITING_POS_1:
-      self.instruction["text"] = "Move gondola to left at calibration_y_offset!"
+      text = "Move gondola to [" + self.conf["ac_sensor"]["calibration_x_offset"] + " , " + self.conf["ac_sensor"]["calibration_y_offset_1"] + "]!"
+      self.instruction["text"] = text
     elif self.calibration_state.get_state() == self.calibration_state.WAITING_POS_2:
-      self.instruction["text"] = "Move gondola to right at calibration_y_offset!"
+      text = "Move gondola to [" + self.conf["ac_sensor"]["calibration_x_offset"] + " , " + self.conf["ac_sensor"]["calibration_y_offset_2"] + "]!"
+      self.instruction["text"] = text
     elif self.calibration_state.get_state() == self.calibration_state.CALIBRATION_DONE:
       self.instruction["text"] = "Calibration Done!"
       if not self.pendingClose:

+ 1 - 1
raspberry-pi/main.py

@@ -22,7 +22,7 @@ def main():
     root = tk.Tk()
     root.title("Tracking System")
     root.attributes('-fullscreen', True)
-    view = MainWindow(root, ac_sensor, ac_queue, ac_calibration_state)
+    view = MainWindow(root, ac_sensor, ac_queue, ac_calibration_state, conf)
     view.pack(side="top", fill="both", expand=True)
     view.update()
     root.mainloop()

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

@@ -67,10 +67,10 @@ class AcusticSensor:
       self.n += 0.02
 
       if self.calibration_state.get_state() == self.calibration_state.ACCUMULATING_1:
-        value = (1541+random.randint(-50,50),2076+random.randint(-50,50))
+        value = (750+random.randint(-50,50),750+random.randint(-50,50))
 
       elif self.calibration_state.get_state() == self.calibration_state.ACCUMULATING_2:
-        value = (2076+random.randint(-50,50),1541+random.randint(-50,50))
+        value = (1450+random.randint(-50,50),1450+random.randint(-50,50))
 
       self.calibrate(value)
       self.pass_to_gui(self.calculate_position(value) + value)