diff options
| author | ishtob <ishtob@gmail.com> | 2018-12-04 11:04:57 -0500 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-12-04 08:04:57 -0800 |
| commit | 4099536c0e7a099b181a80e483b4b95f389b5a7e (patch) | |
| tree | 311c8a15013cce5ee9275fe8654c9b52dc9ca1e2 /keyboards/hadron/ver2/keymaps/default/keymap.c | |
| parent | 4bb28d2df092408a7a0e32a8d8ab47b7f4008fcd (diff) | |
| download | qmk_firmware-4099536c0e7a099b181a80e483b4b95f389b5a7e.tar.gz qmk_firmware-4099536c0e7a099b181a80e483b4b95f389b5a7e.zip | |
adding Hadron v3 keyboard, QWIIC devices support, haptic feedback support (#4462)
* add initial support for hadron ver3
* add initial support for hadron ver3
* pull qwiic support for micro_led to be modified for use in hadron's 64x24 ssd1306 oled display
* initial work on OLED using qwiic driver
* early work to get 128x32 oled working by redefining qwiic micro oled parameters. Currently working, but would affect qwiic's micro oled functionality
* moved oled defines to config.h and added ifndef to micro_oled driver
* WORKING :D - note, still work in progress to get the start location correct on the 128x32 display.
* added equation to automatically calculate display offset based on screen width
* adding time-out timer to oled display
* changed read lock staus via read_led_state
* lock indications fixes
* Added scroll lock indication to oled
* add support for DRV2605 haptic driver
* Improve readabiity of DRV2605 driver.
-added typedef for waveform library
-added unions for registers
* Update keyboards/hadron/ver2/keymaps/default/config.h
Co-Authored-By: ishtob <ishtob@gmail.com>
* Update keyboards/hadron/ver2/keymaps/default/config.h
Co-Authored-By: ishtob <ishtob@gmail.com>
* Update keyboards/hadron/ver2/keymaps/default/config.h
Co-Authored-By: ishtob <ishtob@gmail.com>
* Update keyboards/hadron/ver2/keymaps/default/config.h
Co-Authored-By: ishtob <ishtob@gmail.com>
* Fixes for PR
* PR fixes
* fix old persistent layer function to use new set_single_persistent_default_layer
* fix issues with changing makefile defines that broken per-key haptic pulse
* Comment fixes
* Add definable parameter and auto-calibration based on motor choice
Diffstat (limited to 'keyboards/hadron/ver2/keymaps/default/keymap.c')
| -rw-r--r-- | keyboards/hadron/ver2/keymaps/default/keymap.c | 448 |
1 files changed, 448 insertions, 0 deletions
diff --git a/keyboards/hadron/ver2/keymaps/default/keymap.c b/keyboards/hadron/ver2/keymaps/default/keymap.c new file mode 100644 index 000000000..cc79f5267 --- /dev/null +++ b/keyboards/hadron/ver2/keymaps/default/keymap.c | |||
| @@ -0,0 +1,448 @@ | |||
| 1 | #include QMK_KEYBOARD_H | ||
| 2 | #ifdef AUDIO_ENABLE | ||
| 3 | #include "audio.h" | ||
| 4 | #endif | ||
| 5 | #ifdef USE_I2C | ||
| 6 | #include "i2c.h" | ||
| 7 | #endif | ||
| 8 | #ifdef SSD1306OLED | ||
| 9 | #include "ssd1306.h" | ||
| 10 | #endif | ||
| 11 | extern keymap_config_t keymap_config; | ||
| 12 | |||
| 13 | //Following line allows macro to read current RGB settings | ||
| 14 | extern rgblight_config_t rgblight_config; | ||
| 15 | |||
| 16 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
| 17 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
| 18 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
| 19 | // entirely and just use numbers. | ||
| 20 | #define _QWERTY 0 | ||
| 21 | #define _COLEMAK 1 | ||
| 22 | #define _DVORAK 2 | ||
| 23 | #define _LOWER 3 | ||
| 24 | #define _RAISE 4 | ||
| 25 | #define _MOUSECURSOR 8 | ||
| 26 | #define _ADJUST 16 | ||
| 27 | |||
| 28 | enum preonic_keycodes { | ||
| 29 | QWERTY = SAFE_RANGE, | ||
| 30 | COLEMAK, | ||
| 31 | DVORAK, | ||
| 32 | LOWER, | ||
| 33 | RAISE, | ||
| 34 | BACKLIT, | ||
| 35 | RGBLED_TOGGLE, | ||
| 36 | RGBLED_STEP_MODE, | ||
| 37 | RGBLED_INCREASE_HUE, | ||
| 38 | RGBLED_DECREASE_HUE, | ||
| 39 | RGBLED_INCREASE_SAT, | ||
| 40 | RGBLED_DECREASE_SAT, | ||
| 41 | RGBLED_INCREASE_VAL, | ||
| 42 | RGBLED_DECREASE_VAL, | ||
| 43 | }; | ||
| 44 | |||
| 45 | enum macro_keycodes { | ||
| 46 | KC_DEMOMACRO, | ||
| 47 | }; | ||
| 48 | |||
| 49 | // Fillers to make layering more clear | ||
| 50 | #define _______ KC_TRNS | ||
| 51 | #define XXXXXXX KC_NO | ||
| 52 | // Custom macros | ||
| 53 | #define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl | ||
| 54 | #define CTL_TTAB CTL_T(KC_TAB) // Tap for Esc, hold for Ctrl | ||
| 55 | #define CTL_ENT CTL_T(KC_ENT) // Tap for Enter, hold for Ctrl | ||
| 56 | #define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift | ||
| 57 | // Requires KC_TRNS/_______ for the trigger key in the destination layer | ||
| 58 | #define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor | ||
| 59 | #define LT_RAI(kc) LT(_RAISE, kc) // L-ayer T-ap to Raise | ||
| 60 | #define DEMOMACRO M(KC_DEMOMACRO) // Sample for macros | ||
| 61 | |||
| 62 | |||
| 63 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 64 | |||
| 65 | /* Qwerty | ||
| 66 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 67 | * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | DEL | | ||
| 68 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 69 | * | Tab | Q | W | E | R | T | 7 | 8 | 9 | Y | U | I | O | P | Bksp | | ||
| 70 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 71 | * | CAPS | A | S | D | F | G | 4 | 5 | 6 | H | J | K | L | ;/Nav| ' | | ||
| 72 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 73 | * | Shift| Z | X | C | V | B | 1 | 2 | 3 | N | M | , | . | / |Ctl/Et| | ||
| 74 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 75 | * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right | | ||
| 76 | * `--------------------------------------------------------------------------------------------------------' | ||
| 77 | */ | ||
| 78 | [_QWERTY] = LAYOUT( | ||
| 79 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\ | ||
| 80 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_P7, KC_P8, KC_P9, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
| 81 | KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_P4, KC_P5, KC_P6, KC_H, KC_J, KC_K, KC_L,LT_MC(KC_SCLN), KC_QUOT, \ | ||
| 82 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, CTL_ENT, \ | ||
| 83 | KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT,KC_DOWN, KC_UP, KC_RGHT \ | ||
| 84 | ), | ||
| 85 | |||
| 86 | /* Colemak | ||
| 87 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 88 | * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | 0 | - | | ||
| 89 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 90 | * | Tab | Q | W | F | P | G | 7 | 8 | 9 | J | L | U | Y | ; | Bksp | | ||
| 91 | * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------| | ||
| 92 | * | CAPS | A | R | S | T | D | 4 | 5 | 6 | H | N | E | I | O | ' | | ||
| 93 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 94 | * | Shift| Z | X | C | V | B | 1 | 2 | 3 | K | M | , | . | / |Ctl/Et| | ||
| 95 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 96 | * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right | | ||
| 97 | * `--------------------------------------------------------------------------------------------------------' | ||
| 98 | */ | ||
| 99 | [_COLEMAK] = LAYOUT( | ||
| 100 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\ | ||
| 101 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_P7, KC_P8, KC_P9, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
| 102 | KC_LCTRL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_P4, KC_P5, KC_P6, KC_H, KC_N, KC_E, KC_I, LT_MC(KC_O), KC_QUOT, \ | ||
| 103 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, CTL_ENT, \ | ||
| 104 | KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 105 | ), | ||
| 106 | |||
| 107 | /* Dvorak | ||
| 108 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 109 | * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | | ||
| 110 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 111 | * | Tab | " | , | . | P | Y | 7 | 8 | 9 | F | G | C | R | L | Bksp | | ||
| 112 | * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------| | ||
| 113 | * | Esc | A | O | E | U | I | 4 | 5 | 6 | D | H | T | N | S | / | | ||
| 114 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 115 | * | Shift| ; | Q | J | K | X | 1 | 2 | 3 | B | M | W | V | Z |Ctl/Et| | ||
| 116 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 117 | * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right | | ||
| 118 | * `--------------------------------------------------------------------------------------------------------' | ||
| 119 | */ | ||
| 120 | [_DVORAK] = LAYOUT( | ||
| 121 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\ | ||
| 122 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_P7, KC_P8, KC_P9, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \ | ||
| 123 | KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_P4, KC_P5, KC_P6, KC_D, KC_H, KC_T, KC_N, LT_MC(KC_S), KC_SLSH, \ | ||
| 124 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_P1, KC_P2, KC_P3, KC_B, KC_M, KC_W, KC_V, KC_Z, CTL_ENT, \ | ||
| 125 | KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 126 | ), | ||
| 127 | |||
| 128 | /* Lower | ||
| 129 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 130 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
| 131 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 132 | * | ~ | ! | @ | # | $ | % | | | | ^ | & | * | ( | ) | Del | | ||
| 133 | * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------| | ||
| 134 | * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | _ | + | { | } | | | | ||
| 135 | * |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------| | ||
| 136 | * | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO ~ |ISO | | | | | | ||
| 137 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 138 | * | | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 139 | * `--------------------------------------------------------------------------------------------------------' | ||
| 140 | */ | ||
| 141 | [_LOWER] = LAYOUT( | ||
| 142 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
| 143 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \ | ||
| 144 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_PIPE, \ | ||
| 145 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12,S(KC_NUHS),S(KC_NUBS),_______,_______, _______, \ | ||
| 146 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 147 | ), | ||
| 148 | |||
| 149 | /* Raise | ||
| 150 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 151 | * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | | ||
| 152 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 153 | * | ` | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | Del | | ||
| 154 | * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------| | ||
| 155 | * | Del | F1 | F2 | F3 | F4 | F5 | | | | F6 | - | = | [ | ] | \ | | ||
| 156 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 157 | * | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO # |ISO / | | | | | ||
| 158 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 159 | * | | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 160 | * `--------------------------------------------------------------------------------------------------------' | ||
| 161 | */ | ||
| 162 | [_RAISE] = LAYOUT( | ||
| 163 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
| 164 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
| 165 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
| 166 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \ | ||
| 167 | _______, _______, _______, _______, _______, KC_SPC, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 168 | ), | ||
| 169 | |||
| 170 | /* Mouse Layer (semi-col) | ||
| 171 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 172 | * | ACCL0| ACCL1| ACCL2| | | | | | | | | | | ||
| 173 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 174 | * | | | | | | | | | Home | Wh_Up| WHL_L| M_Up | WHL_R| Macro| | | ||
| 175 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 176 | * | | | | | | | | | End | Wh_Dn| M_Lft| M_Dn | M_Rt | | | | ||
| 177 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 178 | * | | | | | | | | | | BTN2 | BTN3 | BTN4 | BTN5 | | | | ||
| 179 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 180 | * | | | | | | BTN1 | | | | BTN1 | | | | | | | ||
| 181 | * `--------------------------------------------------------------------------------------------------------' | ||
| 182 | */ | ||
| 183 | |||
| 184 | [_MOUSECURSOR] = LAYOUT( | ||
| 185 | KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
| 186 | _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R,DEMOMACRO,_______, \ | ||
| 187 | _______, _______, _______, _______, _______, _______, _______, _______, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, \ | ||
| 188 | _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, \ | ||
| 189 | _______, _______, _______, _______, _______, KC_BTN1, _______, _______, _______, KC_BTN1, _______, _______, _______, _______, _______ \ | ||
| 190 | ), | ||
| 191 | |||
| 192 | /* Adjust (Lower + Raise) | ||
| 193 | * ,------+------+------+------+------+------------------------------------------------. | ||
| 194 | * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | | ||
| 195 | * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------. | ||
| 196 | * | Reset|RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +| | | | | | Del | | ||
| 197 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 198 | * | | | |Aud on|Audoff|AGnorm| | | |AGswap|Qwerty|Colemk| | | | | ||
| 199 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 200 | * | |Voice-|Voice+|Mus on|Musoff| | | | | | | | BL + |BL ST |BL TG | | ||
| 201 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 202 | * | | | | | | | | | | | | | | | | | ||
| 203 | * `--------------------------------------------------------------------------------------------------------' | ||
| 204 | */ | ||
| 205 | [_ADJUST] = LAYOUT( | ||
| 206 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ | ||
| 207 | RESET, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, KC_DEL, \ | ||
| 208 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, _______, _______, _______, AG_SWAP, QWERTY, COLEMAK, _______, _______, _______, \ | ||
| 209 | _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, BL_DEC, BL_INC, BL_STEP, BL_TOGG, \ | ||
| 210 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______\ | ||
| 211 | ) | ||
| 212 | |||
| 213 | |||
| 214 | |||
| 215 | }; | ||
| 216 | |||
| 217 | // define variables for reactive RGB | ||
| 218 | bool RGB_INIT = false; | ||
| 219 | bool TOG_STATUS = false; | ||
| 220 | int RGB_current_mode; | ||
| 221 | |||
| 222 | void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { | ||
| 223 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { | ||
| 224 | rgblight_mode(RGB_current_mode); | ||
| 225 | layer_on(layer3); | ||
| 226 | } else { | ||
| 227 | layer_off(layer3); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 232 | switch (keycode) { | ||
| 233 | case QWERTY: | ||
| 234 | if (record->event.pressed) { | ||
| 235 | set_single_persistent_default_layer(_QWERTY); | ||
| 236 | } | ||
| 237 | return false; | ||
| 238 | break; | ||
| 239 | case COLEMAK: | ||
| 240 | if (record->event.pressed) { | ||
| 241 | set_single_persistent_default_layer(_COLEMAK); | ||
| 242 | } | ||
| 243 | return false; | ||
| 244 | break; | ||
| 245 | case LOWER: | ||
| 246 | if (record->event.pressed) { | ||
| 247 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
| 248 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
| 249 | if (RGB_INIT) {} else { | ||
| 250 | RGB_current_mode = rgblight_config.mode; | ||
| 251 | RGB_INIT = true; | ||
| 252 | } | ||
| 253 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
| 254 | } else { | ||
| 255 | TOG_STATUS = !TOG_STATUS; | ||
| 256 | rgblight_mode(16); | ||
| 257 | } | ||
| 258 | layer_on(_LOWER); | ||
| 259 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 260 | } else { | ||
| 261 | rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
| 262 | TOG_STATUS = false; | ||
| 263 | layer_off(_LOWER); | ||
| 264 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 265 | } | ||
| 266 | return false; | ||
| 267 | break; | ||
| 268 | case RAISE: | ||
| 269 | if (record->event.pressed) { | ||
| 270 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
| 271 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
| 272 | if (RGB_INIT) {} else { | ||
| 273 | RGB_current_mode = rgblight_config.mode; | ||
| 274 | RGB_INIT = true; | ||
| 275 | } | ||
| 276 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
| 277 | } else { | ||
| 278 | TOG_STATUS = !TOG_STATUS; | ||
| 279 | rgblight_mode(15); | ||
| 280 | } | ||
| 281 | layer_on(_RAISE); | ||
| 282 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 283 | } else { | ||
| 284 | rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
| 285 | layer_off(_RAISE); | ||
| 286 | TOG_STATUS = false; | ||
| 287 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 288 | } | ||
| 289 | return false; | ||
| 290 | break; | ||
| 291 | case BACKLIT: | ||
| 292 | if (record->event.pressed) { | ||
| 293 | register_code(KC_RSFT); | ||
| 294 | #ifdef BACKLIGHT_ENABLE | ||
| 295 | backlight_step(); | ||
| 296 | #endif | ||
| 297 | } else { | ||
| 298 | unregister_code(KC_RSFT); | ||
| 299 | } | ||
| 300 | return false; | ||
| 301 | break; | ||
| 302 | case RGB_MOD: | ||
| 303 | //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released | ||
| 304 | if (record->event.pressed) { | ||
| 305 | rgblight_mode(RGB_current_mode); | ||
| 306 | rgblight_step(); | ||
| 307 | RGB_current_mode = rgblight_config.mode; | ||
| 308 | } | ||
| 309 | return false; | ||
| 310 | break; | ||
| 311 | } | ||
| 312 | return true; | ||
| 313 | } | ||
| 314 | |||
| 315 | |||
| 316 | |||
| 317 | /* | ||
| 318 | * Macro definition | ||
| 319 | */ | ||
| 320 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 321 | { | ||
| 322 | if (!eeconfig_is_enabled()) { | ||
| 323 | eeconfig_init(); | ||
| 324 | } | ||
| 325 | |||
| 326 | switch (id) { | ||
| 327 | case KC_DEMOMACRO: | ||
| 328 | if (record->event.pressed){ | ||
| 329 | return MACRO (I(1), T(H),T(E),T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D), END); | ||
| 330 | } | ||
| 331 | } | ||
| 332 | |||
| 333 | return MACRO_NONE; | ||
| 334 | } | ||
| 335 | |||
| 336 | |||
| 337 | //Functions for ver2 | ||
| 338 | #ifdef KEYBOARD_hadron_ver2 | ||
| 339 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
| 340 | void matrix_init_user(void) { | ||
| 341 | #ifdef USE_I2C | ||
| 342 | i2c_master_init(); | ||
| 343 | #ifdef SSD1306OLED | ||
| 344 | // calls code for the SSD1306 OLED | ||
| 345 | _delay_ms(400); | ||
| 346 | TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); | ||
| 347 | iota_gfx_init(); // turns on the display | ||
| 348 | #endif | ||
| 349 | #endif | ||
| 350 | #ifdef AUDIO_ENABLE | ||
| 351 | startup_user(); | ||
| 352 | #endif | ||
| 353 | } | ||
| 354 | |||
| 355 | |||
| 356 | void matrix_scan_user(void) { | ||
| 357 | #ifdef SSD1306OLED | ||
| 358 | iota_gfx_task(); // this is what updates the display continuously | ||
| 359 | #endif | ||
| 360 | } | ||
| 361 | |||
| 362 | void matrix_update(struct CharacterMatrix *dest, | ||
| 363 | const struct CharacterMatrix *source) { | ||
| 364 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
| 365 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
| 366 | dest->dirty = true; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | //assign the right code to your layers for OLED display | ||
| 370 | #define L_BASE 0 | ||
| 371 | #define L_LOWER 8 | ||
| 372 | #define L_RAISE 16 | ||
| 373 | #define L_FNLAYER 64 | ||
| 374 | #define L_NUMLAY 128 | ||
| 375 | #define L_NLOWER 136 | ||
| 376 | #define L_NFNLAYER 192 | ||
| 377 | #define L_MOUSECURSOR 256 | ||
| 378 | #define L_ADJUST 65560 | ||
| 379 | |||
| 380 | void iota_gfx_task_user(void) { | ||
| 381 | #if DEBUG_TO_SCREEN | ||
| 382 | if (debug_enable) { | ||
| 383 | return; | ||
| 384 | } | ||
| 385 | #endif | ||
| 386 | |||
| 387 | struct CharacterMatrix matrix; | ||
| 388 | |||
| 389 | matrix_clear(&matrix); | ||
| 390 | matrix_write_P(&matrix, PSTR("USB: ")); | ||
| 391 | #ifdef PROTOCOL_LUFA | ||
| 392 | switch (USB_DeviceState) { | ||
| 393 | case DEVICE_STATE_Unattached: | ||
| 394 | matrix_write_P(&matrix, PSTR("Unattached")); | ||
| 395 | break; | ||
| 396 | case DEVICE_STATE_Suspended: | ||
| 397 | matrix_write_P(&matrix, PSTR("Suspended")); | ||
| 398 | break; | ||
| 399 | case DEVICE_STATE_Configured: | ||
| 400 | matrix_write_P(&matrix, PSTR("Connected")); | ||
| 401 | break; | ||
| 402 | case DEVICE_STATE_Powered: | ||
| 403 | matrix_write_P(&matrix, PSTR("Powered")); | ||
| 404 | break; | ||
| 405 | case DEVICE_STATE_Default: | ||
| 406 | matrix_write_P(&matrix, PSTR("Default")); | ||
| 407 | break; | ||
| 408 | case DEVICE_STATE_Addressed: | ||
| 409 | matrix_write_P(&matrix, PSTR("Addressed")); | ||
| 410 | break; | ||
| 411 | default: | ||
| 412 | matrix_write_P(&matrix, PSTR("Invalid")); | ||
| 413 | } | ||
| 414 | #endif | ||
| 415 | |||
| 416 | // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below | ||
| 417 | |||
| 418 | char buf[40]; | ||
| 419 | snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); | ||
| 420 | matrix_write_P(&matrix, PSTR("\n\nLayer: ")); | ||
| 421 | switch (layer_state) { | ||
| 422 | case L_BASE: | ||
| 423 | matrix_write_P(&matrix, PSTR("Default")); | ||
| 424 | break; | ||
| 425 | case L_RAISE: | ||
| 426 | matrix_write_P(&matrix, PSTR("Raise")); | ||
| 427 | break; | ||
| 428 | case L_LOWER: | ||
| 429 | matrix_write_P(&matrix, PSTR("Lower")); | ||
| 430 | break; | ||
| 431 | case L_ADJUST: | ||
| 432 | matrix_write_P(&matrix, PSTR("ADJUST")); | ||
| 433 | break; | ||
| 434 | default: | ||
| 435 | matrix_write(&matrix, buf); | ||
| 436 | } | ||
| 437 | |||
| 438 | // Host Keyboard LED Status | ||
| 439 | char led[40]; | ||
| 440 | snprintf(led, sizeof(led), "\n%s %s %s", | ||
| 441 | (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", | ||
| 442 | (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", | ||
| 443 | (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); | ||
| 444 | matrix_write(&matrix, led); | ||
| 445 | matrix_update(&display, &matrix); | ||
| 446 | } | ||
| 447 | |||
| 448 | #endif \ No newline at end of file | ||
