Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
PetePriority
firmware
Commits
78a0e6e6
Commit
78a0e6e6
authored
Aug 30, 2019
by
Rahix
Browse files
Options
Browse Files
Download
Plain Diff
Merge 'read state of rgb LEDs'
See merge request
card10/firmware!242
parents
b6029dd5
c785ac0c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
200 additions
and
61 deletions
+200
-61
Documentation/bluetooth/card10.rst
Documentation/bluetooth/card10.rst
+7
-7
epicardium/ble/card10.c
epicardium/ble/card10.c
+120
-53
epicardium/epicardium.h
epicardium/epicardium.h
+14
-0
epicardium/modules/leds.c
epicardium/modules/leds.c
+11
-0
lib/card10/leds.c
lib/card10/leds.c
+7
-0
lib/card10/leds.h
lib/card10/leds.h
+1
-0
pycardium/modules/py/leds.py
pycardium/modules/py/leds.py
+11
-0
pycardium/modules/qstrdefs.h
pycardium/modules/qstrdefs.h
+1
-0
pycardium/modules/sys_leds.c
pycardium/modules/sys_leds.c
+28
-1
No files found.
Documentation/bluetooth/card10.rst
View file @
78a0e6e6
...
...
@@ -33,22 +33,22 @@ The current draft uses following service specification:
- Background LED Bottom Left characteristic:
UUID: ``42230211-2342-2342-2342-234223422342``
write no response
read and
write no response
- Background LED Bottom Right characteristic:
UUID: ``42230212-2342-2342-2342-234223422342``
write no response
read and
write no response
- Background LED Top Right characteristic:
UUID: ``42230213-2342-2342-2342-234223422342``
write no response
read and
write no response
- Background LED Top Left characteristic:
UUID: ``42230214-2342-2342-2342-234223422342``
write no reponse
read and
write no reponse
- LEDS dim bottom characteristic:
...
...
@@ -78,7 +78,7 @@ The current draft uses following service specification:
- LEDs above characteristic:
UUID: ``42230220-2342-2342-2342-234223422342``
write no reponse
read and
write no reponse
- Light sensor characteristic:
...
...
@@ -120,7 +120,7 @@ Background LED <Position> characteristic
----------------------------------------
The Background LEDs <Position> characteristic makes it possible to address the bottom LEDs by position.
Just write there three ``uint8`` for the rgb color.
Just write there three ``uint8`` for the rgb color
or read the current value
.
Dataformat:
...
...
@@ -170,7 +170,7 @@ It writes always as persistant and it gives feedback if the value is in range an
LEDs above characteristic
---------------------------------
This characteristic set every 11 leds on the top module at once.
This characteristic set
or read the current value of
every 11 leds on the top module at once.
By defining 11x rgb from left to right. You need also to set exchange a bigger MTU to use this feature.
- set a rainbow beginnig with red on the right edge: ``0xff0000ff8b00e8ff005dff0000ff2e00ffb900b9ff002eff5d00ffe800ffff008b``
...
...
epicardium/ble/card10.c
View file @
78a0e6e6
...
...
@@ -125,7 +125,7 @@ static const uint8_t UUID_attChar_rockets[] = {
/* BLE UUID for card10 led background bottom left */
static
const
uint8_t
UUID_char_led_bg_bottom_left
[]
=
{
ATT_PROP_WRITE_NO_RSP
,
ATT_PROP_READ
|
ATT_PROP_WRITE_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x11
,
CARD10_UUID_PREFIX
};
...
...
@@ -134,9 +134,13 @@ static const uint8_t UUID_attChar_led_bg_bottom_left[] = {
CARD10_UUID_SUFFIX
,
0x11
,
CARD10_UUID_PREFIX
};
static
uint8_t
ledBGBottomLeftValue
[]
=
{
0
,
0
,
0
};
// works vor everyone?
static
uint16_t
rgbLen
=
sizeof
(
ledBGBottomLeftValue
);
/* BLE UUID for card10 led background bottom right */
static
const
uint8_t
UUID_char_led_bg_bottom_right
[]
=
{
ATT_PROP_WRITE_NO_RSP
,
ATT_PROP_READ
|
ATT_PROP_WRITE_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x12
,
CARD10_UUID_PREFIX
};
...
...
@@ -145,9 +149,11 @@ static const uint8_t UUID_attChar_led_bg_bottom_right[] = {
CARD10_UUID_SUFFIX
,
0x12
,
CARD10_UUID_PREFIX
};
static
uint8_t
ledBGBottomRightValue
[]
=
{
0
,
0
,
0
};
/* BLE UUID for card10 led background top right */
static
const
uint8_t
UUID_char_led_bg_top_right
[]
=
{
ATT_PROP_WRITE_NO_RSP
,
ATT_PROP_READ
|
ATT_PROP_WRITE_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_TOP_RIGHT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x13
,
CARD10_UUID_PREFIX
};
...
...
@@ -156,9 +162,11 @@ static const uint8_t UUID_attChar_led_bg_top_right[] = {
CARD10_UUID_SUFFIX
,
0x13
,
CARD10_UUID_PREFIX
};
static
uint8_t
ledBGTopRightValue
[]
=
{
0
,
0
,
0
};
/* BLE UUID for card10 led background top left */
static
const
uint8_t
UUID_char_led_bg_top_left
[]
=
{
ATT_PROP_WRITE_NO_RSP
,
ATT_PROP_READ
|
ATT_PROP_WRITE_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LED_BG_TOP_LEFT_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x14
,
CARD10_UUID_PREFIX
};
...
...
@@ -167,6 +175,8 @@ static const uint8_t UUID_attChar_led_bg_top_left[] = {
CARD10_UUID_SUFFIX
,
0x14
,
CARD10_UUID_PREFIX
};
static
uint8_t
ledBGTopLeftValue
[]
=
{
0
,
0
,
0
};
/* BLE UUID for card10 dim leds on bottom */
static
const
uint8_t
UUID_char_leds_bottom_dim
[]
=
{
ATT_PROP_WRITE
,
...
...
@@ -227,7 +237,7 @@ static uint16_t personalStateLen = sizeof(personalStateValue);
/* BLE UUID for card10 above leds */
static
const
uint8_t
UUID_char_leds_above
[]
=
{
ATT_PROP_WRITE_NO_RSP
,
ATT_PROP_READ
|
ATT_PROP_WRITE_NO_RSP
,
UINT16_TO_BYTES
(
CARD10_LEDS_ABOVE_VAL_HDL
),
CARD10_UUID_SUFFIX
,
0x20
,
CARD10_UUID_PREFIX
};
...
...
@@ -235,6 +245,21 @@ static const uint8_t UUID_char_leds_above[] = {
static
const
uint8_t
UUID_attChar_leds_above
[]
=
{
CARD10_UUID_SUFFIX
,
0x20
,
CARD10_UUID_PREFIX
};
static
uint8_t
aboveLEDsValue
[]
=
{
0
,
0
,
0
,
// 0
0
,
0
,
0
,
// 1
0
,
0
,
0
,
// 2
0
,
0
,
0
,
// 3
0
,
0
,
0
,
// 4
0
,
0
,
0
,
// 5
0
,
0
,
0
,
// 6
0
,
0
,
0
,
// 7
0
,
0
,
0
,
// 8
0
,
0
,
0
,
// 9
0
,
0
,
0
,
// 10
};
static
uint16_t
aboveLEDsLen
=
sizeof
(
aboveLEDsValue
);
// starting at 0xf0 with read only characteristics
/* BLE UUID for card10 char light sensor */
...
...
@@ -331,11 +356,13 @@ static const attsAttr_t card10SvcAttrList[] = {
},
{
.
pUuid
=
UUID_attChar_led_bg_bottom_left
,
.
pValue
=
NULL
,
.
pValue
=
ledBGBottomLeftValue
,
.
pLen
=
&
rgbLen
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
settings
=
ATTS_SET_WRITE_CBACK
|
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
,
ATTS_PERMIT_WRITE_AUTH
|
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
// BG LED Bottom right
...
...
@@ -349,15 +376,16 @@ static const attsAttr_t card10SvcAttrList[] = {
},
{
.
pUuid
=
UUID_attChar_led_bg_bottom_right
,
.
pValue
=
NULL
,
.
pValue
=
ledBGBottomRightValue
,
.
pLen
=
&
rgbLen
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
settings
=
ATTS_SET_WRITE_CBACK
|
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
,
ATTS_PERMIT_WRITE_AUTH
|
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
// BG LED top right
{
.
pUuid
=
attChUuid
,
.
pValue
=
(
uint8_t
*
)
UUID_char_led_bg_top_right
,
...
...
@@ -368,11 +396,13 @@ static const attsAttr_t card10SvcAttrList[] = {
},
{
.
pUuid
=
UUID_attChar_led_bg_top_right
,
.
pValue
=
NULL
,
.
pValue
=
ledBGTopRightValue
,
.
pLen
=
&
rgbLen
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
settings
=
ATTS_SET_WRITE_CBACK
|
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
,
ATTS_PERMIT_WRITE_AUTH
|
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
// BG LED top left
...
...
@@ -386,11 +416,13 @@ static const attsAttr_t card10SvcAttrList[] = {
},
{
.
pUuid
=
UUID_attChar_led_bg_top_left
,
.
pValue
=
NULL
,
.
pValue
=
ledBGTopLeftValue
,
.
pLen
=
&
rgbLen
,
.
maxLen
=
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
settings
=
ATTS_SET_WRITE_CBACK
|
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
,
ATTS_PERMIT_WRITE_AUTH
|
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
// Dim bottom module
...
...
@@ -497,11 +529,13 @@ static const attsAttr_t card10SvcAttrList[] = {
},
{
.
pUuid
=
UUID_attChar_leds_above
,
.
pValue
=
NULL
,
.
pValue
=
aboveLEDsValue
,
.
pLen
=
&
aboveLEDsLen
,
.
maxLen
=
11
*
3
*
sizeof
(
uint8_t
),
.
settings
=
ATTS_SET_WRITE_CBACK
,
.
settings
=
ATTS_SET_WRITE_CBACK
|
ATTS_SET_READ_CBACK
,
.
permissions
=
ATTS_PERMIT_WRITE
|
ATTS_PERMIT_WRITE_ENC
|
ATTS_PERMIT_WRITE_AUTH
,
ATTS_PERMIT_WRITE_AUTH
|
ATTS_PERMIT_READ
|
ATTS_PERMIT_READ_ENC
|
ATTS_PERMIT_READ_AUTH
,
},
// Light sensor
...
...
@@ -544,6 +578,38 @@ static uint8_t setTime(uint8_t *pValue)
return
ATT_SUCCESS
;
}
/*
* Set a rgb led
*/
static
uint8_t
setRGBLed
(
uint8_t
led
,
uint8_t
*
pValue
)
{
epic_leds_set
(
led
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]);
APP_TRACE_INFO4
(
"ble-card10: set rgb led %d: #%02x%02x%02x
\n
"
,
led
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]
);
return
ATT_SUCCESS
;
}
/*
* Get value of a rgb led
*/
static
uint8_t
getRGBLed
(
uint8_t
led
,
attsAttr_t
*
pAttr
)
{
epic_leds_get_rgb
(
led
,
pAttr
->
pValue
);
APP_TRACE_INFO4
(
"ble-card10: set rgb led %d: #%02x%02x%02x
\n
"
,
led
,
pAttr
->
pValue
[
0
],
pAttr
->
pValue
[
1
],
pAttr
->
pValue
[
2
]
);
return
ATT_SUCCESS
;
}
/*
* BLE card10 write callback.
*/
...
...
@@ -584,41 +650,13 @@ static uint8_t writeCard10CB(
return
ATT_SUCCESS
;
// bg leds
case
CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL
:
epic_leds_set
(
11
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]);
APP_TRACE_INFO3
(
"ble-card10: set bg bottom left: #%02x%02x%02x
\n
"
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]
);
return
ATT_SUCCESS
;
return
setRGBLed
(
11
,
pValue
);
case
CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL
:
epic_leds_set
(
12
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]);
APP_TRACE_INFO3
(
"ble-card10: set bg bottom right: #%02x%02x%02x
\n
"
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]
);
return
ATT_SUCCESS
;
return
setRGBLed
(
12
,
pValue
);
case
CARD10_LED_BG_TOP_RIGHT_VAL_HDL
:
epic_leds_set
(
13
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]);
APP_TRACE_INFO3
(
"ble-card10: set bg top right: #%02x%02x%02x
\n
"
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]
);
return
ATT_SUCCESS
;
return
setRGBLed
(
13
,
pValue
);
case
CARD10_LED_BG_TOP_LEFT_VAL_HDL
:
epic_leds_set
(
14
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]);
APP_TRACE_INFO3
(
"ble-card10: set bg top left: #%02x%02x%02x
\n
"
,
pValue
[
0
],
pValue
[
1
],
pValue
[
2
]
);
return
ATT_SUCCESS
;
return
setRGBLed
(
14
,
pValue
);
// dim
case
CARD10_LEDS_BOTTOM_DIM_VAL_HDL
:
ui8
=
pValue
[
0
];
...
...
@@ -769,8 +807,10 @@ static uint8_t readCard10CB(
)
{
uint16_t
ui16
=
0
;
uint64_t
ui64
=
0
;
uint8_t
rgb
[]
=
{
0
,
0
,
0
};
switch
(
handle
)
{
// time
case
CARD10_TIME_VAL_HDL
:
ui64
=
epic_rtc_get_milliseconds
();
uint64_t
time
;
...
...
@@ -780,11 +820,38 @@ static uint8_t readCard10CB(
APP_TRACE_INFO0
(
"ble-card10: read time
\n
"
);
return
ATT_SUCCESS
;
// background leds
case
CARD10_LED_BG_BOTTOM_LEFT_VAL_HDL
:
return
getRGBLed
(
11
,
pAttr
);
case
CARD10_LED_BG_BOTTOM_RIGHT_VAL_HDL
:
return
getRGBLed
(
12
,
pAttr
);
case
CARD10_LED_BG_TOP_RIGHT_VAL_HDL
:
return
getRGBLed
(
13
,
pAttr
);
case
CARD10_LED_BG_TOP_LEFT_VAL_HDL
:
return
getRGBLed
(
14
,
pAttr
);
// personal state
case
CARD10_PERSONAL_STATE_VAL_HDL
:
ui16
=
epic_personal_state_get
();
*
pAttr
->
pValue
=
ui16
;
APP_TRACE_INFO1
(
"ble-card10: read personal state: %d
\n
"
,
ui16
);
return
ATT_SUCCESS
;
// leds above
case
CARD10_LEDS_ABOVE_VAL_HDL
:
for
(
ui16
=
0
;
ui16
<
11
;
ui16
++
)
{
epic_leds_get_rgb
(
ui16
,
rgb
);
pAttr
->
pValue
[
ui16
*
3
]
=
rgb
[
0
];
pAttr
->
pValue
[
ui16
*
3
+
1
]
=
rgb
[
1
];
pAttr
->
pValue
[
ui16
*
3
+
2
]
=
rgb
[
2
];
APP_TRACE_INFO4
(
"ble-card10: get led %ld above to #%02x%02x%02x
\n
"
,
ui16
,
pAttr
->
pValue
[
ui16
*
3
],
pAttr
->
pValue
[
ui16
*
3
+
1
],
pAttr
->
pValue
[
ui16
*
3
+
2
]
);
}
return
ATT_SUCCESS
;
// light sensor
case
CARD10_LIGHT_SENSOR_VAL_HDL
:
epic_light_sensor_get
(
&
ui16
);
*
pAttr
->
pValue
=
ui16
;
...
...
epicardium/epicardium.h
View file @
78a0e6e6
...
...
@@ -96,6 +96,7 @@ typedef _Bool bool;
#define API_LEDS_SET_ALL_HSV 0x6b
#define API_LEDS_SET_GAMMA_TABLE 0x6c
#define API_LEDS_CLEAR_ALL 0x6d
#define API_LEDS_GET 0x6f
#define API_VIBRA_SET 0x70
#define API_VIBRA_VIBRATE 0x71
...
...
@@ -590,6 +591,19 @@ API(API_GPIO_READ_PIN, int epic_gpio_read_pin(uint8_t pin));
*/
API
(
API_LEDS_SET
,
void
epic_leds_set
(
int
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
));
/**
* Get one of card10's RGB LEDs in format of RGB.
*
* :c:func:`epic_leds_get_rgb` will get the value of a RGB LED described by ``led``.
*
* :param int led: Which LED to get. 0-10 are the LEDs on the top and 11-14
* are the 4 "ambient" LEDs.
* :param uint8_t * rgb: need tree byte array to get the value of red, green and blue.
* :returns: ``0`` on success or ``-EPERM`` if the LED is blocked by personal-state.
*/
API
(
API_LEDS_GET
,
int
epic_leds_get_rgb
(
int
led
,
uint8_t
*
rgb
));
/**
* Set one of card10's RGB LEDs to a certain color in HSV format.
*
...
...
epicardium/modules/leds.c
View file @
78a0e6e6
...
...
@@ -49,6 +49,17 @@ void epic_leds_prep(int led, uint8_t r, uint8_t g, uint8_t b)
leds_prep
(
led
,
r
,
g
,
b
);
}
int
epic_leds_get_rgb
(
int
led
,
uint8_t
*
rgb
)
{
if
(
led
==
PERSONAL_STATE_LED
&&
personal_state_enabled
())
return
-
EPERM
;
if
(
led
<
0
||
led
>=
NUM_LEDS
)
return
-
EINVAL
;
leds_get_rgb
(
led
,
rgb
);
return
0
;
}
void
epic_leds_prep_hsv
(
int
led
,
float
h
,
float
s
,
float
v
)
{
if
(
led
==
PERSONAL_STATE_LED
&&
personal_state_enabled
())
...
...
lib/card10/leds.c
View file @
78a0e6e6
...
...
@@ -206,6 +206,13 @@ void leds_prep(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
leds
[
led
][
2
]
=
b
;
}
void
leds_get_rgb
(
uint8_t
led
,
uint8_t
*
rgb
)
{
rgb
[
0
]
=
leds
[
led
][
0
];
rgb
[
1
]
=
leds
[
led
][
1
];
rgb
[
2
]
=
leds
[
led
][
2
];
}
#if 0
//don't use, is buggy
void leds_set_autodim(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
...
...
lib/card10/leds.h
View file @
78a0e6e6
...
...
@@ -6,6 +6,7 @@
void
leds_set_dim_top
(
uint8_t
value
);
void
leds_set_dim_bottom
(
uint8_t
value
);
void
leds_prep
(
uint8_t
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
);
void
leds_get_rgb
(
uint8_t
led
,
uint8_t
*
rgb
);
void
leds_prep_hsv
(
uint8_t
led
,
float
h
,
float
s
,
float
v
);
void
leds_update_power
(
void
);
void
leds_update
(
void
);
...
...
pycardium/modules/py/leds.py
View file @
78a0e6e6
...
...
@@ -131,6 +131,17 @@ def set(led, color):
sys_leds
.
set
(
led
,
color
)
def
get_rgb
(
led
):
"""
Get the current RGB value for an RGB LED.
:param int led: Which LED to set. 0-10 are the LEDs on the top and 11-14
are the 4 "ambient" LEDs
:return [r,g,b] color: RGB triplet
"""
return
sys_leds
.
get_rgb
(
led
)
def
set_hsv
(
led
,
color
):
"""
Prepare an RGB LED to be set to an HSV value.
...
...
pycardium/modules/qstrdefs.h
View file @
78a0e6e6
...
...
@@ -8,6 +8,7 @@
Q
(
sys_leds
)
Q
(
update
)
Q
(
set
)
Q
(
get_rgb
)
Q
(
set_hsv
)
Q
(
prep
)
Q
(
prep_hsv
)
...
...
pycardium/modules/sys_leds.c
View file @
78a0e6e6
...
...
@@ -6,7 +6,6 @@
#include <stdio.h>
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
);
...
...
@@ -79,6 +78,33 @@ static mp_obj_t mp_leds_prep(mp_obj_t led_in, mp_obj_t color_in)
}
static
MP_DEFINE_CONST_FUN_OBJ_2
(
leds_prep_obj
,
mp_leds_prep
);
static
mp_obj_t
mp_leds_get_rgb
(
mp_obj_t
led_in
)
{
int
led
=
mp_obj_get_int
(
led_in
);
uint8_t
rgb
[]
=
{
0
,
0
,
0
};
int
retAPI
=
epic_leds_get_rgb
(
led
,
rgb
);
if
(
retAPI
==
-
EPERM
)
{
mp_raise_ValueError
(
"no permission: maybe blocked by personal state"
);
}
if
(
retAPI
==
-
EINVAL
)
{
mp_raise_ValueError
(
"invalid value: maybe the led does not exists"
);
}
mp_obj_t
ret
=
mp_obj_new_tuple
(
3
,
NULL
);
mp_obj_tuple_t
*
tuple
=
MP_OBJ_TO_PTR
(
ret
);
tuple
->
items
[
0
]
=
MP_OBJ_NEW_SMALL_INT
(
rgb
[
0
]);
tuple
->
items
[
1
]
=
MP_OBJ_NEW_SMALL_INT
(
rgb
[
1
]);
tuple
->
items
[
2
]
=
MP_OBJ_NEW_SMALL_INT
(
rgb
[
2
]);
return
ret
;
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
leds_get_rgb_obj
,
mp_leds_get_rgb
);
static
mp_obj_t
mp_leds_prep_hsv
(
mp_obj_t
led_in
,
mp_obj_t
color_in
)
{
int
led
=
mp_obj_get_int
(
led_in
);
...
...
@@ -238,6 +264,7 @@ static const mp_rom_map_elem_t leds_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_set
),
MP_ROM_PTR
(
&
leds_set_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_hsv
),
MP_ROM_PTR
(
&
leds_set_hsv_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_prep
),
MP_ROM_PTR
(
&
leds_prep_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_rgb
),
MP_ROM_PTR
(
&
leds_get_rgb_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_prep_hsv
),
MP_ROM_PTR
(
&
leds_prep_hsv_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_all
),
MP_ROM_PTR
(
&
leds_set_all_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_all_hsv
),
MP_ROM_PTR
(
&
leds_set_all_hsv_obj
)
},
...
...
Write
Preview
Markdown
is supported
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