8000 make pycom.rgbled() return the current color value · jdexyz/pycom-micropython-sigfox@1cde92a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cde92a

Browse files
gijsiopeter-pycom
authored andcommitted
make pycom.rgbled() return the current color value
1 parent 4f07373 commit 1cde92a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

esp32/mods/modpycom.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,25 @@ STATIC mp_obj_t mod_pycom_heartbeat (mp_uint_t n_args, const mp_obj_t *args) {
156156
}
157157
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_pycom_heartbeat_obj, 0, 1, mod_pycom_heartbeat);
158158

159-
STATIC mp_obj_t mod_pycom_rgb_led (mp_obj_t o_color) {
159+
STATIC mp_obj_t mod_pycom_rgb_led (mp_uint_t n_args, const mp_obj_t *args) {
160160
#ifndef RGB_LED_DISABLE
161161
if (mperror_is_heartbeat_enabled()) {
162162
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_request_not_possible));
163163
}
164-
165-
uint32_t color = mp_obj_get_int(o_color);
166-
led_info.color.value = color;
167-
led_set_color(&led_info, true, false);
164+
if(n_args > 0){
165+
uint32_t color = mp_obj_get_int(args[0]);
166+
led_info.color.value = color;
167+
led_set_color(&led_info, true, false);
168+
} else {
169+
return mp_obj_new_int(led_info.color.value);
170+
}
168171
#else
169172
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "RGB Led Interface Disabled"));
170173
#endif
171174

172175
return mp_const_none;
173176
}
174-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_pycom_rgb_led_obj, mod_pycom_rgb_led);
177+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_pycom_rgb_led_obj, 0,1,mod_pycom_rgb_led);
175178

176179
STATIC mp_obj_t mod_pycom_ota_start (void) {
177180
if (!updater_start()) {

0 commit comments

Comments
 (0)
0