|
4 | 4 | MiniWebRadio -- Webradio receiver for ESP32
|
5 | 5 |
|
6 | 6 | first release on 03/2017 */String Version ="\
|
7 |
| - Version 3.1e Jun 11/2024 "; |
| 7 | + Version 3.2 Jun 13/2024 "; |
8 | 8 |
|
9 | 9 | /* 2.8" color display (320x240px) with controller ILI9341 or HX8347D (SPI) or
|
10 | 10 | 3.5" color display (480x320px) wiht controller ILI9486 or ILI9488 (SPI)
|
@@ -72,7 +72,8 @@ uint8_t _cur_Codec = 0;
|
72 | 72 | uint8_t _numServers = 0; //
|
73 | 73 | uint8_t _level = 0;
|
74 | 74 | uint8_t _timeFormat = 24; // 24 or 12
|
75 |
| -uint8_t _sleepMode = 0; // 0 display off, 1 show the clock |
| 75 | +uint8_t _sleepMode = 0; // 0 display off, 1 show the clock |
| 76 | +uint8_t _alarmMode = 1; // 0 with radio only, 1 with bell and radio |
76 | 77 | uint8_t _staListPos = 0;
|
77 | 78 | uint8_t _semaphore = 0;
|
78 | 79 | uint8_t _reconnectCnt = 0;
|
@@ -427,7 +428,8 @@ boolean defaultsettings(){
|
427 | 428 | strcat(jO, "\"toneHP\":"); strcat(jO, "0,"); // -40 ... +6 (dB) audioI2S
|
428 | 429 | strcat(jO, "\"balance\":"); strcat(jO, "0,"); // -16 ... +16 audioI2S
|
429 | 430 | strcat(jO, "\"timeFormat\":"); strcat(jO, "24,");
|
430 |
| - strcat(jO, "\"sleepMode\":"); strcat(jO, "0}"); // 0 display off, 1 clock |
| 431 | + strcat(jO, "\"sleepMode\":"); strcat(jO, "0,"); // 0 display off, 1 clock |
| 432 | + strcat(jO, "\"alarmMode\":"); strcat(jO, "1}"); // 0 with radio only, 1 with bell and radio |
431 | 433 | file.print(jO);
|
432 | 434 | if(jO){free(jO); jO = NULL;}
|
433 | 435 | }
|
@@ -483,6 +485,7 @@ boolean defaultsettings(){
|
483 | 485 | _TZString = parseJson("\"Timezone_String\":");
|
484 | 486 | _lastconnectedhost = parseJson("\"lastconnectedhost\":");
|
485 | 487 | _sleepMode = atoi( parseJson("\"sleepMode\":"));
|
| 488 | + _alarmMode = atoi( parseJson("\"alarmMode\":")); |
486 | 489 |
|
487 | 490 |
|
488 | 491 | if(!pref.isKey("stations_filled")|| _sum_stations == 0) saveStationsToNVS(); // first init
|
@@ -638,7 +641,8 @@ void updateSettings(){
|
638 | 641 | sprintf(tmp, ",\"toneHP\":%i", _toneHP); strcat(jO, tmp);
|
639 | 642 | sprintf(tmp, ",\"balance\":%i", _toneBAL); strcat(jO, tmp);
|
640 | 643 | sprintf(tmp, ",\"timeFormat\":%i", _timeFormat); strcat(jO, tmp);
|
641 |
| - sprintf(tmp, ",\"sleepMode\":%i}", _sleepMode); strcat(jO, tmp); |
| 644 | + sprintf(tmp, ",\"sleepMode\":%i", _sleepMode); strcat(jO, tmp); |
| 645 | + sprintf(tmp, ",\"alarmMode\":%i}", _alarmMode); strcat(jO, tmp); |
642 | 646 |
|
643 | 647 | if(_settingsHash != simpleHash(jO)) {
|
644 | 648 | File file = SD_MMC.open("/settings.json", "w", false);
|
@@ -1021,7 +1025,7 @@ boolean isPlaylist(File file) {
|
1021 | 1025 | * P L A Y L I S T *
|
1022 | 1026 | *****************************************************************************************************************************************************/
|
1023 | 1027 |
|
1024 |
| -bool preparePlaylistFromFile(const char* path) { |
| 1028 | +bool preparePlaylistFromFile(const char* path) { // *.m3u |
1025 | 1029 | File playlistFile = SD_MMC.open(path);
|
1026 | 1030 | if(!playlistFile) {
|
1027 | 1031 | log_e("playlistfile path not found");
|
@@ -1084,7 +1088,7 @@ bool preparePlaylistFromFile(const char* path) {
|
1084 | 1088 | }
|
1085 | 1089 | //____________________________________________________________________________________________________________________________________________________
|
1086 | 1090 |
|
1087 |
| -bool preparePlaylistFromFolder(const char* path) { // all files whithin a folder |
| 1091 | +bool preparePlaylistFromSDFolder(const char* path) { // all files whithin a SD folder |
1088 | 1092 | if(!SD_MMC.exists(path)) {
|
1089 | 1093 | SerialPrintfln(ANSI_ESC_RED "SD_MMC/%s not exist", path);
|
1090 | 1094 | return false;
|
@@ -2510,13 +2514,19 @@ void loop() {
|
2510 | 2514 | dispHeader.updateItem("ALARM");
|
2511 | 2515 | dispHeader.updateTime(rtc.gettime_s());
|
2512 | 2516 | dispFooter.show();
|
2513 |
| - showFileName("ALARM"); |
2514 |
| - drawImage("/common/Alarm.jpg", _winLogo.x, _winLogo.y); |
2515 |
| - setTFTbrightness(_brightness); |
2516 |
| - SerialPrintfln(ANSI_ESC_MAGENTA "Alarm"); |
2517 |
| - audioSetVolume(21); |
2518 |
| - muteChanged(false); |
2519 |
| - connecttoFS("/ring/alarm_clock.mp3"); |
| 2517 | + if(_alarmMode == 1){ // alarm with bell |
| 2518 | + showFileName("ALARM"); |
| 2519 | + drawImage("/common/Alarm.jpg", _winLogo.x, _winLogo.y); |
| 2520 | + setTFTbrightness(_brightness); |
| 2521 | + SerialPrintfln(ANSI_ESC_MAGENTA "Alarm"); |
| 2522 | + audioSetVolume(21); |
| 2523 | + muteChanged(false); |
| 2524 | + connecttoFS("/ring/alarm_clock.mp3"); |
| 2525 | + } |
| 2526 | + else{ // alarm without bell |
| 2527 | + _f_eof_alarm = true; |
| 2528 | + return; |
| 2529 | + } |
2520 | 2530 | }
|
2521 | 2531 | if(_f_eof_alarm) { // AFTER RINGING
|
2522 | 2532 | _f_eof_alarm = false;
|
@@ -3315,7 +3325,7 @@ void WEBSRV_onCommand(const String cmd, const String param, const String arg){
|
3315 | 3325 |
|
3316 | 3326 | if(cmd == "SD_playAllFiles"){ webSrv.send("SD_playFolder=", "" + param);
|
3317 | 3327 | SerialPrintfln("webSrv: ... " ANSI_ESC_YELLOW "Play Folder" ANSI_ESC_ORANGE "\"%s\"", param.c_str());
|
3318 |
| - preparePlaylistFromFolder(param.c_str()); |
| 3328 | + preparePlaylistFromSDFolder(param.c_str()); |
3319 | 3329 | processPlaylist(true);
|
3320 | 3330 | return;}
|
3321 | 3331 |
|
@@ -3369,6 +3379,14 @@ void WEBSRV_onCommand(const String cmd, const String param, const String arg){
|
3369 | 3379 | if(_sleepMode == 1) SerialPrintfln("SleepMode: " ANSI_ESC_YELLOW "Show the time");
|
3370 | 3380 | return;}
|
3371 | 3381 |
|
| 3382 | + if(cmd == "getAlarmMode"){ webSrv.send("alarmMode=", String(_alarmMode, 10)); |
| 3383 | + return;} |
| 3384 | + |
| 3385 | + if(cmd == "setAlarmMode"){ _alarmMode = param.toInt(); |
| 3386 | + if(_alarmMode == 0) SerialPrintfln("AlarmMode: " ANSI_ESC_YELLOW "with radio only"); |
| 3387 | + if(_alarmMode == 1) SerialPrintfln("AlarmMode: " ANSI_ESC_YELLOW "with bell and radio"); |
| 3388 | + return;} |
| 3389 | + |
3372 | 3390 | if(cmd == "loadIRbuttons"){ loadIRbuttonsFromNVS(); // update IR buttons in ir.cpp
|
3373 | 3391 | char buf[150];
|
3374 | 3392 | uint8_t* buttons = ir.get_irButtons();
|
@@ -3661,8 +3679,8 @@ void graphicObjects_OnRelease(const char* name, releasedArg ra) {
|
3661 | 3679 | if(strcmp(name, "btn_PL_prevFile") == 0) {return;}
|
3662 | 3680 | if(strcmp(name, "btn_PL_nextFile") == 0) {return;}
|
3663 | 3681 | if(strcmp(name, "btn_PL_ready") == 0) {_playerSubmenue = 1; SD_playFile(_curAudioFolder, _SD_content.getIndex(_cur_AudioFileNr)); changeState(PLAYER); showAudioFileNumber(); return;}
|
3664 |
| - if(strcmp(name, "btn_PL_playAll") == 0) {_playerSubmenue = 1; _f_shuffle = false; preparePlaylistFromFolder(_curAudioFolder); processPlaylist(true); changeState(PLAYER); return;} |
3665 |
| - if(strcmp(name, "btn_PL_shuffle") == 0) {_playerSubmenue = 1; _f_shuffle = true; preparePlaylistFromFolder(_curAudioFolder); processPlaylist(true); changeState(PLAYER); return;} |
| 3682 | + if(strcmp(name, "btn_PL_playAll") == 0) {_playerSubmenue = 1; _f_shuffle = false; preparePlaylistFromSDFolder(_curAudioFolder); processPlaylist(true); changeState(PLAYER); return;} |
| 3683 | + if(strcmp(name, "btn_PL_shuffle") == 0) {_playerSubmenue = 1; _f_shuffle = true; preparePlaylistFromSDFolder(_curAudioFolder); processPlaylist(true); changeState(PLAYER); return;} |
3666 | 3684 | if(strcmp(name, "btn_PL_fileList") == 0) {_playerSubmenue = 1; _SD_content.listDir(_curAudioFolder, true, false); changeState(AUDIOFILESLIST); return;}
|
3667 | 3685 | if(strcmp(name, "btn_PL_radio") == 0) {_playerSubmenue = 0; setStation(_cur_station); changeState(RADIO); return;}
|
3668 | 3686 | }
|
|
0 commit comments