Skip to content

Commit

Permalink
microbit: Turn the radio on when importing radio module.
Browse files Browse the repository at this point in the history
Addresses issue #760.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Aug 19, 2022
1 parent 81df66b commit 8d21387
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/microbit/modradio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ static mp_obj_t radio_receive(uint8_t *header, mp_buffer_info_t *bufinfo, uint32
/*****************************************************************************/
// MicroPython bindings and module

STATIC mp_obj_t mod_radio_reset(void);

STATIC mp_obj_t mod_radio___init__(void) {
mod_radio_reset();
radio_enable();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(mod_radio___init___obj, mod_radio___init__);

STATIC mp_obj_t mod_radio_reset(void) {
radio_state.max_payload = RADIO_DEFAULT_MAX_PAYLOAD;
radio_state.queue_len = RADIO_DEFAULT_QUEUE_LEN;
Expand Down Expand Up @@ -511,7 +520,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_receive_full_obj, mod_radio_receive_full);

STATIC const mp_map_elem_t radio_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_radio) },
{ MP_OBJ_NEW_QSTR(MP_QSTR___init__), (mp_obj_t)&mod_radio_reset_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR___init__), (mp_obj_t)&mod_radio___init___obj },

{ MP_OBJ_NEW_QSTR(MP_QSTR_reset), (mp_obj_t)&mod_radio_reset_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_config), (mp_obj_t)&mod_radio_config_obj },
Expand Down

0 comments on commit 8d21387

Please sign in to comment.