First experiments
This commit is contained in:
73
src/main.cpp
Normal file
73
src/main.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
|
||||
|
||||
// needed for library
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiManager.h> //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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user