File tree Expand file tree Collapse file tree 4 files changed +17
-14
lines changed
Expand file tree Collapse file tree 4 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 5454 readings, be sure the vacuum tape has been removed from the sensor.
5555"""
5656
57- import qwiic
57+ import qwiic_vl53l1x
5858import time
5959
6060print ("VL53L1X Qwiic Test\n " )
61- ToF = qwiic .QwiicVL53L1X ()
61+ ToF = qwiic_vl53l1x .QwiicVL53L1X ()
6262if (ToF .sensor_init () == None ): # Begin returns 0 on a good init
6363 print ("Sensor online!\n " )
6464
Original file line number Diff line number Diff line change 5555 be sure the vacuum tape has been removed from the sensor.
5656"""
5757
58- import qwiic
58+ import qwiic_vl53l1x
5959import time
6060
6161print ("VL53L1X Qwiic Test\n " )
62- ToF = qwiic .QwiicVL53L1X ()
62+ ToF = qwiic_vl53l1x .QwiicVL53L1X ()
6363
6464if (ToF .sensor_init () == None ): # Begin returns 0 on a good init
6565 print ("Sensor online!\n " )
Original file line number Diff line number Diff line change 5959 removed from the sensor.
6060"""
6161
62- import qwiic
63- import time , statistics
62+ import qwiic_vl53l1x
63+ import time
64+
65+ def mean (numbers ):
66+ return float (sum (numbers )) / max (len (numbers ), 1 )
6467
6568print ("VL53L1X Qwiic Test\n " )
66- ToF = qwiic .QwiicVL53L1X ()
69+ ToF = qwiic_vl53l1x .QwiicVL53L1X ()
6770
68- if (ToF .sensor_init () == None ): # Begin returns 0 on a good init
71+ if (ToF .sensor_init () == None ): # Begin returns 0 on a good init
6972 print ("Sensor online!\n " )
7073
7174ToF .set_distance_mode (1 ) # Sets Distance Mode Short (Long- Change value to 2)
7679 start = time .time ()
7780
7881 try :
79- ToF .start_ranging () # Write configuration bytes to initiate measurement
82+ ToF .start_ranging () # Write configuration bytes to initiate measurement
8083 time .sleep (.005 )
8184 distance .append (ToF .get_distance ()) # Get the result of the measurement from the sensor
8285 time .sleep (.005 )
9194 distanceFeet = distanceInches / 12.0
9295
9396 if len (distance ) < 10 :
94- avgdistance = statistics . mean (distance )
97+ avgdistance = mean (distance )
9598 else :
9699 distance .remove (distance [0 ])
97- avgdistance = statistics . mean (distance [len (distance )- 10 :len (distance )+ 1 ]) # Running average of last 10 measurements
100+ avgdistance = mean (distance [len (distance )- 10 :len (distance )+ 1 ]) # Running average of last 10 measurements
98101
99102 signalrate = ToF .get_signal_rate ()
100103 rangestatus = ToF .get_range_status ()
Original file line number Diff line number Diff line change 5555 readings, be sure the vacuum tape has been removed from the sensor.
5656"""
5757
58- import qwiic
58+ import qwiic_vl53l1x
5959import time
6060
6161print ("VL53L1X Qwiic Test\n " )
62- ToF = qwiic .QwiicVL53L1X ()
62+ ToF = qwiic_vl53l1x .QwiicVL53L1X ()
6363
6464if (ToF .sensor_init () == None ): # Begin returns 0 on a good init
6565 print ("Sensor online!\n " )
6666
6767ToF .set_inter_measurement_in_ms (40 )
6868
69- print ("Inter Measurement Period (ms): %s \n " , ToF .get_inter_measurement_in_ms ())
69+ print ("Inter Measurement Period (ms):" , ToF .get_inter_measurement_in_ms ())
7070
7171while True :
7272 try :
You can’t perform that action at this time.
0 commit comments