nrf5/modules/music: backing up porting progress in modmusic.c.
This commit is contained in:
parent
d170ca5d03
commit
a7f10336e1
@ -33,6 +33,8 @@
|
||||
#include "modmusic.h"
|
||||
#include "musictunes.h"
|
||||
#include "drivers/pwm.h"
|
||||
#include "pin.h"
|
||||
#include "genhdr/pins.h"
|
||||
|
||||
#define DEFAULT_BPM 120
|
||||
#define DEFAULT_TICKS 4 // i.e. 4 ticks per beat
|
||||
@ -270,12 +272,17 @@ STATIC mp_obj_t microbit_music_get_tempo(void) {
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(microbit_music_get_tempo_obj, microbit_music_get_tempo);
|
||||
|
||||
STATIC mp_obj_t microbit_music_stop(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// TODO: const pin_obj_t *pin;
|
||||
const pin_obj_t *pin;
|
||||
if (n_args == 0) {
|
||||
// TODO:pin = µbit_p0_obj;
|
||||
#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 {
|
||||
// TODO:pin = microbit_obj_get_pin(args[0]);
|
||||
pin = (pin_obj_t *)args[0];
|
||||
}
|
||||
(void)pin;
|
||||
// Raise exception if the pin we are trying to stop is not in a compatible mode.
|
||||
// TODO: microbit_obj_pin_acquire(pin, microbit_pin_mode_music);
|
||||
// TODO: pwm_set_duty_cycle(pin->name, 0);
|
||||
@ -291,7 +298,7 @@ STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_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_const_none} },
|
||||
{ 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} },
|
||||
};
|
||||
@ -353,7 +360,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_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_const_none} },
|
||||
{ MP_QSTR_pin, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
{ MP_QSTR_wait, MP_ARG_BOOL, {.u_bool = true} },
|
||||
};
|
||||
|
||||
@ -364,8 +371,8 @@ 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;
|
||||
//TODO: const pin_obj_t *pin = microbit_obj_get_pin(args[2].u_obj);
|
||||
|
||||
const pin_obj_t *pin = args[2].u_obj;
|
||||
(void)pin;
|
||||
// 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