First experiments

This commit is contained in:
Stefan Ostermann 2023-05-28 00:32:39 +02:00
parent 664b84b29b
commit 0ac1f18ccc
7 changed files with 131 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

10
.vscode/extensions.json vendored Normal file
View File

@ -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"
]
}

View File

@ -0,0 +1,14 @@
# HannaBox
## Pins
RX -> DIN
D8 -> BCLK
D4 -> LRC
5V -> Vin
GND -> GND
## Links
https://github.com/earlephilhower/ESP8266Audio

BIN
data/ex.mp3 Normal file

Binary file not shown.

18
platformio.ini Normal file
View File

@ -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

73
src/main.cpp Normal file
View 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);
}
}

11
test/README Normal file
View File

@ -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