Skip to content

Commit

Permalink
Limit speed SerialWAV can send samples, avoid WDT
Browse files Browse the repository at this point in the history
  • Loading branch information
earlephilhower committed Mar 26, 2018
1 parent 1e584d1 commit abeba9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/AudioOutputSerialWAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ bool AudioOutputSerialWAV::begin()
wavHeader[34] = bps;
wavHeader[35] = 0;
Serial.write(wavHeader, sizeof(wavHeader));
count = 0;
return true;
}

bool AudioOutputSerialWAV::ConsumeSample(int16_t sample[2])
{
if (++count == 200) {
count = 0;
return false;
}
for (int i=0; i<channels; i++) {
if (bps == 8) {
uint8_t l = sample[i] & 0xff;
Expand Down
2 changes: 2 additions & 0 deletions src/AudioOutputSerialWAV.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class AudioOutputSerialWAV : public AudioOutput
virtual bool begin() override;
virtual bool ConsumeSample(int16_t sample[2]) override;
virtual bool stop() override;
private:
int count;
};

#endif
Expand Down

0 comments on commit abeba9d

Please sign in to comment.