magneticSensor.py 416 B

12345678910111213141516171819202122
  1. from sensors.connection import globalArduinoSlave
  2. import time
  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()