forked from Edzelf/Esp-radio
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract 'switch to MP3 mode' functionality to be called explicitly
- Loading branch information
Showing
6 changed files
with
713 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
examples/SimpleMp3PlayerWithDebug/SimpleMp3PlayerWithDebug.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
A simple example to use ESP_VS1053_Library (plays a test sound every 3s) | ||
https://github.com/baldram/ESP_VS1053_Library | ||
If you like this project, please add a star. | ||
For debugging it uses third-party library ArduinoLog. | ||
No need to add a depenency in lib_deps explicitly, since | ||
it is used internally by ESP_VS1053_Library. | ||
Copyright (C) 2017 Marcin Szalomski (github.com/baldram) | ||
Licensed under GNU GPL v3 | ||
The circuit (example wiring for ESP8266 based board like eg. LoLin NodeMCU V3): | ||
--------------------- | ||
| VS1053 | ESP8266 | | ||
--------------------- | ||
| SCK | D5 | | ||
| MISO | D6 | | ||
| MOSI | D7 | | ||
| XRST | RST | | ||
| CS | D1 | | ||
| DCS | D0 | | ||
| DREQ | D3 | | ||
| 5V | VU | | ||
| GND | G | | ||
--------------------- | ||
Note: It's just an example, you may use a different pins definition | ||
To run this example define the platformio.ini as below. | ||
[env:nodemcuv2] | ||
platform = espressif8266 | ||
board = nodemcuv2 | ||
framework = arduino | ||
lib_deps = | ||
baldram/ESP_VS1053_Library | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <ArduinoLog.h> // PlatformIO library id=1532 | ||
#include <VS1053.h> // this ESP_VS1053_Library | ||
#include <helloMp3.h> | ||
|
||
// Wiring of VS1053 board (SPI connected in a standard way) | ||
#define VS1053_CS D1 | ||
#define VS1053_DCS D0 | ||
#define VS1053_DREQ D3 | ||
|
||
#define VOLUME 100 // volume level 0-100 | ||
|
||
VS1053 player(VS1053_CS, VS1053_DCS, VS1053_DREQ); | ||
|
||
void setup () { | ||
// initialize SPI | ||
SPI.begin(); | ||
|
||
// open serial monitor for debugging | ||
Serial.begin(9600); | ||
while(!Serial && !Serial.available()){} | ||
Log.begin(LOG_LEVEL_VERBOSE, &Serial); | ||
|
||
// initialize a player | ||
Log.notice("Hello VS1053!\n"); | ||
player.begin(); | ||
player.switchToMp3Mode(); // optional, some boards require this | ||
player.setVolume(VOLUME); | ||
} | ||
|
||
void loop() { | ||
Log.notice("Playing sound... "); | ||
|
||
// play mp3 flow each 3s | ||
player.playChunk(helloMp3, sizeof(helloMp3)); | ||
delay(3000); | ||
} |
Oops, something went wrong.