Skip to content

Commit 05dd727

Browse files
committed
PWM remove callback
1 parent 02f859f commit 05dd727

File tree

2 files changed

+1
-42
lines changed

2 files changed

+1
-42
lines changed

src/AudioPWM/AudioPWM.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ class PWMAudioOutput : public AudioOutput {
5050
}
5151
}
5252

53-
// /// Starts the PWMAudio using callbacks
54-
bool begin(uint16_t sampleRate, uint8_t channels, PWMCallbackType cb) {
55-
TRACED();
56-
audio_config.channels = channels;
57-
audio_config.sample_rate = sampleRate;
58-
driver.setUserCallback(cb);
59-
return begin();
60-
}
61-
62-
6353
/// starts the processing using Streams
6454
bool begin(PWMConfig config ) {
6555
TRACED();

src/AudioPWM/PWMAudioBase.h

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ class DriverPWMBase {
120120
LOGE("Only max %d channels are supported!",maxChannels());
121121
return false;
122122
}
123-
if (audio_config.bits_per_sample!=16){
124-
LOGE("bits_per_sample must be 16!");
125-
return false;
126-
}
127123
// allocate buffer if necessary
128124
if (user_callback==nullptr) {
129125
if (buffer!=nullptr){
@@ -195,10 +191,6 @@ class DriverPWMBase {
195191
}
196192
}
197193

198-
void setUserCallback(PWMCallbackType cb){
199-
user_callback = cb;
200-
}
201-
202194
bool isTimerStarted() {
203195
return is_timer_started;
204196
}
@@ -224,22 +216,8 @@ class DriverPWMBase {
224216
bool is_timer_started = false;
225217
bool is_blocking_write = true;
226218

227-
void playNextFrameCallback(){
228-
//TRACED();
229-
uint8_t channels = audio_config.channels;
230-
int16_t data[channels];
231-
if (user_callback(channels, data)){
232-
for (uint8_t j=0;j<audio_config.channels;j++){
233-
int value = map(data[j], -NumberConverter::maxValue(16), NumberConverter::maxValue(16), 0, 255);
234-
pwmWrite(j, value);
235-
}
236-
updateStatistics();
237-
}
238-
}
239-
240-
241219
/// writes the next frame to the output pins
242-
void playNextFrameStream(){
220+
void playNextFrame(){
243221
if (isTimerStarted() && buffer!=nullptr){
244222
//TRACED();
245223
int required = (audio_config.bits_per_sample / 8) * audio_config.channels;
@@ -255,15 +233,6 @@ class DriverPWMBase {
255233
}
256234
}
257235

258-
void playNextFrame(){
259-
// TRACED();
260-
if (user_callback!=nullptr){
261-
playNextFrameCallback();
262-
} else {
263-
playNextFrameStream();
264-
}
265-
}
266-
267236
/// determines the next scaled value
268237
virtual int nextValue() {
269238
int result = 0;

0 commit comments

Comments
 (0)