Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
card10
firmware
Commits
db117163
Verified
Commit
db117163
authored
5 years ago
by
koalo
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(bhi160): Toggle between sensors in app
parent
e260a6cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!163
Support for BHI160
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
preload/apps/bhi160/__init__.py
+19
-3
19 additions, 3 deletions
preload/apps/bhi160/__init__.py
preload/apps/bhi160/metadata.json
+1
-0
1 addition, 0 deletions
preload/apps/bhi160/metadata.json
with
20 additions
and
3 deletions
preload/apps/bhi160/__init__.py
+
19
−
3
View file @
db117163
import
bhi160
import
display
import
utime
import
buttons
disp
=
display
.
open
()
sensor
=
0
bhi
=
bhi160
.
BHI160Accelerometer
()
sensors
=
[
{
"
sensor
"
:
bhi160
.
BHI160Orientation
(),
"
name
"
:
"
Orientation
"
},
{
"
sensor
"
:
bhi160
.
BHI160Accelerometer
(),
"
name
"
:
"
Accelerometer
"
},
{
"
sensor
"
:
bhi160
.
BHI160Gyroscope
(),
"
name
"
:
"
Gyroscope
"
},
]
while
True
:
samples
=
bhi
.
read
()
# Read and print sample
samples
=
sensors
[
sensor
][
"
sensor
"
].
read
()
if
len
(
samples
)
>
0
:
disp
.
clear
()
sample
=
samples
[
0
]
...
...
@@ -20,11 +27,20 @@ while True:
elif
sample
.
status
==
3
:
color
=
[
0
,
200
,
0
]
disp
.
print
(
"
Accelerometer
"
,
posy
=
0
)
disp
.
print
(
sensors
[
sensor
][
"
name
"
]
,
posy
=
0
)
disp
.
print
(
"
X: %f
"
%
sample
.
x
,
posy
=
20
,
fg
=
color
)
disp
.
print
(
"
Y: %f
"
%
sample
.
y
,
posy
=
40
,
fg
=
color
)
disp
.
print
(
"
Z: %f
"
%
sample
.
z
,
posy
=
60
,
fg
=
color
)
disp
.
update
()
# Read button
v
=
buttons
.
read
(
buttons
.
BOTTOM_RIGHT
)
if
v
==
0
:
button_pressed
=
False
if
not
button_pressed
and
v
&
buttons
.
BOTTOM_RIGHT
!=
0
:
button_pressed
=
True
sensor
=
(
sensor
+
1
)
%
len
(
sensors
)
utime
.
sleep
(
0.1
)
This diff is collapsed.
Click to expand it.
preload/apps/bhi160/metadata.json
0 → 100644
+
1
−
0
View file @
db117163
{
"author"
:
"card10badge team"
,
"name"
:
"BHI160"
,
"description"
:
"Read BHI160 sensor data"
,
"category"
:
"Hardware"
,
"revision"
:
1
}
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