10
10
#include < ESP8266Audio.h>
11
11
#include < ESP8266SAM.h>
12
12
#include " sd_functions.h"
13
+ #include " settings.h"
14
+ #include " display.h"
13
15
14
16
15
17
void SerialPrintHexString (uint64_t val) {
@@ -219,7 +221,7 @@ void handleSerialCommands() {
219
221
source = new AudioFileSourcePROGMEM ( song.c_str (), song.length () );
220
222
} else if (song.indexOf (" ." ) != -1 ) {
221
223
// try to open "song" as a file
222
- // e.g. music_player music /Axel-F.txt
224
+ // e.g. music_player audio /Axel-F.txt
223
225
if (!song.startsWith (" /" )) song = " /" + song; // add "/" if missing
224
226
// try opening on SD
225
227
// if(setupSdCard()) source = new AudioFileSourceFS(SD, song.c_str());
@@ -236,21 +238,25 @@ void handleSerialCommands() {
236
238
// switch on extension
237
239
song.toLowerCase (); // case-insensitive match
238
240
if (song.endsWith (" .txt" ) || song.endsWith (" .rtttl" )) generator = new AudioGeneratorRTTTL ();
239
- /*
241
+ /* 2FIX: compilation issues
240
242
if(song.endsWith(".mid")) {
241
243
// need to load a soundfont
242
244
AudioFileSource* sf2 = NULL;
243
- if(setupSdCard()) sf2 = new AudioFileSourceFS(SD, " 1mgm.sf2"); // TODO: make configurable
244
- if(!sf2) sf2 = new AudioFileSourceFS(LittleFS, " 1mgm.sf2"); // TODO: make configurable
245
+ if(setupSdCard()) sf2 = new AudioFileSourceSD("audio/ 1mgm.sf2"); // TODO: make configurable
246
+ if(!sf2) sf2 = new AudioFileSourceLittleFS("audio/ 1mgm.sf2"); // TODO: make configurable
245
247
if(sf2) {
246
248
// a soundfount was found
247
- generator = new AudioGeneratorMIDI();
249
+ AudioGeneratorMIDI* midi = new AudioGeneratorMIDI();
248
250
generator->SetSoundfont(sf2);
251
+ generator = midi;
249
252
}
250
253
}*/
251
254
if (song.endsWith (" .wav" )) generator = new AudioGeneratorWAV ();
252
255
if (song.endsWith (" .mod" )) generator = new AudioGeneratorMOD ();
253
- if (song.endsWith (" .mp3" )) generator = new AudioGeneratorMP3 ();
256
+ if (song.endsWith (" .mp3" )) {
257
+ generator = new AudioGeneratorMP3 ();
258
+ source = new AudioFileSourceID3 (source);
259
+ }
254
260
if (song.endsWith (" .opus" )) generator = new AudioGeneratorOpus ();
255
261
// TODO: more formats
256
262
}
@@ -266,7 +272,10 @@ void handleSerialCommands() {
266
272
}*/
267
273
268
274
// TODO: tone
269
- // https://github.com/earlephilhower/ESP8266Audio/blob/master/examples/PlayWAVFromFunction/PlayWAVFromFunction.ino
275
+ // https://github.com/earlephilhower/ESP8266Audio/issues/643
276
+
277
+ // TODO: webradio
278
+ // https://github.com/earlephilhower/ESP8266Audio/tree/master/examples/WebRadio
270
279
271
280
if (cmd_str.startsWith (" tts " ) || cmd_str.startsWith (" say " )) {
272
281
// https://github.com/earlephilhower/ESP8266SAM/blob/master/examples/Speak/Speak.ino
@@ -292,6 +301,18 @@ void handleSerialCommands() {
292
301
// https://github.com/earlephilhower/ESP8266Audio/issues/70
293
302
// https://github.com/earlephilhower/ESP8266Audio/pull/118
294
303
304
+ if (cmd_str.startsWith (" lcd " ) || cmd_str.startsWith (" tft" ) ) {
305
+ String new_status = cmd_str.substring (strlen (" lcd " ), cmd_str.length ());
306
+ if (new_status==" off" ) {
307
+ analogWrite (BACKLIGHT, 0 );
308
+ esp_timer_stop (screensaver_timer);
309
+ } else if (new_status==" on" ) {
310
+ getBrightness (); // reinit brightness
311
+ reset_screensaver_timer ();
312
+ }
313
+ return ;
314
+ }
315
+
295
316
Serial.println (" unsupported serial command: " + cmd_str);
296
317
297
318
0 commit comments