Skip to content

Commit 0fe6fe6

Browse files
committed
Plasma: Add is_busy method.
1 parent 23ac27e commit 0fe6fe6

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

micropython/modules/plasma/plasma.c

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(PlasmaAPA102_get_obj, 2, PlasmaAPA102_get);
1111
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaAPA102_clear_obj, PlasmaAPA102_clear);
1212
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaAPA102_update_obj, PlasmaAPA102_update);
1313
MP_DEFINE_CONST_FUN_OBJ_2(PlasmaAPA102_set_blocking_obj, PlasmaAPA102_set_blocking);
14+
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaAPA102_is_busy_obj, PlasmaAPA102_is_busy);
1415

1516
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaWS2812___del___obj, PlasmaWS2812___del__);
1617
MP_DEFINE_CONST_FUN_OBJ_KW(PlasmaWS2812_set_rgb_obj, 5, PlasmaWS2812_set_rgb);
@@ -20,6 +21,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(PlasmaWS2812_get_obj, 2, PlasmaWS2812_get);
2021
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaWS2812_clear_obj, PlasmaWS2812_clear);
2122
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaWS2812_update_obj, PlasmaWS2812_update);
2223
MP_DEFINE_CONST_FUN_OBJ_2(PlasmaWS2812_set_blocking_obj, PlasmaWS2812_set_blocking);
24+
MP_DEFINE_CONST_FUN_OBJ_1(PlasmaWS2812_is_busy_obj, PlasmaWS2812_is_busy);
2325

2426
/***** Binding of Methods *****/
2527
static const mp_rom_map_elem_t PlasmaAPA102_locals_dict_table[] = {
@@ -32,6 +34,7 @@ static const mp_rom_map_elem_t PlasmaAPA102_locals_dict_table[] = {
3234
{ MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&PlasmaAPA102_clear_obj) },
3335
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&PlasmaAPA102_update_obj) },
3436
{ MP_ROM_QSTR(MP_QSTR_set_blocking), MP_ROM_PTR(&PlasmaAPA102_set_blocking_obj) },
37+
{ MP_ROM_QSTR(MP_QSTR_is_busy), MP_ROM_PTR(&PlasmaAPA102_is_busy_obj) },
3538
};
3639
static const mp_rom_map_elem_t PlasmaWS2812_locals_dict_table[] = {
3740
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&PlasmaWS2812___del___obj) },
@@ -42,6 +45,7 @@ static const mp_rom_map_elem_t PlasmaWS2812_locals_dict_table[] = {
4245
{ MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&PlasmaWS2812_clear_obj) },
4346
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&PlasmaWS2812_update_obj) },
4447
{ MP_ROM_QSTR(MP_QSTR_set_blocking), MP_ROM_PTR(&PlasmaWS2812_set_blocking_obj) },
48+
{ MP_ROM_QSTR(MP_QSTR_is_busy), MP_ROM_PTR(&PlasmaWS2812_is_busy_obj) },
4549
};
4650

4751
static MP_DEFINE_CONST_DICT(PlasmaAPA102_locals_dict, PlasmaAPA102_locals_dict_table);

micropython/modules/plasma/plasma.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ mp_obj_t PlasmaWS2812_set_blocking(mp_obj_t self_in, mp_obj_t blocking_in) {
125125
return mp_const_none;
126126
}
127127

128+
mp_obj_t PlasmaWS2812_is_busy(mp_obj_t self_in) {
129+
_PlasmaWS2812_obj_t *self = MP_OBJ_TO_PTR2(self_in, _PlasmaWS2812_obj_t);
130+
return self->ws2812->is_busy() ? mp_const_true : mp_const_false;
131+
}
132+
128133
mp_obj_t PlasmaWS2812_start(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
129134
enum { ARG_self, ARG_fps };
130135
static const mp_arg_t allowed_args[] = {
@@ -343,6 +348,11 @@ mp_obj_t PlasmaAPA102_set_blocking(mp_obj_t self_in, mp_obj_t blocking_in) {
343348
return mp_const_none;
344349
}
345350

351+
mp_obj_t PlasmaAPA102_is_busy(mp_obj_t self_in) {
352+
_PlasmaAPA102_obj_t *self = MP_OBJ_TO_PTR2(self_in, _PlasmaAPA102_obj_t);
353+
return self->apa102->is_busy() ? mp_const_true : mp_const_false;
354+
}
355+
346356
mp_obj_t PlasmaAPA102_start(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
347357
enum { ARG_self, ARG_fps };
348358
static const mp_arg_t allowed_args[] = {

micropython/modules/plasma/plasma.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern mp_obj_t PlasmaAPA102_get(size_t n_args, const mp_obj_t *pos_args, mp_map
1717
extern mp_obj_t PlasmaAPA102_clear(mp_obj_t self_in);
1818
extern mp_obj_t PlasmaAPA102_update(mp_obj_t self_in);
1919
extern mp_obj_t PlasmaAPA102_set_blocking(mp_obj_t self_in, mp_obj_t blocking_in);
20+
extern mp_obj_t PlasmaAPA102_is_busy(mp_obj_t self_in);
2021

2122
extern void PlasmaWS2812_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
2223
extern mp_obj_t PlasmaWS2812_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
@@ -28,5 +29,6 @@ extern mp_obj_t PlasmaWS2812_get(size_t n_args, const mp_obj_t *pos_args, mp_map
2829
extern mp_obj_t PlasmaWS2812_clear(mp_obj_t self_in);
2930
extern mp_obj_t PlasmaWS2812_update(mp_obj_t self_in);
3031
extern mp_obj_t PlasmaWS2812_set_blocking(mp_obj_t self_in, mp_obj_t blocking_in);
32+
extern mp_obj_t PlasmaWS2812_is_busy(mp_obj_t self_in);
3133

3234
extern bool Pimoroni_mp_obj_to_i2c(mp_obj_t in, void *out);

0 commit comments

Comments
 (0)