magneticSensor.py 418 B

123456789101112131415161718192021222324
  1. import time
  2. from sensors.connection import globalArduinoSlave
  3. conn = globalArduinoSlave()
  4. class MagneticSensor:
  5. def __init__(self):
  6. pass
  7. def start(self):
  8. if not conn.isConnected():
  9. conn.open()
  10. conn.addRecvCallback(self._readCb)
  11. def _readCb(self, raw):
  12. print("mag: ", conn.getMagneticField())
  13. def calibrate(self, x, y):
  14. pass
  15. def read(self):
  16. return conn.getMagneticField()