1
0
Fork 0

add audio on/off audios

This commit is contained in:
Jack Humbert 2017-09-06 12:37:57 -04:00
parent 4d5eeb3d7d
commit 994592f985
2 changed files with 57 additions and 36 deletions

View file

@ -23,6 +23,7 @@
#include "print.h"
#include "audio.h"
#include "keymap.h"
#include "wait.h"
#include "eeconfig.h"
@ -122,14 +123,19 @@ bool glissando = true;
#ifndef STARTUP_SONG
#define STARTUP_SONG SONG(STARTUP_SOUND)
#endif
#ifndef AUDIO_ON_SONG
#define AUDIO_ON_SONG SONG(AUDIO_ON_SOUND)
#endif
#ifndef AUDIO_OFF_SONG
#define AUDIO_OFF_SONG SONG(AUDIO_OFF_SOUND)
#endif
float startup_song[][2] = STARTUP_SONG;
float audio_on_song[][2] = AUDIO_ON_SONG;
float audio_off_song[][2] = AUDIO_OFF_SONG;
void audio_init()
{
if (audio_initialized)
return;
// Check EEPROM
if (!eeconfig_is_enabled())
{
@ -137,6 +143,8 @@ void audio_init()
}
audio_config.raw = eeconfig_read_audio();
if (!audio_initialized) {
// Set port PC6 (OC3A and /OC4A) as output
#ifdef C6_AUDIO
@ -177,6 +185,7 @@ void audio_init()
#endif
audio_initialized = true;
}
if (audio_config.enable) {
PLAY_SONG(startup_song);
@ -720,9 +729,13 @@ void audio_on(void) {
audio_config.enable = 1;
eeconfig_update_audio(audio_config.raw);
audio_on_user();
PLAY_SONG(audio_on_song);
}
void audio_off(void) {
PLAY_SONG(audio_off_song);
wait_ms(100);
stop_all_notes();
audio_config.enable = 0;
eeconfig_update_audio(audio_config.raw);
}

View file

@ -127,6 +127,14 @@
E__NOTE(_GS6), \
E__NOTE(_A6 ),
#define AUDIO_ON_SOUND \
E__NOTE(_A5 ), \
E__NOTE(_A6 ),
#define AUDIO_OFF_SOUND \
E__NOTE(_A6 ), \
E__NOTE(_A5 ),
#define MUSIC_SCALE_SOUND MUSIC_ON_SOUND
#define MUSIC_OFF_SOUND \