Remove redundant audio eeconfig init (#22736)
This commit is contained in:
parent
b824faca71
commit
b24bd2351a
6 changed files with 42 additions and 17 deletions
|
@ -17,6 +17,7 @@
|
|||
#include "audio.h"
|
||||
#include "eeconfig.h"
|
||||
#include "timer.h"
|
||||
#include "debug.h"
|
||||
#include "wait.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -62,6 +63,13 @@
|
|||
* the internal state of the audio system does its calculations with the later - ms
|
||||
*/
|
||||
|
||||
#ifndef AUDIO_DEFAULT_ON
|
||||
# define AUDIO_DEFAULT_ON true
|
||||
#endif
|
||||
#ifndef AUDIO_DEFAULT_CLICKY_ON
|
||||
# define AUDIO_DEFAULT_CLICKY_ON true
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_TONE_STACKSIZE
|
||||
# define AUDIO_TONE_STACKSIZE 8
|
||||
#endif
|
||||
|
@ -117,32 +125,31 @@ void eeconfig_update_audio_current(void) {
|
|||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
void eeconfig_update_audio_default(void) {
|
||||
audio_config.valid = true;
|
||||
audio_config.enable = AUDIO_DEFAULT_ON;
|
||||
audio_config.clicky_enable = AUDIO_DEFAULT_CLICKY_ON;
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
void audio_init(void) {
|
||||
if (audio_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check EEPROM
|
||||
#ifdef EEPROM_ENABLE
|
||||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
audio_config.raw = eeconfig_read_audio();
|
||||
#else // EEPROM settings
|
||||
audio_config.enable = true;
|
||||
# ifdef AUDIO_CLICKY_ON
|
||||
audio_config.clicky_enable = true;
|
||||
# endif
|
||||
#endif // EEPROM settings
|
||||
if (!audio_config.valid) {
|
||||
dprintf("audio_init audio_config.valid = 0. Write default values to EEPROM.\n");
|
||||
eeconfig_update_audio_default();
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < AUDIO_TONE_STACKSIZE; i++) {
|
||||
tones[i] = (musical_tone_t){.time_started = 0, .pitch = -1.0f, .duration = 0};
|
||||
}
|
||||
|
||||
if (!audio_initialized) {
|
||||
audio_driver_initialize();
|
||||
audio_initialized = true;
|
||||
}
|
||||
audio_driver_initialize();
|
||||
audio_initialized = true;
|
||||
|
||||
stop_all_notes();
|
||||
#ifndef AUDIO_INIT_DELAY
|
||||
audio_startup();
|
||||
|
|
|
@ -33,7 +33,8 @@ typedef union {
|
|||
struct {
|
||||
bool enable : 1;
|
||||
bool clicky_enable : 1;
|
||||
uint8_t level : 6;
|
||||
bool valid : 1;
|
||||
uint8_t reserved : 5;
|
||||
};
|
||||
} audio_config_t;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void eeconfig_init_quantum(void) {
|
|||
// Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000
|
||||
eeprom_update_word(EECONFIG_KEYMAP, 0x1400);
|
||||
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
|
||||
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
|
||||
eeprom_update_byte(EECONFIG_AUDIO, 0);
|
||||
eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
|
||||
eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0);
|
||||
eeprom_update_byte(EECONFIG_UNUSED, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue