Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tech
inf
public
realproject
Software Microzed Board
Python Scripts
test
Commits
f05baaff
Verified
Commit
f05baaff
authored
1 year ago
by
Moritz Lammerich
Browse files
Options
Downloads
Patches
Plain Diff
add VL53L0x ToF sensor test program
parent
7f457bc2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tofTest.py
+47
-0
47 additions, 0 deletions
tofTest.py
with
47 additions
and
0 deletions
tofTest.py
0 → 100644
+
47
−
0
View file @
f05baaff
#!/bin/python
import
argparse
from
vl53l0x_helper
import
init_vl53l0x
import
flink
__author__
=
"
Moritz Lammerich
"
__license__
=
"
http://www.apache.org/licenses/LICENSE-2.0
"
__version__
=
"
1.0
"
# set up and parse command line arguments
parser
=
argparse
.
ArgumentParser
(
prog
=
'
tof-test
'
,
description
=
'
Test utility for VL53L0x ToF sensors
'
)
parser
.
add_argument
(
'
-g
'
,
'
--gpios
'
,
nargs
=
'
+
'
,
type
=
int
,
dest
=
'
gpios
'
,
metavar
=
'
PIN
'
,
required
=
True
,
help
=
'
Flink GPIO channels to which the sensors
\'
\
XSHUT pin is connected, the number of sensors is inferred
\
from the number of GPIO channels
'
)
parser
.
add_argument
(
'
-o
'
,
'
--other
'
,
nargs
=
'
+
'
,
type
=
int
,
dest
=
'
other_pins
'
,
metavar
=
'
PIN
'
,
help
=
'
GPIO channels of sensors that are connected but not
\
under test. These will be set low to disable those sensors
\
so they don
\'
t interfere with the sensors under test.
\
GPIOs specified in -g -o will work the same as if only
\
specified in -g (i.e -o has no ill effect)
'
)
args
=
parser
.
parse_args
()
# set 'other' GPIOS low, so that sensors that aren't tested can be disabled
gpio
=
flink
.
FlinkGPIO
()
for
pin
in
args
.
other_pins
:
gpio
.
setDir
(
pin
,
True
)
gpio
.
setValue
(
pin
,
False
)
# initialize the ToF sensors
tofs
=
init_vl53l0x
(
args
.
gpios
)
# print measurements
for
_
in
range
(
1
,
11
):
line
=
"
"
.
join
([
"
% d
"
%
tof
.
get_distance
()
for
tof
in
tofs
])
print
(
"
distance %s
"
%
line
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment