Limit speed SerialWAV can send samples, avoid WDT

This commit is contained in:
Earle F. Philhower, III committed 2018-03-26 07:15:58 -07:00
1 parent 1e584d141a
commit abeba9dd89
2 files changed
+7

No files matched your search

+5
View File
@@ -45,11 +45,16 @@ bool AudioOutputSerialWAV::begin()
wavHeader[34] = bps; wavHeader[34] = bps;
wavHeader[35] = 0; wavHeader[35] = 0;
Serial.write(wavHeader, sizeof(wavHeader)); Serial.write(wavHeader, sizeof(wavHeader));
count = 0;
return true; return true;
} }
bool AudioOutputSerialWAV::ConsumeSample(int16_t sample[2]) bool AudioOutputSerialWAV::ConsumeSample(int16_t sample[2])
{ {
if (++count == 200) {
count = 0;
return false;
}
for (int i=0; i<channels; i++) { for (int i=0; i<channels; i++) {
if (bps == 8) { if (bps == 8) {
uint8_t l = sample[i] & 0xff; uint8_t l = sample[i] & 0xff;
+2
View File
@@ -31,6 +31,8 @@ class AudioOutputSerialWAV : public AudioOutput
virtual bool begin() override; virtual bool begin() override;
virtual bool ConsumeSample(int16_t sample[2]) override; virtual bool ConsumeSample(int16_t sample[2]) override;
virtual bool stop() override; virtual bool stop() override;
private:
int count;
}; };
#endif #endif