Parcourir la source

added calibrate and calculate position function

w.mueller il y a 3 ans
Parent
commit
fbf05f78b4
1 fichiers modifiés avec 21 ajouts et 1 suppressions
  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()
+