Skip to content

Commit b723529

Browse files
committed
PWM audio: Rename AudioOut -> PWMAudioOut, _audioio_ -> _audiopwmio_
1 parent aa1398e commit b723529

File tree

8 files changed

+95
-95
lines changed

8 files changed

+95
-95
lines changed

ports/nrf/background.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#endif
3535

3636
#if CIRCUITPY_AUDIOPWMIO
37-
#include "common-hal/audiopwmio/AudioOut.h"
37+
#include "common-hal/audiopwmio/PWMAudioOut.h"
3838
#endif
3939

4040
static bool running_background_tasks = false;

ports/nrf/common-hal/audiopwmio/AudioOut.c renamed to ports/nrf/common-hal/audiopwmio/PWMAudioOut.c

+21-21
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
#include "py/gc.h"
3232
#include "py/mperrno.h"
3333
#include "py/runtime.h"
34-
#include "common-hal/audiopwmio/AudioOut.h"
34+
#include "common-hal/audiopwmio/PWMAudioOut.h"
3535
#include "common-hal/pulseio/PWMOut.h"
36-
#include "shared-bindings/audiopwmio/AudioOut.h"
36+
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
3737
#include "shared-bindings/microcontroller/__init__.h"
3838
#include "shared-bindings/microcontroller/Pin.h"
3939
#include "supervisor/shared/translate.h"
4040

4141
// TODO: This should be the same size as PWMOut.c:pwms[], but there's no trivial way to accomplish that
42-
STATIC audiopwmio_audioout_obj_t* active_audio[4];
42+
STATIC audiopwmio_pwmaudioout_obj_t* active_audio[4];
4343

4444
#define F_TARGET (62500)
4545
#define F_PWM (16000000)
@@ -63,15 +63,15 @@ STATIC uint32_t calculate_pwm_parameters(uint32_t sample_rate, uint32_t *top_out
6363
return multiplier - 1;
6464
}
6565

66-
STATIC void activate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) {
66+
STATIC void activate_audiopwmout_obj(audiopwmio_pwmaudioout_obj_t *self) {
6767
for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) {
6868
if(!active_audio[i]) {
6969
active_audio[i] = self;
7070
break;
7171
}
7272
}
7373
}
74-
STATIC void deactivate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) {
74+
STATIC void deactivate_audiopwmout_obj(audiopwmio_pwmaudioout_obj_t *self) {
7575
for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) {
7676
if(active_audio[i] == self)
7777
active_audio[i] = NULL;
@@ -83,7 +83,7 @@ void audiopwmout_reset() {
8383
active_audio[i] = NULL;
8484
}
8585

86-
STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) {
86+
STATIC void fill_buffers(audiopwmio_pwmaudioout_obj_t *self, int buf) {
8787
self->pwm->EVENTS_SEQSTARTED[1-buf] = 0;
8888
uint16_t *dev_buffer = self->buffers[buf];
8989
uint8_t *buffer;
@@ -92,7 +92,7 @@ STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) {
9292
audiosample_get_buffer(self->sample, false, 0,
9393
&buffer, &buffer_length);
9494
if (get_buffer_result == GET_BUFFER_ERROR) {
95-
common_hal_audiopwmio_audioout_stop(self);
95+
common_hal_audiopwmio_pwmaudioout_stop(self);
9696
return;
9797
}
9898
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) {
132132
}
133133
}
134134

135-
STATIC void audiopwmout_background_obj(audiopwmio_audioout_obj_t *self) {
136-
if(!common_hal_audiopwmio_audioout_get_playing(self))
135+
STATIC void audiopwmout_background_obj(audiopwmio_pwmaudioout_obj_t *self) {
136+
if(!common_hal_audiopwmio_pwmaudioout_get_playing(self))
137137
return;
138138
if(self->loop && self->single_buffer) {
139139
self->pwm->LOOP = 0xffff;
@@ -156,7 +156,7 @@ void audiopwmout_background() {
156156
}
157157
}
158158

159-
void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self,
159+
void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self,
160160
const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) {
161161
assert_pin_free(left_channel);
162162
assert_pin_free(right_channel);
@@ -188,12 +188,12 @@ void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self,
188188
// TODO: Ramp from 0 to quiescent value
189189
}
190190

191-
bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self) {
191+
bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t* self) {
192192
return !self->pwm;
193193
}
194194

195-
void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self) {
196-
if (common_hal_audiopwmio_audioout_deinited(self)) {
195+
void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t* self) {
196+
if (common_hal_audiopwmio_pwmaudioout_deinited(self)) {
197197
return;
198198
}
199199
// 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) {
216216
self->buffers[1] = NULL;
217217
}
218218

219-
void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop) {
220-
if (common_hal_audiopwmio_audioout_get_playing(self)) {
221-
common_hal_audiopwmio_audioout_stop(self);
219+
void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, mp_obj_t sample, bool loop) {
220+
if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) {
221+
common_hal_audiopwmio_pwmaudioout_stop(self);
222222
}
223223
self->sample = sample;
224224
self->loop = loop;
@@ -268,7 +268,7 @@ void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj
268268
self->paused = false;
269269
}
270270

271-
void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) {
271+
void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self) {
272272
deactivate_audiopwmout_obj(self);
273273
self->pwm->TASKS_STOP = 1;
274274
self->stopping = false;
@@ -281,7 +281,7 @@ void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) {
281281
self->buffers[1] = NULL;
282282
}
283283

284-
bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self) {
284+
bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self) {
285285
if(self->pwm->EVENTS_STOPPED) {
286286
self->playing = false;
287287
self->pwm->EVENTS_STOPPED = 0;
@@ -305,14 +305,14 @@ bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self)
305305
* feels instant. (This also saves on memory, for long in-memory "single buffer"
306306
* samples!)
307307
*/
308-
void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self) {
308+
void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self) {
309309
self->paused = true;
310310
}
311311

312-
void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self) {
312+
void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self) {
313313
self->paused = false;
314314
}
315315

316-
bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self) {
316+
bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self) {
317317
return self->paused;
318318
}

ports/nrf/common-hal/audiopwmio/AudioOut.h renamed to ports/nrf/common-hal/audiopwmio/PWMAudioOut.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef struct {
5050
bool loop;
5151
bool signed_to_unsigned;
5252
bool single_buffer;
53-
} audiopwmio_audioout_obj_t;
53+
} audiopwmio_pwmaudioout_obj_t;
5454

5555
void audiopwmout_reset(void);
5656

ports/nrf/supervisor/port.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include "shared-bindings/rtc/__init__.h"
5252

5353
#ifdef CIRCUITPY_AUDIOPWMIO
54-
#include "common-hal/audiopwmio/AudioOut.h"
54+
#include "common-hal/audiopwmio/PWMAudioOut.h"
5555
#endif
5656

5757
static void power_warning_handler(void) {

py/circuitpy_defns.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ $(filter $(SRC_PATTERNS), \
227227
audiobusio/I2SOut.c \
228228
audiobusio/PDMIn.c \
229229
audiopwmio/__init__.c \
230-
audiopwmio/AudioOut.c \
230+
audiopwmio/PWMAudioOut.c \
231231
audioio/__init__.c \
232232
audioio/AudioOut.c \
233233
bleio/__init__.c \

0 commit comments

Comments
 (0)