Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
2433b2f0
Verified
Commit
2433b2f0
authored
Jul 05, 2019
by
Rahix
Browse files
fix(pycardium): Make leds module work with colors
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
d407658a
Changes
1
Hide whitespace changes
Inline
Side-by-side
pycardium/modules/leds.c
View file @
2433b2f0
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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