Skip to content

Commit

Permalink
Moving settings to the Web UI (#350)
Browse files Browse the repository at this point in the history
* Transferring defines from `settings.h` to be manageable on the Web UI:
* PLAY_MONO_SPEAKER
* SAVE_PLAYPOS_BEFORE_SHUTDOWN
* SAVE_PLAYPOS_WHEN_RFID_CHANGE
* SAVE_PLAYPOS_WHEN_RFID_CHANGE
* USE_LAST_VOLUME_AFTER_REBOOT
* VOLUMECURVE

* clang and personal settings ...

* So much clang!

* Moving settings to settings-override.h

* Cleaning `settings.h` from now unused defines

* added missing volume curve checkbox in html

* mke clang happy

---------

Co-authored-by: fabian <[email protected]>
Co-authored-by: Dirk Carstensen <[email protected]>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent 624cfab commit 8323438
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 116 deletions.
15 changes: 15 additions & 0 deletions html/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,21 @@
"gainHighPass": "Höhen (in dB)",
"info": "Die Frequenzen sind laut Bibliothek (ESP32-audioI2S) 500 Hz LowShelf, 3000 Hz PeakEQ und 6000 Hz HighShelf."
},
"options": {
"title": "Optionen",
"playMono": "Mono-Wiedergabe",
"playMonoExp": "Wenn zwei Lautsprecher verbaut sind, kann Stereo abgespielt werden. Mehr Infos <a href='https://forum.espuino.de/t/stereo-ausgabe/341' target='_blank'>hier</a>.",
"savePlayPosShutdown": "Abspielposition beim Ausschalten merken",
"savePlayPosShutdownExp": "Beim Ausschalten der Box wird für Hörbücher die Abspielposition gespeichert. Mehr Infos <a href='https://forum.espuino.de/t/welche-optionen-beim-kompilieren-gibt-es/120' target='_blank'>hier</a> unter <code>SAVE_PLAYPOS_BEFORE_SHUTDOWN</code>.",
"savePlayPosRfidChange": "Abspielposition bei RFID-Tag Wechsel merken",
"savePlayPosRfidChangeExp": "Beim Wechsel zu einem neuen RFID-Tag wird für Hörbücher die Abspielposition gespeichert. Betrifft keine Modifikations-Tags. Mehr Infos <a href='https://forum.espuino.de/t/welche-optionen-beim-kompilieren-gibt-es/120' target='_blank'>hier</a> unter <code>SAVE_PLAYPOS_WHEN_RFID_CHANGE</code>.",
"pauseOnMinVolume": "Pause bei minimaler Lautstärke",
"pauseOnMinVolumeExp": "Die Wiedergabe wird pausiert, wenn die Lautstärke das Minimum erreicht. Mehr Infos <a href='https://forum.espuino.de/t/lautstaerke-0-pause/1631' target='_blank'>hier</a>.",
"recoverVolBoot": "Letzte Lautstärke bei Neustart verwenden",
"recoverVolBootExp": "Die Box erinnert sich über einen Neustart hinweg, welche Lautstärke zuletzt verwendet wurde und stellt diese automatisch wieder ein.",
"volumeCurve" : "Feinere Abstufungen bei niedriger Lautstärke",
"volumeCurveExp" : "Verwendung von logarithmischer Lautstärkeberechnung. Kann helfen, wenn im unteren Lautstärkebereich die Abstufungen zu grob sind."
},
"neopixel": {
"title": "Neopixel (Helligkeit)",
"restart": "Nach dem Einschalten",
Expand Down
15 changes: 15 additions & 0 deletions html/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,21 @@
"gainHighPass": "Highs (in dB)",
"info": "According to the library (ESP32-audioI2S), the frequencies are 500 Hz LowShelf, 3000 Hz PeakEQ and 6000 Hz HighShelf."
},
"options": {
"title": "Options",
"playMono": "Mono Playback",
"playMonoExp": "If two speakers are installed, stereo can be played. More infos <a href='https://forum.espuino.de/t/stereo-ausgabe/341' target='_blank'>here</a>.",
"savePlayPosShutdown": "Remember playback position at shutdown",
"savePlayPosShutdownExp": "When the box is switched off, the playback position for audio books is saved. More infos <a href='https://forum.espuino.de/t/welche-optionen-beim-kompilieren-gibt-es/120' target='_blank'>here</a> under <code>SAVE_PLAYPOS_BEFORE_SHUTDOWN</code>.",
"savePlayPosRfidChange": "Remember playback position at RFID tag change",
"savePlayPosRfidChangeExp": "When switching to a new RFID tag, the playback position is saved for audio books. Does not affect modification tags. More infos <a href='https://forum.espuino.de/t/welche-optionen-beim-kompilieren-gibt-es/120' target='_blank'>here</a> under <code>SAVE_PLAYPOS_WHEN_RFID_CHANGE</code>.",
"pauseOnMinVolume": "Pause at minimum volume",
"pauseOnMinVolumeExp": "Playback is paused when the volume reaches the minimum level. More infos <a href='https://forum.espuino.de/t/lautstaerke-0-pause/1631' target='_blank'>here</a>",
"recoverVolBoot": "Use last volume at restart",
"recoverVolBootExp": "After a restart, the speaker remembers which volume was last used and automatically adjusts it again.",
"volumeCurve": "Finer gradations at low volume",
"volumeCurveExp": "Use of logarithmic volume calculation. Can help if the gradations in the lower volume range are too coarse."
},
"neopixel": {
"title": "Neopixel (brightness)",
"restart": "After restart",
Expand Down
15 changes: 15 additions & 0 deletions html/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,21 @@
"gainHighPass": "Aigus (en dB)",
"info": "Les fréquences sont, selon la bibliothèque (ESP32-audioI2S), 500 Hz LowShelf, 3000 Hz PeakEQ et 6000 Hz HighShelf."
},
"options": {
"title": "Options",
"playMono": "Lecture mono",
"playMonoExp": "Si deux haut-parleurs sont installés, la stéréo peut être jouée. Plus d'infos <a href='https://forum.espuino.de/t/stereo-ausgabe/341' target='_blank'>ici</a>.",
"savePlayPosShutdown": "Mémoriser la position de lecture à l'extinction",
"savePlayPosShutdownExp": "Lorsque la boîte est éteinte, la position de lecture est enregistrée pour les livres audio. Plus d'informations <a href='https://forum.espuino.de/t/welche-optionen-beim-kompilieren-gibt-es/120' target='_blank'>ici</a> sous <code>SAVE_PLAYPOS_BEFORE_SHUTDOWN</code>.",
"savePlayPosRfidChange": "Mémoriser la position de lecture au changement de tag RFID",
"savePlayPosRfidChangeExp": "Lors du passage à une nouvelle balise RFID, la position de lecture est enregistrée pour les livres audio. Plus d'informations <a href='https://forum.espuino.de/t/welche-optionen-beim-kompilieren-gibt-es/120' target='_blank'>ici</a> sous <code>SAVE_PLAYPOS_WHEN_RFID_CHANGE</code>.",
"pauseOnMinVolume": "Pause au volume minimal",
"pauseOnMinVolumeExp": "La lecture est mise en pause lorsque le volume atteint le minimum.Plus d'infos <a href='https://forum.espuino.de/t/lautstaerke-0-pause/1631' target='_blank'>ici</a>.",
"recoverVolBoot": "Utiliser le dernier volume au redémarrage",
"recoverVolBootExp": "Le boîtier se souvient, après un redémarrage, du dernier volume utilisé et le rétablit automatiquement.",
"volumeCurve": "Des nuances plus fines à faible volume",
"volumeCurveExp": "Utilisation du calcul logarithmique du volume. Peut aider si les nuances sont trop grossières dans la plage de volume inférieure."
},
"neopixel": {
"title": "Neopixel (luminosité)",
"restart": "Après le redémarrage",
Expand Down
99 changes: 64 additions & 35 deletions html/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,41 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
</div>
</fieldset>
</div>
<div class="col-md-12 mb-4" id="optionsConfig">
<fieldset >
<legend class="w-auto" data-i18n="general.options.title"></legend><br>
<div class="d-flex gap-2">
<input type="checkbox" id="savePlayPosShutdown" name="savePlayPosShutdown" value="false">
<label for="savePlayPosShutdown" data-i18n="general.options.savePlayPosShutdown"></label>
<a href="#" class="link-secondary" data-bs-toggle="popover" data-i18n="[data-bs-content]general.options.savePlayPosShutdownExp" tabindex="0"><i class="fas fa-circle-question"></i></a>
</div>
<div class="d-flex gap-2">
<input type="checkbox" id="savePlayPosRfidChange" name="savePlayPosRfidChange" value="false">
<label for="savePlayPosRfidChange" data-i18n="general.options.savePlayPosRfidChange"></label>
<a href="#" class="link-secondary" data-bs-toggle="popover" data-i18n="[data-bs-content]general.options.savePlayPosRfidChangeExp" tabindex="0"><i class="fas fa-circle-question"></i></a>
</div>
<div class="d-flex gap-2">
<input type="checkbox" id="pauseOnMinVolume" name="pauseOnMinVolume" value="false">
<label for="pauseOnMinVolume" data-i18n="general.options.pauseOnMinVolume"></label>
<a href="#" class="link-secondary" data-bs-toggle="popover" data-i18n="[data-bs-content]general.options.pauseOnMinVolumeExp" tabindex="0"><i class="fas fa-circle-question"></i></a>
</div>
<div class="d-flex gap-2">
<input type="checkbox" id="recoverVolBoot" name="recoverVolBoot" value="false">
<label for="recoverVolBoot" data-i18n="general.options.recoverVolBoot"></label>
<a href="#" class="link-secondary" data-bs-toggle="popover" data-i18n="[data-bs-content]general.options.recoverVolBootExp" tabindex="0"><i class="fas fa-circle-question"></i></a>
</div>
<div class="d-flex gap-2">
<input type="checkbox" id="playMono" name="playMono" value="false">
<label for="playMono" data-i18n="general.options.playMono"></label>
<a href="#" class="link-secondary" data-bs-toggle="popover" data-i18n="[data-bs-content]general.options.playMonoExp" tabindex="0"><i class="fas fa-circle-question"></i></a>
</div>
<div class="d-flex gap-2">
<input type="checkbox" id="volumeCurve" name="volumeCurve" value="false">
<label for="volumeCurve" data-i18n="general.options.volumeCurve"></label>
<a href="#" class="link-secondary" data-bs-toggle="popover" data-i18n="[data-bs-content]general.options.volumeCurveExp" tabindex="0"><i class="fas fa-circle-question"></i></a>
</div>
</fieldset>
</div>
<div class="col-md-12 mb-4" id="neopixelConfig" data-visible="false">
<fieldset>
<legend class="w-auto" data-i18n="general.neopixel.title"></legend><br>
Expand Down Expand Up @@ -1280,6 +1315,11 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
document.querySelector('#langSel').value = lng;
if (localize) {
localize('body');
// (re)initialize all popover buttons to get correct translations in the popovers
document.querySelectorAll('[data-bs-toggle="popover"]')
.forEach(popoverButton => {
new bootstrap.Popover(popoverButton, {html: true, trigger: 'focus'})
});
}
$('#navMenu').removeClass("show"); // Hide the menu again
});
Expand Down Expand Up @@ -2019,36 +2059,19 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
$('#maxVolumeSpeaker').bootstrapSlider('setValue', genSettings.maxVolumeSp);
$('#maxVolumeHeadphone').bootstrapSlider('setValue', genSettings.maxVolumeHp);
$('#inactivityTime').bootstrapSlider('setValue', genSettings.sleepInactivity);
$('#playMono').prop('checked', genSettings.playMono);
$('#savePlayPosShutdown').prop('checked', genSettings.savePosShutdown);
$('#savePlayPosRfidChange').prop('checked', genSettings.savePosRfidChg);
$('#pauseOnMinVolume').prop('checked', genSettings.pauseOnMinVol);
$('#recoverVolBoot').prop('checked', genSettings.recoverVolBoot);
$('#volumeCurve').prop('checked', genSettings.volumeCurve > 0);
}
// current values
let currSettings = settings.current;
if (currSettings) {
document.getElementById("rfidIdMusic").value = currSettings.rfidTagId;
volumeSlider.setValue(currSettings.volume);
}
// default (factory) settings
let defSettings = settings.defaults;
if (defSettings) {
$('#initialVolume').bootstrapSlider('setValue', defSettings.initVolume);
$('#maxVolumeSpeaker').bootstrapSlider('setValue', defSettings.maxVolumeSp);
$('#maxVolumeHeadphone').bootstrapSlider('setValue', defSettings.maxVolumeHp);
$('#inactivityTime').bootstrapSlider('setValue', defSettings.sleepInactivity);
$('#initBrightness').bootstrapSlider('setValue', defSettings.initBrightness);
$('#nightBrightness').bootstrapSlider('setValue', defSettings.nightBrightness);
$('#warningLowVoltage').bootstrapSlider('setValue', defSettings.warnLowVoltage);
$('#voltageIndicatorLow').bootstrapSlider('setValue', defSettings.indicatorLow);
$('#voltageIndicatorHigh').bootstrapSlider('setValue', defSettings.indicatorHi);
$('#voltageCheckInterval').bootstrapSlider('setValue', defSettings.voltageCheckInterval);
$('#criticalVoltage').bootstrapSlider('setValue', defSettings.criticalVoltage);
$("#playlistSortMode").val(defSettings.sortMode).change();
$("#gainLowPass").bootstrapSlider('setValue', defSettings.gainLowPass);
$("#gainBandPass").bootstrapSlider('setValue', defSettings.gainBandPass);
$("#gainHighPass").bootstrapSlider('setValue', defSettings.gainHighPass);
// If there is any better way to overwrite the bootstrap slider tooltip - please change this abdomination!
formatDBTooltip($('#gainLowPass')[0].previousSibling, defSettings.gainLowPass);
formatDBTooltip($('#gainBandPass')[0].previousSibling, defSettings.gainBandPass);
formatDBTooltip($('#gainHighPass')[0].previousSibling, defSettings.gainHighPass);
}
let eqSettings = settings.equalizer;
if (eqSettings) {
$("#gainLowPass").bootstrapSlider('setValue', eqSettings.gainLowPass);
Expand Down Expand Up @@ -2345,24 +2368,30 @@ <h5 class="modal-title" data-i18n="tools.nvs.erase.title"></h5>
lastIdclicked = clickedId;
var myObj = {
"general": {
initVolume: Number(document.getElementById('initialVolume').value),
maxVolumeSp: Number(document.getElementById('maxVolumeSpeaker').value),
maxVolumeHp: Number(document.getElementById('maxVolumeHeadphone').value),
sleepInactivity: Number(document.getElementById('inactivityTime').value)
initVolume: Number($('#initialVolume').val()),
maxVolumeSp: Number($('#maxVolumeSpeaker').val()),
maxVolumeHp: Number($('#maxVolumeHeadphone').val()),
sleepInactivity: Number($('#inactivityTime').val()),
playMono: $('#playMono').prop('checked'),
savePosShutdown: $('#savePlayPosShutdown').prop('checked'),
savePosRfidChg: $('#savePlayPosRfidChange').prop('checked'),
pauseOnMinVol: $('#pauseOnMinVolume').prop('checked'),
recoverVolBoot: $('#recoverVolBoot').prop('checked'),
volumeCurve: $("#volumeCurve").prop('checked') ? 1 : 0
},
"led": {
initBrightness: Number(document.getElementById('initBrightness').value),
nightBrightness: Number(document.getElementById('nightBrightness').value)
initBrightness: Number($('#initBrightness').val()),
nightBrightness: Number($('#nightBrightness').val())
},
"battery": {
warnLowVoltage: Number(document.getElementById('warningLowVoltage').value),
indicatorLow: Number(document.getElementById('voltageIndicatorLow').value),
indicatorHi: Number(document.getElementById('voltageIndicatorHigh').value),
criticalVoltage: Number(document.getElementById('criticalVoltage').value),
voltageCheckInterval: Number(document.getElementById('voltageCheckInterval').value)
warnLowVoltage: Number($('#warningLowVoltage').val()),
indicatorLow: Number($('#voltageIndicatorLow').val()),
indicatorHi: Number($('#voltageIndicatorHigh').val()),
criticalVoltage: Number($('#criticalVoltage').val()),
voltageCheckInterval: Number($('#voltageCheckInterval').val())
},
"playlist": {
sortMode: Number(document.getElementById('playlistSortMode').value)
sortMode: Number($('#playlistSortMode').val())
}
};
var myJSON = JSON.stringify(myObj);
Expand Down
Loading

0 comments on commit 8323438

Please sign in to comment.