Skip to content

Commit

Permalink
codal_port/modaudio: Ignore return_pin argument to audio.play().
Browse files Browse the repository at this point in the history
On v2 this should be ignored, as per the docs.

Fixes issue #181.

Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Apr 30, 2024
1 parent c143b24 commit 15b467c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/codal_port/modaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ STATIC mp_obj_t stop(void) {
MP_DEFINE_CONST_FUN_OBJ_0(microbit_audio_stop_obj, stop);

STATIC mp_obj_t play(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// Note: the return_pin argument is for compatibility with micro:bit v1 and is ignored on v2.
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_source, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_wait, MP_ARG_BOOL, {.u_bool = true} },
Expand All @@ -222,11 +223,6 @@ STATIC mp_obj_t play(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);

// The return_pin argument from micro:bit v1 is no longer supported.
if (args[3].u_obj != mp_const_none) {
mp_raise_ValueError(MP_ERROR_TEXT("return_pin not supported"));
}

mp_obj_t src = args[0].u_obj;
microbit_audio_play_source(src, args[2].u_obj, args[1].u_bool, DEFAULT_SAMPLE_RATE);
return mp_const_none;
Expand Down

0 comments on commit 15b467c

Please sign in to comment.