[Keyboard] Fix default keymaps for OLKB boards to play Startup Sound (#6721)

* Fix Planck default keymap to play sounds on rev6

The dip_switch_update callback was overriding the default startup sound.  This should prevent that from happening, and still allow it to play sounds, or stop them, when appropriate.

* Fix Preonic default keymap to play sounds on Rev 3

The dip_switch_update callback was overriding the default startup sound.  This should prevent that from happening, and still allow it to play sounds, or stop them, when appropriate.
This commit is contained in:
Drashna Jaelre 2019-09-14 19:59:44 -07:00 committed by GitHub
parent 265d8abee1
commit 6c871408df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 62 deletions

View File

@ -290,46 +290,51 @@ void encoder_update(bool clockwise) {
} }
void dip_switch_update_user(uint8_t index, bool active) { void dip_switch_update_user(uint8_t index, bool active) {
switch (index) { switch (index) {
case 0: case 0: {
if (active) { static bool play_sound = false;
#ifdef AUDIO_ENABLE if (active) {
PLAY_SONG(plover_song); #ifdef AUDIO_ENABLE
#endif if (play_sound) { PLAY_SONG(plover_song); }
layer_on(_ADJUST); #endif
} else { layer_on(_ADJUST);
#ifdef AUDIO_ENABLE } else {
PLAY_SONG(plover_gb_song); #ifdef AUDIO_ENABLE
#endif if (play_sound) { PLAY_SONG(plover_gb_song); }
layer_off(_ADJUST); #endif
} layer_off(_ADJUST);
break; }
case 1: play_sound = true;
if (active) { break;
muse_mode = true; }
} else { case 1:
muse_mode = false; if (active) {
#ifdef AUDIO_ENABLE muse_mode = true;
stop_all_notes(); } else {
#endif muse_mode = false;
} }
} }
} }
void matrix_scan_user(void) { void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
if (muse_mode) { if (muse_mode) {
if (muse_counter == 0) { if (muse_counter == 0) {
uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()]; uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
if (muse_note != last_muse_note) { if (muse_note != last_muse_note) {
stop_note(compute_freq_for_midi_note(last_muse_note)); stop_note(compute_freq_for_midi_note(last_muse_note));
play_note(compute_freq_for_midi_note(muse_note), 0xF); play_note(compute_freq_for_midi_note(muse_note), 0xF);
last_muse_note = muse_note; last_muse_note = muse_note;
}
}
muse_counter = (muse_counter + 1) % muse_tempo;
} else {
if (muse_counter) {
stop_all_notes();
muse_counter = 0;
} }
}
muse_counter = (muse_counter + 1) % muse_tempo;
} }
#endif #endif
} }
bool music_mask_user(uint16_t keycode) { bool music_mask_user(uint16_t keycode) {

View File

@ -260,40 +260,43 @@ void encoder_update_user(uint8_t index, bool clockwise) {
} }
void dip_switch_update_user(uint8_t index, bool active) { void dip_switch_update_user(uint8_t index, bool active) {
switch (index) { switch (index) {
case 0: case 0:
if (active) { if (active) {
layer_on(_ADJUST); layer_on(_ADJUST);
} else { } else {
layer_off(_ADJUST); layer_off(_ADJUST);
} }
break; break;
case 1: case 1:
if (active) { if (active) {
muse_mode = true; muse_mode = true;
} else { } else {
muse_mode = false; muse_mode = false;
#ifdef AUDIO_ENABLE }
stop_all_notes(); xs}
#endif
}
}
} }
void matrix_scan_user(void) { void matrix_scan_user(void) {
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
if (muse_mode) { if (muse_mode) {
if (muse_counter == 0) { if (muse_counter == 0) {
uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()]; uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
if (muse_note != last_muse_note) { if (muse_note != last_muse_note) {
stop_note(compute_freq_for_midi_note(last_muse_note)); stop_note(compute_freq_for_midi_note(last_muse_note));
play_note(compute_freq_for_midi_note(muse_note), 0xF); play_note(compute_freq_for_midi_note(muse_note), 0xF);
last_muse_note = muse_note; last_muse_note = muse_note;
}
}
muse_counter = (muse_counter + 1) % muse_tempo;
} else {
if (muse_counter) {
stop_all_notes();
muse_counter = 0;
} }
}
muse_counter = (muse_counter + 1) % muse_tempo;
} }
#endif #endif
} }
bool music_mask_user(uint16_t keycode) { bool music_mask_user(uint16_t keycode) {