Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fleur
firmware
Commits
e260a6cb
Verified
Commit
e260a6cb
authored
Aug 22, 2019
by
koalo
Committed by
Rahix
Aug 22, 2019
Browse files
feat(bhi160): Forward status
parent
1aaffea6
Changes
5
Hide whitespace changes
Inline
Side-by-side
epicardium/epicardium.h
View file @
e260a6cb
...
...
@@ -968,6 +968,8 @@ struct bhi160_data_vector {
int16_t
y
;
/** Z */
int16_t
z
;
/** Status */
uint8_t
status
;
};
/**
...
...
epicardium/modules/bhi.c
View file @
e260a6cb
...
...
@@ -304,6 +304,7 @@ bhi160_handle_packet(bhy_data_type_t data_type, bhy_data_generic_t *sensor_data)
data_vector
.
x
=
sensor_data
->
data_vector
.
x
;
data_vector
.
y
=
sensor_data
->
data_vector
.
y
;
data_vector
.
z
=
sensor_data
->
data_vector
.
z
;
data_vector
.
status
=
sensor_data
->
data_vector
.
status
;
xQueueSend
(
bhi160_streams
[
sensor_type
].
queue
,
&
data_vector
,
...
...
preload/apps/bhi160/__init__.py
View file @
e260a6cb
...
...
@@ -12,10 +12,18 @@ while True:
disp
.
clear
()
sample
=
samples
[
0
]
color
=
[
255
,
0
,
0
]
if
sample
.
status
==
1
:
color
=
[
255
,
128
,
0
]
elif
sample
.
status
==
2
:
color
=
[
255
,
255
,
0
]
elif
sample
.
status
==
3
:
color
=
[
0
,
200
,
0
]
disp
.
print
(
"Accelerometer"
,
posy
=
0
)
disp
.
print
(
"X: %f"
%
sample
[
"x"
]
,
posy
=
20
)
disp
.
print
(
"Y: %f"
%
sample
[
"y"
]
,
posy
=
40
)
disp
.
print
(
"Z: %f"
%
sample
[
"z"
]
,
posy
=
60
)
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
()
...
...
pycardium/modules/bhi160-sys.c
View file @
e260a6cb
...
...
@@ -38,11 +38,12 @@ STATIC mp_obj_t mp_bhi160_read_sensor(mp_obj_t stream_id_in)
// other data types are currently not supported
mp_raise_OSError
(
EINVAL
);
}
mp_obj_t
tuple
[
3
];
mp_obj_t
tuple
[
4
];
tuple
[
0
]
=
mp_obj_new_int
(
buf
[
i
].
x
);
tuple
[
1
]
=
mp_obj_new_int
(
buf
[
i
].
y
);
tuple
[
2
]
=
mp_obj_new_int
(
buf
[
i
].
z
);
mp_obj_list_append
(
list
,
mp_obj_new_tuple
(
3
,
tuple
));
tuple
[
3
]
=
mp_obj_new_int
(
buf
[
i
].
status
);
mp_obj_list_append
(
list
,
mp_obj_new_tuple
(
4
,
tuple
));
}
return
MP_OBJ_FROM_PTR
(
list
);
...
...
pycardium/modules/py/bhi160.py
View file @
e260a6cb
import
sys_bhi160
import
interrupt
import
ucollections
DataVector
=
ucollections
.
namedtuple
(
"DataVector"
,
[
"x"
,
"y"
,
"z"
,
"status"
])
class
BHI160
:
...
...
@@ -49,6 +52,14 @@ class BHI160:
if
self
.
_callback
:
self
.
_callback
(
data
)
def
convert_data_vector
(
self
,
sample
):
return
DataVector
(
self
.
convert_single
(
sample
[
0
]),
self
.
convert_single
(
sample
[
1
]),
self
.
convert_single
(
sample
[
2
]),
sample
[
3
],
)
class
BHI160Accelerometer
(
BHI160
):
def
__init__
(
...
...
@@ -67,13 +78,7 @@ class BHI160Accelerometer(BHI160):
return
2
*
value
/
32768.0
def
convert
(
self
,
sample
):
return
dict
(
{
"x"
:
self
.
convert_single
(
sample
[
0
]),
"y"
:
self
.
convert_single
(
sample
[
1
]),
"z"
:
self
.
convert_single
(
sample
[
2
]),
}
)
return
self
.
convert_data_vector
(
sample
)
class
BHI160Gyroscope
(
BHI160
):
...
...
@@ -93,13 +98,7 @@ class BHI160Gyroscope(BHI160):
return
360
*
value
/
32768.0
def
convert
(
self
,
sample
):
return
dict
(
{
"x"
:
self
.
convert_single
(
sample
[
0
]),
"y"
:
self
.
convert_single
(
sample
[
1
]),
"z"
:
self
.
convert_single
(
sample
[
2
]),
}
)
return
self
.
convert_data_vector
(
sample
)
class
BHI160Orientation
(
BHI160
):
...
...
@@ -119,10 +118,4 @@ class BHI160Orientation(BHI160):
return
360
*
value
/
32768.0
def
convert
(
self
,
sample
):
return
dict
(
{
"x"
:
self
.
convert_single
(
sample
[
0
]),
"y"
:
self
.
convert_single
(
sample
[
1
]),
"z"
:
self
.
convert_single
(
sample
[
2
]),
}
)
return
self
.
convert_data_vector
(
sample
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment