import queue import time from sensors.calibration import CalibrationStateMashine from sensors.connection import globalArduinoSlave import logHandler conn = globalArduinoSlave() class MagneticSensor: def __init__(self, conf): self.conf = conf self.queue = queue.Queue() self.calibration_state = CalibrationStateMashine() self.log_handler = logHandler.get_log_handler() # neu self.field_height = float(conf["field"]["y"]) self.field_width = float(conf["field"]["x"]) self.n = 0 #pass def start(self): if not conn.isConnected(): conn.open() conn.addRecvCallback(self._readCb) def _readCb(self, raw): print("mag: ", conn.getMagneticField()) def calibrate(self, x, y): pass def read(self): return conn.getMagneticField() def stop(self): # neu self.log_handler.log_and_print("stop magnetic sensor") conn.close