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
Merge requests
!15
Implement frozen modules (
#4
)
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement frozen modules (
#4
)
rahix/mpy-frozen
into
master
Overview
0
Commits
5
Pipelines
2
Changes
1
Merged
rahix
requested to merge
rahix/mpy-frozen
into
master
5 years ago
Overview
0
Commits
5
Pipelines
2
Changes
1
Expand
0
0
Merge request reports
Viewing commit
2433b2f0
Prev
Next
Show latest version
1 file
+
12
−
12
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
2433b2f0
fix(pycardium): Make leds module work with colors
· 2433b2f0
rahix
authored
5 years ago
Signed-off-by:
Rahix
<
rahix@rahix.de
>
pycardium/modules/leds.c
+
12
−
12
Options
@@ -8,21 +8,21 @@ static mp_obj_t mp_leds_set(mp_obj_t led_in, mp_obj_t color_in)
{
int
led
=
mp_obj_get_int
(
led_in
);
if
(
!
mp_obj_
is_type
(
color_in
,
&
mp_type_list
)
)
{
mp_raise_
Typ
eError
(
"color must
be a list
"
);
if
(
mp_obj_
get_int
(
mp_obj_len
(
color_in
))
<
3
)
{
mp_raise_
Valu
eError
(
"color must
have 3 elements
"
);
}
mp_obj_list_t
*
color
=
MP_OBJ_TO_PTR
(
color_in
);
if
(
color
->
len
<
3
)
{
mp_raise_ValueError
(
"color list must have 3 elements"
);
}
epic_leds_set
(
led
,
mp_obj_get_int
(
color
->
items
[
0
]),
mp_obj_get_int
(
color
->
items
[
1
]),
mp_obj_get_int
(
color
->
items
[
2
])
uint8_t
red
=
mp_obj_get_int
(
mp_obj_subscr
(
color_in
,
mp_obj_new_int
(
0
),
MP_OBJ_SENTINEL
)
);
uint8_t
green
=
mp_obj_get_int
(
mp_obj_subscr
(
color_in
,
mp_obj_new_int
(
1
),
MP_OBJ_SENTINEL
)
);
uint8_t
blue
=
mp_obj_get_int
(
mp_obj_subscr
(
color_in
,
mp_obj_new_int
(
2
),
MP_OBJ_SENTINEL
)
);
epic_leds_set
(
led
,
red
,
green
,
blue
);
return
mp_const_none
;
}
Loading