diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/README.md b/README.md index e69de29..7f37cac 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,14 @@ +# HannaBox + + +## Pins +RX -> DIN +D8 -> BCLK +D4 -> LRC +5V -> Vin +GND -> GND + +## Links + +https://github.com/earlephilhower/ESP8266Audio + diff --git a/data/ex.mp3 b/data/ex.mp3 new file mode 100644 index 0000000..e175d0f Binary files /dev/null and b/data/ex.mp3 differ diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..eb3a3bf --- /dev/null +++ b/platformio.ini @@ -0,0 +1,18 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:d1_mini] +platform = espressif8266 +board = d1_mini +framework = arduino +lib_deps = + tzapu/WiFiManager@^0.16.0 + earlephilhower/ESP8266Audio@^1.9.7 +monitor_speed = 115200 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..4ce43b8 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,73 @@ +#include //https://github.com/esp8266/Arduino + +// needed for library +#include +#include +#include //https://github.com/tzapu/WiFiManager + +#include "AudioFileSourceSPIFFS.h" +#include "AudioGeneratorMP3.h" +#include "AudioOutputI2SNoDAC.h" + +AudioGeneratorMP3 *mp3; +AudioFileSourceSPIFFS *file; +AudioOutputI2SNoDAC *out; + +void setup() +{ + // put your setup code here, to run once: + Serial.begin(115200); + + // WiFiManager + // Local intialization. Once its business is done, there is no need to keep it around + + + //WiFiManager wifiManager; + + + // reset saved settings + // wifiManager.resetSettings(); + + // set custom ip for portal + // wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); + + // fetches ssid and pass from eeprom and tries to connect + // if it does not connect it starts an access point with the specified name + // here "AutoConnectAP" + // and goes into a blocking loop awaiting configuration + //wifiManager.autoConnect("AutoConnectAP"); + // or use this for auto generated name ESP + ChipID + + + // wifiManager.autoConnect(); + + // if you get here you have connected to the WiFi + Serial.println("connected...yeey :)"); + audioLogger = &Serial; + + SPIFFS.begin(); + Serial.println("beginning mp3 setup..."); + file = new AudioFileSourceSPIFFS("/ex.mp3"); + out = new AudioOutputI2SNoDAC(); + mp3 = new AudioGeneratorMP3(); + if (!mp3->begin(file, out)) { + Serial.println("could not play file."); + } + + +} + +void loop() +{ + if (mp3->isRunning()) + { + if (!mp3->loop()) + mp3->stop(); + } + else + { + Serial.printf("MP3 done\n"); + delay(1000); + } + +} \ No newline at end of file diff --git a/test/README b/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html