diff options
author | Jack Humbert <jack.humb@gmail.com> | 2018-07-19 23:57:13 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-07-20 23:09:25 -0400 |
commit | 1572375bfbdb231c3373a6300fbb7e2ca195d9be (patch) | |
tree | 19d93ab71ae5a5f5a19609a8b0fa32142463e666 /keyboards/preonic/keymaps/default/keymap.c | |
parent | 0284431ad935b05fad212fb3925e8104007ab93f (diff) | |
download | firmware-1572375bfbdb231c3373a6300fbb7e2ca195d9be.tar.gz firmware-1572375bfbdb231c3373a6300fbb7e2ca195d9be.tar.bz2 firmware-1572375bfbdb231c3373a6300fbb7e2ca195d9be.zip |
adds support for preonic rev 3
Diffstat (limited to 'keyboards/preonic/keymaps/default/keymap.c')
-rw-r--r-- | keyboards/preonic/keymaps/default/keymap.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/keyboards/preonic/keymaps/default/keymap.c b/keyboards/preonic/keymaps/default/keymap.c index de3eb2298..33ca90f99 100644 --- a/keyboards/preonic/keymaps/default/keymap.c +++ b/keyboards/preonic/keymaps/default/keymap.c @@ -15,6 +15,7 @@ */ #include QMK_KEYBOARD_H +#include "muse.h" enum preonic_layers { _QWERTY, @@ -211,13 +212,96 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { #ifdef BACKLIGHT_ENABLE backlight_step(); #endif + #ifdef __AVR__ PORTE &= ~(1<<6); + #endif } else { unregister_code(KC_RSFT); + #ifdef __AVR__ PORTE |= (1<<6); + #endif } return false; break; } return true; }; + +bool muse_mode = false; +uint8_t last_muse_note = 0; +uint16_t muse_counter = 0; +uint8_t muse_offset = 70; +uint16_t muse_tempo = 50; + +void encoder_update(bool clockwise) { + if (muse_mode) { + if (IS_LAYER_ON(_RAISE)) { + if (clockwise) { + muse_offset++; + } else { + muse_offset--; + } + } else { + if (clockwise) { + muse_tempo+=1; + } else { + muse_tempo-=1; + } + } + } else { + if (clockwise) { + register_code(KC_PGDN); + unregister_code(KC_PGDN); + } else { + register_code(KC_PGUP); + unregister_code(KC_PGUP); + } + } +} + +void dip_update(uint8_t index, bool active) { + switch (index) { + case 0: + if (active) { + layer_on(_ADJUST); + } else { + layer_off(_ADJUST); + } + break; + case 1: + if (active) { + muse_mode = true; + } else { + muse_mode = false; + #ifdef AUDIO_ENABLE + stop_all_notes(); + #endif + } + } +} + +void matrix_scan_user(void) { + #ifdef AUDIO_ENABLE + if (muse_mode) { + if (muse_counter == 0) { + uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()]; + if (muse_note != last_muse_note) { + stop_note(compute_freq_for_midi_note(last_muse_note)); + play_note(compute_freq_for_midi_note(muse_note), 0xF); + last_muse_note = muse_note; + } + } + muse_counter = (muse_counter + 1) % muse_tempo; + } + #endif +} + +bool music_mask_user(uint16_t keycode) { + switch (keycode) { + case RAISE: + case LOWER: + return false; + default: + return true; + } +} |