From 5686e2fa57889c0dcf714fca9009892ddf4e1369 Mon Sep 17 00:00:00 2001 From: "Thomas A. Hirsch" Date: Sun, 3 Nov 2019 22:43:40 +0100 Subject: [PATCH] Cleaned up a bit and added an ESP8266 example. --- .gitignore | 2 + examples/ESP8266/ESP8266.ino | 66 ++++++++++++++++++++++++++ keywords.txt | 2 +- WTV020SD16P.cpp => src/WTV020SD16P.cpp | 0 WTV020SD16P.h => src/WTV020SD16P.h | 0 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 examples/ESP8266/ESP8266.ino rename WTV020SD16P.cpp => src/WTV020SD16P.cpp (100%) rename WTV020SD16P.h => src/WTV020SD16P.h (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a4d52e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.development + diff --git a/examples/ESP8266/ESP8266.ino b/examples/ESP8266/ESP8266.ino new file mode 100644 index 0000000..ddc1316 --- /dev/null +++ b/examples/ESP8266/ESP8266.ino @@ -0,0 +1,66 @@ +/* + Example of using the WTV020SD16P chip on an ESP8266. + + Connect the WTV020SD16P to your ESP8266 and define the pins below. + + created 3 Nov 2019 + by Thomas A. Hirsch + + original version created by ELECTRONOOBS, 14 Oct 2016. + + This example code is in the public domain. +*/ + +#include +#include + +// Constants to define the used pins. +static const uint8_t resetPin = D1; // The pin number of the reset pin. +static const uint8_t clockPin = D6; // The pin number of the clock pin. +static const uint8_t dataPin = D7; // The pin number of the data pin. +static const uint8_t busyPin = D5; // The pin number of the busy pin. + +// Instance of WTV020SD16P +WTV020SD16P wtv020sd16p(resetPin, clockPin,dataPin,busyPin); + +void setup() { + +} + +void loop() { + wtv020sd16p.asyncPlayVoice(0); + + //////////////////////////////////////////// + //This are all the functions for the WTV020 module + //Use yours and delete the others + //Each function is explained + /////////////////////////////////////////// + //Plays synchronously an audio file. Busy pin is used for this method. + //wtv020sd15p.playVoice(0); // Will triggern the wdt (watch-dog timer) due to the use of sleep() on ESP8266! + //Plays asynchronously an audio file. + //wtv020sd16p.asyncPlayVoice(1); + //Plays audio file number 1 during 5 seconds. + //wtv020sd16p.asyncPlayVoice(1); + //delay(5000); + //Pauses audio file number 1 during 5 seconds. + //wtv020sd16p.pauseVoice(); + //delay(5000); + //Resumes audio file number 1 during 5 seconds. + //wtv020sd16p.pauseVoice(); + //delay(5000); + //Stops current audio file playing. + //wtv020sd16p.stopVoice(); + //Plays synchronously an audio file. Busy pin is used for this method. + //wtv020sd16p.asyncPlayVoice(2); + //delay(2000); + //Mutes audio file number 2 during 2 seconds. + //wtv020sd16p.mute(); + //delay(2000); + //Unmutes audio file number 2 during 2 seconds. + //wtv020sd16p.unmute(); + //delay(2000); + //Stops current audio file playing. + //wtv020sd16p.stopVoice(); + //Resets the chip - Will initially be called during construction. + //wtv020sd16p.reset(); +} diff --git a/keywords.txt b/keywords.txt index a6ca194..124f233 100644 --- a/keywords.txt +++ b/keywords.txt @@ -5,7 +5,7 @@ ####################################### # Datatypes (KEYWORD1) ####################################### -WTV020SD16P KEYWORD1 +WTV020SD16P KEYWORD1 DATA_TYPE ####################################### # Methods and Functions (KEYWORD2) diff --git a/WTV020SD16P.cpp b/src/WTV020SD16P.cpp similarity index 100% rename from WTV020SD16P.cpp rename to src/WTV020SD16P.cpp diff --git a/WTV020SD16P.h b/src/WTV020SD16P.h similarity index 100% rename from WTV020SD16P.h rename to src/WTV020SD16P.h