From ade22f8e2c272044ea2f80ff6fe5ca9576858939 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 16 Jul 2018 11:48:31 -0400 Subject: Adds support for Planck Rev 6 (#2666) * initial files for rev 6 with encoder * music map init, dip scan added * adds ws2812 driver for arm * flesh out dip and encoder support * adds default encoder res * adds default encoder res * start muse implementation * muse working with encoder as control * flip direction * try mouse wheel again * dont break other revs * dont break other revs * conditional autio * pwm ws driver (not working) * update build includes for chibios * update ws2812 driver/config * last commit for glasser code * working example * remove rgb for now * finish up rev6 * working encoder keycodes * add warnings to planck keymaps about the LAYOUT --- quantum/process_keycode/process_audio.c | 4 +--- quantum/process_keycode/process_audio.h | 4 +++- quantum/process_keycode/process_music.c | 31 ++++++++++++++++++++----------- quantum/process_keycode/process_music.h | 5 +++++ 4 files changed, 29 insertions(+), 15 deletions(-) (limited to 'quantum/process_keycode') diff --git a/quantum/process_keycode/process_audio.c b/quantum/process_keycode/process_audio.c index e9b20512e..0a25aa535 100644 --- a/quantum/process_keycode/process_audio.c +++ b/quantum/process_keycode/process_audio.c @@ -10,9 +10,7 @@ float voice_change_song[][2] = VOICE_CHANGE_SONG; #define PITCH_STANDARD_A 440.0f #endif - - -static float compute_freq_for_midi_note(uint8_t note) +float compute_freq_for_midi_note(uint8_t note) { // https://en.wikipedia.org/wiki/MIDI_tuning_standard return pow(2.0, (note - 69) / 12.0) * PITCH_STANDARD_A; diff --git a/quantum/process_keycode/process_audio.h b/quantum/process_keycode/process_audio.h index 7ac15b733..3a84c3d86 100644 --- a/quantum/process_keycode/process_audio.h +++ b/quantum/process_keycode/process_audio.h @@ -1,6 +1,8 @@ #ifndef PROCESS_AUDIO_H #define PROCESS_AUDIO_H +float compute_freq_for_midi_note(uint8_t note); + bool process_audio(uint16_t keycode, keyrecord_t *record); void process_audio_noteon(uint8_t note); void process_audio_noteoff(uint8_t note); @@ -8,4 +10,4 @@ void process_audio_all_notes_off(void); void audio_on_user(void); -#endif \ No newline at end of file +#endif diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 742bb08b1..697aa237f 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c @@ -197,17 +197,26 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { } } - uint8_t note; - if (music_mode == MUSIC_MODE_CHROMATIC) - note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row); - else if (music_mode == MUSIC_MODE_GUITAR) - note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row); - else if (music_mode == MUSIC_MODE_VIOLIN) - note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row); - else if (music_mode == MUSIC_MODE_MAJOR) - note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row); - else - note = music_starting_note; + uint8_t note = 36; + #ifdef MUSIC_MAP + if (music_mode == MUSIC_MODE_CHROMATIC) { + note = music_starting_note + music_offset + 36 + music_map[record->event.key.row][record->event.key.col]; + } else { + uint8_t position = music_map[record->event.key.row][record->event.key.col]; + note = music_starting_note + music_offset + 36 + SCALE[position % 12] + (position / 12)*12; + } + #else + if (music_mode == MUSIC_MODE_CHROMATIC) + note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row); + else if (music_mode == MUSIC_MODE_GUITAR) + note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row); + else if (music_mode == MUSIC_MODE_VIOLIN) + note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row); + else if (music_mode == MUSIC_MODE_MAJOR) + note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row); + else + note = music_starting_note; + #endif if (record->event.pressed) { music_noteon(note); diff --git a/quantum/process_keycode/process_music.h b/quantum/process_keycode/process_music.h index 8ccb7a3a5..f6753d4f2 100644 --- a/quantum/process_keycode/process_music.h +++ b/quantum/process_keycode/process_music.h @@ -29,6 +29,11 @@ enum music_modes { NUMBER_OF_MODES }; + +#ifdef MUSIC_MAP + extern const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS]; +#endif + bool process_music(uint16_t keycode, keyrecord_t *record); bool is_music_on(void); -- cgit v1.2.3-24-g4f1b