nrf5/modules/music: Updating pitch method to also use configured pin from mpconfigboard.h if set, in the case of lacking kwarg for pin. Also removing some commented out arguments to remove some confusion in the argument list. Done for both play() and pitch().
This commit is contained in:
parent
d5acc13d5e
commit
db0fa6aafb
@ -307,7 +307,6 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(microbit_music_stop_obj, 0, 1, microbit_musi
|
||||
STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_music, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
// TODO:{ MP_QSTR_pin, MP_ARG_OBJ, {.u_obj = (mp_obj_t)µbit_p0_obj} },
|
||||
{ MP_QSTR_pin, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_wait, MP_ARG_BOOL, {.u_bool = true} },
|
||||
{ MP_QSTR_loop, MP_ARG_BOOL, {.u_bool = false} },
|
||||
@ -378,7 +377,6 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args,
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_frequency, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
|
||||
{ MP_QSTR_duration, MP_ARG_INT, {.u_int = -1} },
|
||||
//TODO: { MP_QSTR_pin, MP_ARG_OBJ, {.u_obj = (mp_obj_t)µbit_p0_obj} },
|
||||
{ MP_QSTR_pin, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_wait, MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
@ -390,8 +388,19 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args,
|
||||
// get the parameters
|
||||
mp_uint_t frequency = args[0].u_int;
|
||||
mp_int_t duration = args[1].u_int;
|
||||
const pin_obj_t *pin = args[2].u_obj;
|
||||
(void)pin;
|
||||
|
||||
// get the pin to play on
|
||||
const pin_obj_t *pin;
|
||||
if (args[2].u_obj == MP_OBJ_NULL) {
|
||||
#ifdef MICROPY_HW_MUSIC_PIN
|
||||
pin = &MICROPY_HW_MUSIC_PIN;
|
||||
#else
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
|
||||
#endif
|
||||
} else {
|
||||
pin = (pin_obj_t *)args[2].u_obj;
|
||||
}
|
||||
|
||||
// Update pin modes
|
||||
//TODO: microbit_obj_pin_free(music_data->async_pin);
|
||||
music_data->async_pin = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user