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

View file

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

View file

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