Sfoglia il codice sorgente

added calibrate and calculate position function

w.mueller 3 anni fa
parent
commit
fbf05f78b4
1 ha cambiato i file con 21 aggiunte e 1 eliminazioni
  1. 21 1
      raspberry-pi/main.py

+ 21 - 1
raspberry-pi/main.py

@@ -1,3 +1,23 @@
-from sensors import *
+import sensors
+import time
+
+distance = 450 #in mm
+
+def main():
+    ac_sensor = sensors.AcusticSensor()
+    ac_sensor.start()
+    ac_sensor.calibrate(distance)
+    try:
+        while True:
+            x,y = ac_sensor.calculate_position()
+            print(x,y)
+            time.sleep(2)
+    except KeyboardInterrupt:
+        print("exit")
+    except Exception as e:
+        print("Error: ",e)
+
+main()
+