Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Open-Cube FW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Cube
Open-Cube FW
Commits
f071178d
Verified
Commit
f071178d
authored
1 year ago
by
Jakub Vaněk
Browse files
Options
Downloads
Patches
Plain Diff
Turn ICM20608 off after being garbage-collected
parent
878a3add
Branches
jv-robosoutez
No related tags found
No related merge requests found
Pipeline
#66472
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
micropython/modules/opencube_brick/ICM20608_api.c
+7
-2
7 additions, 2 deletions
micropython/modules/opencube_brick/ICM20608_api.c
with
7 additions
and
2 deletions
micropython/modules/opencube_brick/ICM20608_api.c
+
7
−
2
View file @
f071178d
...
...
@@ -17,7 +17,7 @@ static void ICM20608_print(const mp_print_t *print, mp_obj_t self_in);
// Called on ICM20608 init
STATIC
mp_obj_t
ICM20608_make_new
(
const
mp_obj_type_t
*
type
,
size_t
n_args
,
size_t
n_kw
,
const
mp_obj_t
*
args
)
{
ICM20608_obj_t
*
self
=
m_new_obj
(
ICM20608_obj_t
);
ICM20608_obj_t
*
self
=
m_new_obj
_with_finaliser
(
ICM20608_obj_t
);
self
->
base
.
type
=
type
;
self
->
icm
=
(
ICM20608G_t
*
)
malloc
(
sizeof
(
ICM20608G_t
));
opencube_lock_i2c_or_raise
();
...
...
@@ -31,7 +31,11 @@ static void ICM20608_print(const mp_print_t *print, mp_obj_t self_in) {
}
STATIC
mp_obj_t
ICM20608_read_value
(
mp_obj_t
self_in
)
{
ICM20608_obj_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
ICM20608_obj_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
if
(
self
->
icm
==
NULL
)
{
mp_raise_msg
(
&
mp_type_RuntimeError
,
MP_ERROR_TEXT
(
"ICM20608 has been deinitialized already"
));
}
float
accel_x
,
accel_y
,
accel_z
,
gyro_x
,
gyro_y
,
gyro_z
;
opencube_lock_i2c_or_raise
();
ICM20608G_read_data
(
self
->
icm
,
...
...
@@ -63,6 +67,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(ICM20608_deinit_obj, ICM20608_deinit);
STATIC
const
mp_rom_map_elem_t
ICM20608_locals_dict
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR_read_value
),
MP_ROM_PTR
(
&
ICM20608_read_value_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_deinit
),
MP_ROM_PTR
(
&
ICM20608_deinit_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR___del__
),
MP_ROM_PTR
(
&
ICM20608_deinit_obj
)
},
};
STATIC
MP_DEFINE_CONST_DICT
(
ICM20608_locals_dict_obj
,
ICM20608_locals_dict
);
...
...
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