Move shutdown delay to audio feature (#25859)
This commit is contained in:
parent
c1b8b3dc6a
commit
10faca0b85
|
|
@ -71,6 +71,10 @@
|
||||||
# define AUDIO_DEFAULT_CLICKY_ON true
|
# define AUDIO_DEFAULT_CLICKY_ON true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef AUDIO_SHUTDOWN_DELAY
|
||||||
|
# define AUDIO_SHUTDOWN_DELAY 250
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef AUDIO_TONE_STACKSIZE
|
#ifndef AUDIO_TONE_STACKSIZE
|
||||||
# define AUDIO_TONE_STACKSIZE 8
|
# define AUDIO_TONE_STACKSIZE 8
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -114,9 +118,14 @@ extern uint16_t voices_timer;
|
||||||
#ifndef AUDIO_OFF_SONG
|
#ifndef AUDIO_OFF_SONG
|
||||||
# define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
|
# define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GOODBYE_SONG
|
||||||
|
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
|
||||||
|
#endif
|
||||||
|
|
||||||
float startup_song[][2] = STARTUP_SONG;
|
float startup_song[][2] = STARTUP_SONG;
|
||||||
float audio_on_song[][2] = AUDIO_ON_SONG;
|
float audio_on_song[][2] = AUDIO_ON_SONG;
|
||||||
float audio_off_song[][2] = AUDIO_OFF_SONG;
|
float audio_off_song[][2] = AUDIO_OFF_SONG;
|
||||||
|
float goodbye_song[][2] = GOODBYE_SONG;
|
||||||
|
|
||||||
static bool audio_initialized = false;
|
static bool audio_initialized = false;
|
||||||
static bool audio_driver_stopped = true;
|
static bool audio_driver_stopped = true;
|
||||||
|
|
@ -210,6 +219,18 @@ void audio_startup(void) {
|
||||||
last_timestamp = timer_read();
|
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) {
|
void audio_toggle(void) {
|
||||||
if (audio_config.enable) {
|
if (audio_config.enable) {
|
||||||
stop_all_notes();
|
stop_all_notes();
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,8 @@ uint16_t audio_ms_to_duration(uint16_t duration_ms);
|
||||||
|
|
||||||
void audio_startup(void);
|
void audio_startup(void);
|
||||||
|
|
||||||
|
void audio_shutdown(void);
|
||||||
|
|
||||||
// hardware interface
|
// hardware interface
|
||||||
|
|
||||||
// implementation in the driver_avr/arm_* respective parts
|
// implementation in the driver_avr/arm_* respective parts
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AUDIO_ENABLE
|
#ifdef AUDIO_ENABLE
|
||||||
# ifndef GOODBYE_SONG
|
|
||||||
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
|
|
||||||
# endif
|
|
||||||
float goodbye_song[][2] = GOODBYE_SONG;
|
|
||||||
# ifdef DEFAULT_LAYER_SONGS
|
# ifdef DEFAULT_LAYER_SONGS
|
||||||
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
|
float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -218,18 +214,16 @@ void shutdown_quantum(bool jump_to_bootloader) {
|
||||||
# ifndef NO_MUSIC_MODE
|
# ifndef NO_MUSIC_MODE
|
||||||
music_all_notes_off();
|
music_all_notes_off();
|
||||||
# endif
|
# endif
|
||||||
uint16_t timer_start = timer_read();
|
audio_shutdown();
|
||||||
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);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
shutdown_modules(jump_to_bootloader);
|
||||||
|
shutdown_kb(jump_to_bootloader);
|
||||||
|
|
||||||
|
#if SHUTDOWN_DELAY > 0
|
||||||
|
wait_ms(SHUTDOWN_DELAY);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAPTIC_ENABLE
|
#ifdef HAPTIC_ENABLE
|
||||||
haptic_shutdown();
|
haptic_shutdown();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue