PWM audio: Rename AudioOut -> PWMAudioOut, _audioio_ -> _audiopwmio_

This commit is contained in:
Jeff Epler 2019-07-29 18:39:00 -04:00
parent aa1398e696
commit b72352949b
8 changed files with 95 additions and 95 deletions

View File

@ -34,7 +34,7 @@
#endif
#if CIRCUITPY_AUDIOPWMIO
#include "common-hal/audiopwmio/AudioOut.h"
#include "common-hal/audiopwmio/PWMAudioOut.h"
#endif
static bool running_background_tasks = false;

View File

@ -31,15 +31,15 @@
#include "py/gc.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "common-hal/audiopwmio/AudioOut.h"
#include "common-hal/audiopwmio/PWMAudioOut.h"
#include "common-hal/pulseio/PWMOut.h"
#include "shared-bindings/audiopwmio/AudioOut.h"
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "supervisor/shared/translate.h"
// TODO: This should be the same size as PWMOut.c:pwms[], but there's no trivial way to accomplish that
STATIC audiopwmio_audioout_obj_t* active_audio[4];
STATIC audiopwmio_pwmaudioout_obj_t* active_audio[4];
#define F_TARGET (62500)
#define F_PWM (16000000)
@ -63,7 +63,7 @@ STATIC uint32_t calculate_pwm_parameters(uint32_t sample_rate, uint32_t *top_out
return multiplier - 1;
}
STATIC void activate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) {
STATIC void activate_audiopwmout_obj(audiopwmio_pwmaudioout_obj_t *self) {
for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) {
if(!active_audio[i]) {
active_audio[i] = self;
@ -71,7 +71,7 @@ STATIC void activate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) {
}
}
}
STATIC void deactivate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) {
STATIC void deactivate_audiopwmout_obj(audiopwmio_pwmaudioout_obj_t *self) {
for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) {
if(active_audio[i] == self)
active_audio[i] = NULL;
@ -83,7 +83,7 @@ void audiopwmout_reset() {
active_audio[i] = NULL;
}
STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) {
STATIC void fill_buffers(audiopwmio_pwmaudioout_obj_t *self, int buf) {
self->pwm->EVENTS_SEQSTARTED[1-buf] = 0;
uint16_t *dev_buffer = self->buffers[buf];
uint8_t *buffer;
@ -92,7 +92,7 @@ STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) {
audiosample_get_buffer(self->sample, false, 0,
&buffer, &buffer_length);
if (get_buffer_result == GET_BUFFER_ERROR) {
common_hal_audiopwmio_audioout_stop(self);
common_hal_audiopwmio_pwmaudioout_stop(self);
return;
}
uint32_t num_samples = buffer_length / self->bytes_per_sample / self->spacing;
@ -132,8 +132,8 @@ STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) {
}
}
STATIC void audiopwmout_background_obj(audiopwmio_audioout_obj_t *self) {
if(!common_hal_audiopwmio_audioout_get_playing(self))
STATIC void audiopwmout_background_obj(audiopwmio_pwmaudioout_obj_t *self) {
if(!common_hal_audiopwmio_pwmaudioout_get_playing(self))
return;
if(self->loop && self->single_buffer) {
self->pwm->LOOP = 0xffff;
@ -156,7 +156,7 @@ void audiopwmout_background() {
}
}
void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self,
void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self,
const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) {
assert_pin_free(left_channel);
assert_pin_free(right_channel);
@ -188,12 +188,12 @@ void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self,
// TODO: Ramp from 0 to quiescent value
}
bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self) {
bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t* self) {
return !self->pwm;
}
void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self) {
if (common_hal_audiopwmio_audioout_deinited(self)) {
void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t* self) {
if (common_hal_audiopwmio_pwmaudioout_deinited(self)) {
return;
}
// TODO: ramp the pwm down from quiescent value to 0
@ -216,9 +216,9 @@ void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self) {
self->buffers[1] = NULL;
}
void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop) {
if (common_hal_audiopwmio_audioout_get_playing(self)) {
common_hal_audiopwmio_audioout_stop(self);
void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, mp_obj_t sample, bool loop) {
if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) {
common_hal_audiopwmio_pwmaudioout_stop(self);
}
self->sample = sample;
self->loop = loop;
@ -268,7 +268,7 @@ void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj
self->paused = false;
}
void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) {
void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self) {
deactivate_audiopwmout_obj(self);
self->pwm->TASKS_STOP = 1;
self->stopping = false;
@ -281,7 +281,7 @@ void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) {
self->buffers[1] = NULL;
}
bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self) {
bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self) {
if(self->pwm->EVENTS_STOPPED) {
self->playing = false;
self->pwm->EVENTS_STOPPED = 0;
@ -305,14 +305,14 @@ bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self)
* feels instant. (This also saves on memory, for long in-memory "single buffer"
* samples!)
*/
void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self) {
void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self) {
self->paused = true;
}
void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self) {
void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self) {
self->paused = false;
}
bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self) {
bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self) {
return self->paused;
}

