mirror of
https://github.com/jmwtsn/qmk_firmware.git
synced 2026-06-03 19:53:31 -03:00
Move shutdown delay to audio feature (#25859)
This commit is contained in:
@@ -71,6 +71,10 @@
|
||||
# define AUDIO_DEFAULT_CLICKY_ON true
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_SHUTDOWN_DELAY
|
||||
# define AUDIO_SHUTDOWN_DELAY 250
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_TONE_STACKSIZE
|
||||
# define AUDIO_TONE_STACKSIZE 8
|
||||
#endif
|
||||
@@ -114,9 +118,14 @@ extern uint16_t voices_timer;
|
||||
#ifndef AUDIO_OFF_SONG
|
||||
# define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
|
||||
#endif
|
||||
#ifndef GOODBYE_SONG
|
||||
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
|
||||
#endif
|
||||
|
||||
float startup_song[][2] = STARTUP_SONG;
|
||||
float audio_on_song[][2] = AUDIO_ON_SONG;
|
||||
float audio_off_song[][2] = AUDIO_OFF_SONG;
|
||||
float goodbye_song[][2] = GOODBYE_SONG;
|
||||
|
||||
static bool audio_initialized = false;
|
||||
static bool audio_driver_stopped = true;
|
||||
@@ -210,6 +219,18 @@ void audio_startup(void) {
|
||||
last_timestamp = timer_read();
|
||||
}
|
||||
|
||||
void audio_shutdown(void) {
|
||||
uint16_t timer_start = timer_read();
|
||||
|
||||
PLAY_SONG(goodbye_song);
|
||||
|
||||
while (timer_elapsed(timer_start) < AUDIO_SHUTDOWN_DELAY) {
|
||||
wait_ms(1);
|
||||
}
|
||||
|
||||
stop_all_notes();
|
||||
}
|
||||
|
||||
void audio_toggle(void) {
|
||||
if (audio_config.enable) {
|
||||
stop_all_notes();
|
||||
|
||||
@@ -218,6 +218,8 @@ uint16_t audio_ms_to_duration(uint16_t duration_ms);
|
||||
|
||||
void audio_startup(void);
|
||||
|
||||
void audio_shutdown(void);
|
||||
|
||||
// hardware interface
|
||||
|
||||
// implementation in the driver_avr/arm_* respective parts
|
||||
|
||||
+9
-15
@@ -94,10 +94,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
# ifndef GOODBYE_SONG
|
||||
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
|
||||
# endif
|
||||
float goodbye_song[][2] = GOODBYE_SONG;
|
||||
# ifdef DEFAULT_LAYER_SONGS
|
||||
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
|
||||
# endif
|
||||
@@ -218,18 +214,16 @@ void shutdown_quantum(bool jump_to_bootloader) {
|
||||
# ifndef NO_MUSIC_MODE
|
||||
music_all_notes_off();
|
||||
# endif
|
||||
uint16_t timer_start = timer_read();
|
||||
PLAY_SONG(goodbye_song);
|
||||
shutdown_modules(jump_to_bootloader);
|
||||
shutdown_kb(jump_to_bootloader);
|
||||
while (timer_elapsed(timer_start) < 250)
|
||||
wait_ms(1);
|
||||
stop_all_notes();
|
||||
#else
|
||||
shutdown_modules(jump_to_bootloader);
|
||||
shutdown_kb(jump_to_bootloader);
|
||||
wait_ms(250);
|
||||
audio_shutdown();
|
||||
#endif
|
||||
|
||||
shutdown_modules(jump_to_bootloader);
|
||||
shutdown_kb(jump_to_bootloader);
|
||||
|
||||
#if SHUTDOWN_DELAY > 0
|
||||
wait_ms(SHUTDOWN_DELAY);
|
||||
#endif
|
||||
|
||||
#ifdef HAPTIC_ENABLE
|
||||
haptic_shutdown();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user