Skip to content

Commit c051c40

Browse files
committed
feat: add cold start ready sound feature
1 parent 76e1535 commit c051c40

11 files changed

Lines changed: 45 additions & 5 deletions

File tree

‎html/locales/de.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@
423423
"recoverVolBoot": "Letzte Lautstärke bei Neustart verwenden",
424424
"recoverVolBootExp": "Die Box erinnert sich über einen Neustart hinweg, welche Lautstärke zuletzt verwendet wurde und stellt diese automatisch wieder ein.",
425425
"volumeCurve": "Feinere Abstufungen bei niedriger Lautstärke",
426-
"volumeCurveExp": "Verwendung von logarithmischer Lautstärkeberechnung. Kann helfen, wenn im unteren Lautstärkebereich die Abstufungen zu grob sind."
426+
"volumeCurveExp": "Verwendung von logarithmischer Lautstärkeberechnung. Kann helfen, wenn im unteren Lautstärkebereich die Abstufungen zu grob sind.",
427+
"readypath": "Pfad zur Begrüßungs-MP3 (Kaltstart)"
427428
},
428429
"neopixel": {
429430
"title": "Neopixel (Helligkeit)",

‎html/locales/en.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@
425425
"recoverVolBoot": "Use last volume at restart",
426426
"recoverVolBootExp": "After a restart, the speaker remembers which volume was last used and automatically adjusts it again.",
427427
"volumeCurve": "Finer gradations at low volume",
428-
"volumeCurveExp": "Use of logarithmic volume calculation. Can help if the gradations in the lower volume range are too coarse."
428+
"volumeCurveExp": "Use of logarithmic volume calculation. Can help if the gradations in the lower volume range are too coarse.",
429+
"readypath": "Path to ready MP3 (cold start)"
429430
},
430431
"neopixel": {
431432
"title": "Neopixel (brightness)",

‎html/locales/fr.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@
412412
"recoverVolBoot": "Utiliser le dernier volume au redémarrage",
413413
"recoverVolBootExp": "Le boîtier se souvient, après un redémarrage, du dernier volume utilisé et le rétablit automatiquement.",
414414
"volumeCurve": "Des nuances plus fines à faible volume",
415-
"volumeCurveExp": "Utilisation du calcul logarithmique du volume. Peut aider si les nuances sont trop grossières dans la plage de volume inférieure."
415+
"volumeCurveExp": "Utilisation du calcul logarithmique du volume. Peut aider si les nuances sont trop grossières dans la plage de volume inférieure.",
416+
"readypath": "Chemin vers le MP3 de bienvenue"
416417
},
417418
"neopixel": {
418419
"title": "Neopixel (luminosité)",

‎html/management.html‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,9 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
10631063
data-i18n="[data-bs-content]general.options.volumeCurveExp" tabindex="0"><i
10641064
class="fas fa-circle-question"></i></a>
10651065
</div>
1066+
<br>
1067+
<label for="readyPath" data-i18n="general.options.readypath"></label>
1068+
<input type="text" class="form-control" id="readyPath" name="readyPath">
10661069
</fieldset>
10671070
</div>
10681071
<div class="col-md-12 mb-4" id="neopixelConfig" data-visible="false">
@@ -2555,6 +2558,9 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
25552558
if (genSettings.mfrc522Gain !== undefined) {
25562559
document.getElementById('mfrc522Gain').value = genSettings.mfrc522Gain;
25572560
}
2561+
if (genSettings.readyPath !== undefined) {
2562+
document.getElementById('readyPath').value = genSettings.readyPath;
2563+
}
25582564
}
25592565
// current values
25602566
let currSettings = settings.current;
@@ -2971,7 +2977,8 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
29712977
rfidReaderType: Number($('#rfidReaderType').val()),
29722978
pn5180Lpcd: $('#pn5180Lpcd').prop('checked'),
29732979
slix2Password: $('#slix2Password').val(),
2974-
mfrc522Gain: Number($('#mfrc522Gain').val())
2980+
mfrc522Gain: Number($('#mfrc522Gain').val()),
2981+
readyPath: document.getElementById('readyPath').value
29752982
},
29762983
"led": {
29772984
initBrightness: Number($('#initBrightness').val()),

‎src/AudioPlayer.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ void AudioPlayer_Loop() {
629629
if (newPlayListAvailable) {
630630
newPlayListAvailable = false;
631631
audio->stopSong();
632-
Rfid_ResetOldRfid();
633632

634633
// destroy the old playlist and assign the new one
635634
freePlaylist(gPlayProperties.playlist);
@@ -1233,6 +1232,18 @@ void AudioPlayer_PauseOnMinVolume(const uint8_t oldVolume, const uint8_t newVolu
12331232
}
12341233
}
12351234

1235+
void AudioPlayer_PlayReadyMsg(void) {
1236+
if (audio != nullptr) {
1237+
String path = gPrefsSettings.getString("readyPath", "/ready.mp3");
1238+
if (path.length() > 0 && gFSystem.exists(path)) {
1239+
Log_Printf(LOGLEVEL_INFO, "Audio: Playing ready sound from %s", path.c_str());
1240+
audio->connecttoFS(gFSystem, path.c_str());
1241+
} else {
1242+
Log_Printf(LOGLEVEL_NOTICE, "Audio: Ready sound not found at %s", path.c_str());
1243+
}
1244+
}
1245+
}
1246+
12361247
// Receives de-serialized RFID-data (from NVS) and dispatches playlists for the given
12371248
// playmode to the track-queue.
12381249
void AudioPlayer_SetPlaylist(const char *_itemToPlay, const uint32_t _lastPlayPos, const uint32_t _playMode, const uint16_t _trackLastPlayed) {

‎src/AudioPlayer.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void AudioPlayer_SetEqualizer(const int8_t gainLowPass, const int8_t gainBandPas
7171
void AudioPlayer_SetPlaylist(const char *_itemToPlay, const uint32_t _lastPlayPos, const uint32_t _playMode, const uint16_t _trackLastPlayed);
7272
void AudioPlayer_SetTrackControl(const uint8_t trackCommand);
7373
void AudioPlayer_PauseOnMinVolume(const uint8_t oldVolume, const uint8_t newVolume);
74+
void AudioPlayer_PlayReadyMsg(void);
7475

7576
playlistSortMode AudioPlayer_GetPlaylistSortMode(void);
7677
bool AudioPlayer_SetPlaylistSortMode(playlistSortMode value);

‎src/Mqtt.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ void Mqtt_ClientCallback(const char *topic_buf, uint32_t topic_length, const cha
456456
// New track to play? Take RFID-ID as input
457457
else if (reduced_topic_str == topicRfid) {
458458
if (payload_str.size() >= (cardIdStringSize - 1)) {
459+
Rfid_ResetOldRfid();
459460
xQueueSend(gRfidCardQueue, payload_str.data(), 0);
460461
} else {
461462
System_IndicateError();

‎src/System.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ void System_ShowWakeUpReason() {
309309
}
310310
}
311311

312+
bool System_IsColdStart() {
313+
return (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_UNDEFINED);
314+
}
315+
312316
void System_esp_print_tasks(void) {
313317
#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
314318
char *pbuffer = x_calloc(2048, 1);

‎src/System.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ uint8_t System_GetOperationModeFromNvs(void);
2828
void System_esp_print_tasks(void);
2929
void System_ShowWakeUpReason();
3030
void System_PauseTasksDuringUpload(bool pause);
31+
bool System_IsColdStart();

‎src/Web.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,13 @@ WebsocketCodeType JSONToSettings(JsonObject doc) {
688688
success = success && (gPrefsSettings.putBool("pauseOnMinVol", generalObj["pauseOnMinVol"].as<bool>()) != 0);
689689
success = success && (gPrefsSettings.putBool("recoverVolBoot", generalObj["recoverVolBoot"].as<bool>()) != 0);
690690
success = success && (gPrefsSettings.putUChar("volumeCurve", generalObj["volumeCurve"].as<uint8_t>()) != 0);
691+
if (generalObj["readyPath"].is<const char *>()) {
692+
const char *path = generalObj["readyPath"].as<const char *>();
693+
size_t written = gPrefsSettings.putString("readyPath", path);
694+
if (strlen(path) > 0 && written == 0) {
695+
success = false;
696+
}
697+
}
691698
success = success && (gPrefsRfid.putUChar("rfidReaderType", generalObj["rfidReaderType"].as<uint8_t>()) != 0);
692699
success = success && (gPrefsRfid.putBool("pn5180Lpcd", generalObj["pn5180Lpcd"].as<bool>()) != 0);
693700
if (generalObj["slix2Password"].is<const char *>()) {
@@ -1049,6 +1056,7 @@ static void settingsToJSON(JsonObject obj, const String section) {
10491056
generalObj["pauseOnMinVol"].set(gPrefsSettings.getBool("pauseOnMinVol", false)); // PAUSE_ON_MIN_VOLUME
10501057
generalObj["recoverVolBoot"].set(gPrefsSettings.getBool("recoverVolBoot", false)); // USE_LAST_VOLUME_AFTER_REBOOT
10511058
generalObj["volumeCurve"].set(gPrefsSettings.getUChar("volumeCurve", 0)); // VOLUMECURVE
1059+
generalObj["readyPath"].set(gPrefsSettings.getString("readyPath", "/ready.mp3")); // READY_PATH
10521060
}
10531061
if ((section == "") || (section == "equalizer")) {
10541062
// equalizer settings

0 commit comments

Comments
 (0)