watchdog added... still not satisfied about stability... T.T

This commit is contained in:
Dooho Yi 2019-12-31 00:25:19 +09:00
parent c78b4d5601
commit 51ad7dec35
3 changed files with 36 additions and 26 deletions

View file

@ -34,32 +34,32 @@
class AudioPlaySdWav : public AudioStream
{
public:
AudioPlaySdWav(void) : AudioStream(0, NULL), block_left(NULL), block_right(NULL) { begin(); }
void begin(void);
bool play(const char *filename);
void stop(void);
bool isPlaying(void);
uint32_t positionMillis(void);
uint32_t lengthMillis(void);
virtual void update(void);
AudioPlaySdWav(void) : AudioStream(0, NULL), block_left(NULL), block_right(NULL) { begin(); }
void begin(void);
bool play(const char *filename);
void stop(void);
bool isPlaying(void);
uint32_t positionMillis(void);
uint32_t lengthMillis(void);
virtual void update(void);
private:
File wavfile;
bool consume(uint32_t size);
bool parse_format(void);
uint32_t header[10]; // temporary storage of wav header data
uint32_t data_length; // number of bytes remaining in current section
uint32_t total_length; // number of audio data bytes in file
uint32_t bytes2millis;
audio_block_t *block_left;
audio_block_t *block_right;
uint16_t block_offset; // how much data is in block_left & block_right
uint8_t buffer[512]; // buffer one block of data
uint16_t buffer_offset; // where we're at consuming "buffer"
uint16_t buffer_length; // how much data is in "buffer" (512 until last read)
uint8_t header_offset; // number of bytes in header[]
uint8_t state;
uint8_t state_play;
uint8_t leftover_bytes;
File wavfile;
bool consume(uint32_t size);
bool parse_format(void);
uint32_t header[10]; // temporary storage of wav header data
uint32_t data_length; // number of bytes remaining in current section
uint32_t total_length; // number of audio data bytes in file
uint32_t bytes2millis;
audio_block_t *block_left;
audio_block_t *block_right;
uint16_t block_offset; // how much data is in block_left & block_right
uint8_t buffer[512]; // buffer one block of data
uint16_t buffer_offset; // where we're at consuming "buffer"
uint16_t buffer_length; // how much data is in "buffer" (512 until last read)
uint8_t header_offset; // number of bytes in header[]
uint8_t state;
uint8_t state_play;
uint8_t leftover_bytes;
};
#endif

View file

@ -16,6 +16,7 @@ lib_ignore = Audio, SD
lib_deps =
721 ; TaskScheduler
322 ; SdFat
401 ; Adafruit SleepyDog Library
[env:teensy35]
platform = teensy

View file

@ -33,6 +33,9 @@
// #define ANALOG_REF_EXTERNAL_3P3V
//----------</configuration>----------
//watchdog
#include <Adafruit_SleepyDog.h>
//teensy audio
#include <Audio.h>
#include <SdFat.h>
@ -121,7 +124,7 @@ public:
// the filename to play is...
Serial.println(filename);
// go! (re-triggering)
if (player.isPlaying()) player.stop();
// if (player.isPlaying()) player.stop();
player.play(filename);
Serial.println("1");
// --> we just believe that this 'file' is existing & available. NO additional checking.
@ -303,6 +306,9 @@ void playcheck() {
// //
// Serial.print("AM_max:");
// Serial.println(AudioMemoryUsageMax());
//watchdog
Watchdog.reset();
}
//
Task playcheck_task(100, TASK_FOREVER, playcheck, &runner, true);
@ -462,6 +468,9 @@ void setup() {
//
Serial.println("[setup] done.");
//watchdog
Watchdog.enable(1000);
}
void loop() {