View File

@ -50,7 +50,7 @@ typedef struct {
bool loop;
bool signed_to_unsigned;
bool single_buffer;
} audiopwmio_audioout_obj_t;
} audiopwmio_pwmaudioout_obj_t;
void audiopwmout_reset(void);

View File

@ -51,7 +51,7 @@
#include "shared-bindings/rtc/__init__.h"
#ifdef CIRCUITPY_AUDIOPWMIO
#include "common-hal/audiopwmio/AudioOut.h"
#include "common-hal/audiopwmio/PWMAudioOut.h"
#endif
static void power_warning_handler(void) {

View File

@ -227,7 +227,7 @@ $(filter $(SRC_PATTERNS), \
audiobusio/I2SOut.c \
audiobusio/PDMIn.c \
audiopwmio/__init__.c \
audiopwmio/AudioOut.c \
audiopwmio/PWMAudioOut.c \
audioio/__init__.c \
audioio/AudioOut.c \
bleio/__init__.c \

View File

@ -31,7 +31,7 @@
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audiopwmio/AudioOut.h"
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
@ -97,7 +97,7 @@
//| pass
//| print("stopped")
//|
STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED },
@ -119,9 +119,9 @@ STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n
}
// create AudioOut object from the given pin
audiopwmio_audioout_obj_t *self = m_new_obj(audiopwmio_audioout_obj_t);
self->base.type = &audiopwmio_audioout_type;
common_hal_audiopwmio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int);
audiopwmio_pwmaudioout_obj_t *self = m_new_obj(audiopwmio_pwmaudioout_obj_t);
self->base.type = &audiopwmio_pwmaudioout_type;
common_hal_audiopwmio_pwmaudioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int);
return MP_OBJ_FROM_PTR(self);
}
@ -130,15 +130,15 @@ STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n
//|
//| Deinitialises the AudioOut and releases any hardware resources for reuse.
//|
STATIC mp_obj_t audiopwmio_audioout_deinit(mp_obj_t self_in) {
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audiopwmio_audioout_deinit(self);
STATIC mp_obj_t audiopwmio_pwmaudioout_deinit(mp_obj_t self_in) {
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audiopwmio_pwmaudioout_deinit(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_deinit_obj, audiopwmio_audioout_deinit);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_deinit_obj, audiopwmio_pwmaudioout_deinit);
STATIC void check_for_deinit(audiopwmio_audioout_obj_t *self) {
if (common_hal_audiopwmio_audioout_deinited(self)) {
STATIC void check_for_deinit(audiopwmio_pwmaudioout_obj_t *self) {
if (common_hal_audiopwmio_pwmaudioout_deinited(self)) {
raise_deinited_error();
}
}
@ -153,12 +153,12 @@ STATIC void check_for_deinit(audiopwmio_audioout_obj_t *self) {
//| Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info.
//|
STATIC mp_obj_t audiopwmio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) {
STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
common_hal_audiopwmio_audioout_deinit(args[0]);
common_hal_audiopwmio_pwmaudioout_deinit(args[0]);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_audioout___exit___obj, 4, 4, audiopwmio_audioout_obj___exit__);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, 4, 4, audiopwmio_pwmaudioout_obj___exit__);
//| .. method:: play(sample, *, loop=False)
@ -172,50 +172,50 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_audioout___exit___obj, 4,
//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit
//| DAC that ignores the lowest 6 bits when playing 16 bit samples.
//|
STATIC mp_obj_t audiopwmio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_sample, ARG_loop };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_sample, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_loop, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
};
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
check_for_deinit(self);
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_obj_t sample = args[ARG_sample].u_obj;
common_hal_audiopwmio_audioout_play(self, sample, args[ARG_loop].u_bool);
common_hal_audiopwmio_pwmaudioout_play(self, sample, args[ARG_loop].u_bool);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_audioout_play_obj, 1, audiopwmio_audioout_obj_play);
MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_pwmaudioout_play_obj, 1, audiopwmio_pwmaudioout_obj_play);
//| .. method:: stop()
//|
//| Stops playback and resets to the start of the sample.
//|
STATIC mp_obj_t audiopwmio_audioout_obj_stop(mp_obj_t self_in) {
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_stop(mp_obj_t self_in) {
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
common_hal_audiopwmio_audioout_stop(self);
common_hal_audiopwmio_pwmaudioout_stop(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_stop_obj, audiopwmio_audioout_obj_stop);
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_stop_obj, audiopwmio_pwmaudioout_obj_stop);
//| .. attribute:: playing
//|
//| True when an audio sample is being output even if `paused`. (read-only)
//|
STATIC mp_obj_t audiopwmio_audioout_obj_get_playing(mp_obj_t self_in) {
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_playing(mp_obj_t self_in) {
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return mp_obj_new_bool(common_hal_audiopwmio_audioout_get_playing(self));
return mp_obj_new_bool(common_hal_audiopwmio_pwmaudioout_get_playing(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_get_playing_obj, audiopwmio_audioout_obj_get_playing);
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_get_playing_obj, audiopwmio_pwmaudioout_obj_get_playing);
const mp_obj_property_t audiopwmio_audioout_playing_obj = {
const mp_obj_property_t audiopwmio_pwmaudioout_playing_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&audiopwmio_audioout_get_playing_obj,
.proxy = {(mp_obj_t)&audiopwmio_pwmaudioout_get_playing_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
@ -224,71 +224,71 @@ const mp_obj_property_t audiopwmio_audioout_playing_obj = {
//|
//| Stops playback temporarily while remembering the position. Use `resume` to resume playback.
//|
STATIC mp_obj_t audiopwmio_audioout_obj_pause(mp_obj_t self_in) {
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) {
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
if (!common_hal_audiopwmio_audioout_get_playing(self)) {
if (!common_hal_audiopwmio_pwmaudioout_get_playing(self)) {
mp_raise_RuntimeError(translate("Not playing"));
}
common_hal_audiopwmio_audioout_pause(self);
common_hal_audiopwmio_pwmaudioout_pause(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_pause_obj, audiopwmio_audioout_obj_pause);
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_pause_obj, audiopwmio_pwmaudioout_obj_pause);
//| .. method:: resume()
//|
//| Resumes sample playback after :py:func:`pause`.
//|
STATIC mp_obj_t audiopwmio_audioout_obj_resume(mp_obj_t self_in) {
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_resume(mp_obj_t self_in) {
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
if (common_hal_audiopwmio_audioout_get_paused(self)) {
common_hal_audiopwmio_audioout_resume(self);
if (common_hal_audiopwmio_pwmaudioout_get_paused(self)) {
common_hal_audiopwmio_pwmaudioout_resume(self);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_resume_obj, audiopwmio_audioout_obj_resume);
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_resume_obj, audiopwmio_pwmaudioout_obj_resume);
//| .. attribute:: paused
//|
//| True when playback is paused. (read-only)
//|
STATIC mp_obj_t audiopwmio_audioout_obj_get_paused(mp_obj_t self_in) {
audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_paused(mp_obj_t self_in) {
audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return mp_obj_new_bool(common_hal_audiopwmio_audioout_get_paused(self));
return mp_obj_new_bool(common_hal_audiopwmio_pwmaudioout_get_paused(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_get_paused_obj, audiopwmio_audioout_obj_get_paused);
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_get_paused_obj, audiopwmio_pwmaudioout_obj_get_paused);
const mp_obj_property_t audiopwmio_audioout_paused_obj = {
const mp_obj_property_t audiopwmio_pwmaudioout_paused_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&audiopwmio_audioout_get_paused_obj,
.proxy = {(mp_obj_t)&audiopwmio_pwmaudioout_get_paused_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
STATIC const mp_rom_map_elem_t audiopwmio_audioout_locals_dict_table[] = {
STATIC const mp_rom_map_elem_t audiopwmio_pwmaudioout_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiopwmio_audioout_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiopwmio_pwmaudioout_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiopwmio_audioout___exit___obj) },
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiopwmio_audioout_play_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiopwmio_audioout_stop_obj) },
{ MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audiopwmio_audioout_pause_obj) },
{ MP_ROM_QSTR(MP_QSTR_resume), MP_ROM_PTR(&audiopwmio_audioout_resume_obj) },
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiopwmio_pwmaudioout___exit___obj) },
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiopwmio_pwmaudioout_play_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiopwmio_pwmaudioout_stop_obj) },
{ MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audiopwmio_pwmaudioout_pause_obj) },
{ MP_ROM_QSTR(MP_QSTR_resume), MP_ROM_PTR(&audiopwmio_pwmaudioout_resume_obj) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiopwmio_audioout_playing_obj) },
{ MP_ROM_QSTR(MP_QSTR_paused), MP_ROM_PTR(&audiopwmio_audioout_paused_obj) },
{ MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiopwmio_pwmaudioout_playing_obj) },
{ MP_ROM_QSTR(MP_QSTR_paused), MP_ROM_PTR(&audiopwmio_pwmaudioout_paused_obj) },
};
STATIC MP_DEFINE_CONST_DICT(audiopwmio_audioout_locals_dict, audiopwmio_audioout_locals_dict_table);
STATIC MP_DEFINE_CONST_DICT(audiopwmio_pwmaudioout_locals_dict, audiopwmio_pwmaudioout_locals_dict_table);
const mp_obj_type_t audiopwmio_audioout_type = {
const mp_obj_type_t audiopwmio_pwmaudioout_type = {
{ &mp_type_type },
.name = MP_QSTR_PWMAudioOut,
.make_new = audiopwmio_audioout_make_new,
.locals_dict = (mp_obj_dict_t*)&audiopwmio_audioout_locals_dict,
.make_new = audiopwmio_pwmaudioout_make_new,
.locals_dict = (mp_obj_dict_t*)&audiopwmio_pwmaudioout_locals_dict,
};

View File

@ -27,23 +27,23 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H
#include "common-hal/audiopwmio/AudioOut.h"
#include "common-hal/audiopwmio/PWMAudioOut.h"
#include "common-hal/microcontroller/Pin.h"
#include "shared-bindings/audiocore/RawSample.h"
extern const mp_obj_type_t audiopwmio_audioout_type;
extern const mp_obj_type_t audiopwmio_pwmaudioout_type;
// left_channel will always be non-NULL but right_channel may be for mono output.
void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self,
void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self,
const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value);
void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self);
bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self);
void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop);
void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self);
bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self);
void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self);
void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self);
bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self);
void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t* self);
bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t* self);
void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, mp_obj_t sample, bool loop);
void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self);
bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self);
void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self);
void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self);
bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H

View File

@ -31,7 +31,7 @@
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audiopwmio/__init__.h"
#include "shared-bindings/audiopwmio/AudioOut.h"
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
//| :mod:`audiopwmio` --- Support for audio input and output
//| ========================================================
@ -60,7 +60,7 @@
STATIC const mp_rom_map_elem_t audiopwmio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiopwmio) },
{ MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audiopwmio_audioout_type) },
{ MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audiopwmio_pwmaudioout_type) },
};
STATIC MP_DEFINE_CONST_DICT(audiopwmio_module_globals, audiopwmio_module_globals_table);