1 #include QMK_KEYBOARD_H
2 #include "LUFA/Drivers/Peripheral/TWI.h"
7 extern keymap_config_t keymap_config;
9 //Following line allows macro to read current RGB settings
10 extern rgblight_config_t rgblight_config;
13 // Each layer gets a name for readability, which is then used in the keymap matrix below.
14 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
15 // Layer names don't all need to be of the same length, obviously, and you can also skip them
16 // entirely and just use numbers.
24 enum custom_keycodes {
47 #define M_SAMPLE M(KC_SAMPLEMACRO)
49 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
52 * ,-----------------------------------------------------------------------------------.
53 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
54 * |------+------+------+------+------+-------------+------+------+------+------+------|
55 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
56 * |------+------+------+------+------+------|------+------+------+------+------+------|
57 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
58 * |------+------+------+------+------+------+------+------+------+------+------+------|
59 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
60 * `-----------------------------------------------------------------------------------'
63 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
64 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
65 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
66 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
70 * ,-----------------------------------------------------------------------------------.
71 * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
72 * |------+------+------+------+------+-------------+------+------+------+------+------|
73 * | Esc | A | R | S | T | D | H | N | E | I | O | " |
74 * |------+------+------+------+------+------|------+------+------+------+------+------|
75 * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
76 * |------+------+------+------+------+------+------+------+------+------+------+------|
77 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
78 * `-----------------------------------------------------------------------------------'
80 [_COLEMAK] = LAYOUT( \
81 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
82 KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
83 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
84 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
88 * ,-----------------------------------------------------------------------------------.
89 * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
90 * |------+------+------+------+------+-------------+------+------+------+------+------|
91 * | Esc | A | O | E | U | I | D | H | T | N | S | / |
92 * |------+------+------+------+------+------|------+------+------+------+------+------|
93 * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
94 * |------+------+------+------+------+------+------+------+------+------+------+------|
95 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
96 * `-----------------------------------------------------------------------------------'
99 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
100 KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
101 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
102 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
106 * ,-----------------------------------------------------------------------------------.
107 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
108 * |------+------+------+------+------+-------------+------+------+------+------+------|
109 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
110 * |------+------+------+------+------+------|------+------+------+------+------+------|
111 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
112 * |------+------+------+------+------+------+------+------+------+------+------+------|
113 * | | | | | | | | Next | Vol- | Vol+ | Play |
114 * `-----------------------------------------------------------------------------------'
117 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
118 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
119 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
120 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
124 * ,-----------------------------------------------------------------------------------.
125 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
126 * |------+------+------+------+------+-------------+------+------+------+------+------|
127 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
128 * |------+------+------+------+------+------|------+------+------+------+------+------|
129 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
130 * |------+------+------+------+------+------+------+------+------+------+------+------|
131 * | | | | | | | | Next | Vol- | Vol+ | Play |
132 * `-----------------------------------------------------------------------------------'
135 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
136 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
137 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
138 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
141 /* Adjust (Lower + Raise)
142 * ,-----------------------------------------------------------------------------------.
143 * | | Reset| | | | | | | | | | Del |
144 * |------+------+------+------+------+-------------+------+------+------+------+------|
145 * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
146 * |------+------+------+------+------+------|------+------+------+------+------+------|
147 * | | | | | | | | | | | | |
148 * |------+------+------+------+------+------+------+------+------+------+------+------|
149 * | | | | | | | | | | | |
150 * `-----------------------------------------------------------------------------------'
152 [_ADJUST] = LAYOUT( \
153 _______, RESET, _______, M_SAMPLE, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
154 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
155 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
156 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
165 float tone_startup[][2] = SONG(STARTUP_SOUND);
166 float tone_qwerty[][2] = SONG(QWERTY_SOUND);
167 float tone_dvorak[][2] = SONG(DVORAK_SOUND);
168 float tone_colemak[][2] = SONG(COLEMAK_SOUND);
169 float tone_plover[][2] = SONG(PLOVER_SOUND);
170 float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
171 float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
172 float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
175 // define variables for reactive RGB
176 bool TOG_STATUS = false;
177 int RGB_current_mode;
179 void persistent_default_layer_set(uint16_t default_layer) {
180 eeconfig_update_default_layer(default_layer);
181 default_layer_set(default_layer);
184 // Setting ADJUST layer RGB back to default
185 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
186 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
187 rgblight_mode(RGB_current_mode);
194 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
197 if (record->event.pressed) {
199 PLAY_SONG(tone_qwerty);
201 persistent_default_layer_set(1UL<<_QWERTY);
206 if (record->event.pressed) {
208 PLAY_SONG(tone_colemak);
210 persistent_default_layer_set(1UL<<_COLEMAK);
215 if (record->event.pressed) {
217 PLAY_SONG(tone_dvorak);
219 persistent_default_layer_set(1UL<<_DVORAK);
224 if (record->event.pressed) {
225 //not sure how to have keyboard check mode and set it to a variable, so my work around
226 //uses another variable that would be set to true after the first time a reactive key is pressed.
227 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
229 TOG_STATUS = !TOG_STATUS;
233 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
235 rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
238 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
243 if (record->event.pressed) {
244 //not sure how to have keyboard check mode and set it to a variable, so my work around
245 //uses another variable that would be set to true after the first time a reactive key is pressed.
246 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
248 TOG_STATUS = !TOG_STATUS;
252 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
254 rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
257 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
262 if (record->event.pressed) {
263 register_code(KC_RSFT);
264 #ifdef BACKLIGHT_ENABLE
268 unregister_code(KC_RSFT);
272 //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
274 if (record->event.pressed) {
275 rgblight_mode(RGB_current_mode);
277 RGB_current_mode = rgblight_config.mode;
285 void matrix_init_user(void) {
289 RGB_current_mode = rgblight_config.mode;
292 //SSD1306 OLED init and update loop, make sure to add #define SSD1306OLED in config.h
294 void matrix_master_OLED_init (void) {
295 TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
296 iota_gfx_init(); // turns on the display
299 void matrix_scan_user(void) {
300 iota_gfx_task(); // this is what updates the display continuously
308 _delay_ms(20); // gets rid of tick
309 PLAY_SONG(tone_startup);
314 PLAY_SONG(tone_goodbye);
319 void music_on_user(void)
324 void music_scale_user(void)
326 PLAY_SONG(music_scale);
334 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
336 if (!eeconfig_is_enabled()) {
342 if (record->event.pressed){
343 return MACRO (I(10), T(H), T(E), T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D), END);
352 void matrix_update(struct CharacterMatrix *dest,
353 const struct CharacterMatrix *source) {
354 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
355 memcpy(dest->display, source->display, sizeof(dest->display));
360 //assign the right code to your layers for OLED display
367 #define L_NFNLAYER 192
368 #define L_MOUSECURSOR 256
369 #define L_ADJUST 65560
371 void iota_gfx_task_user(void) {
378 struct CharacterMatrix matrix;
380 matrix_clear(&matrix);
381 matrix_write_P(&matrix, PSTR("USB: "));
383 switch (USB_DeviceState) {
384 case DEVICE_STATE_Unattached:
385 matrix_write_P(&matrix, PSTR("Unattached"));
387 case DEVICE_STATE_Suspended:
388 matrix_write_P(&matrix, PSTR("Suspended"));
390 case DEVICE_STATE_Configured:
391 matrix_write_P(&matrix, PSTR("Connected"));
393 case DEVICE_STATE_Powered:
394 matrix_write_P(&matrix, PSTR("Powered"));
396 case DEVICE_STATE_Default:
397 matrix_write_P(&matrix, PSTR("Default"));
399 case DEVICE_STATE_Addressed:
400 matrix_write_P(&matrix, PSTR("Addressed"));
403 matrix_write_P(&matrix, PSTR("Invalid"));
407 // 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
410 snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
411 matrix_write_P(&matrix, PSTR("\n\nLayer: "));
412 switch (layer_state) {
414 matrix_write_P(&matrix, PSTR("Default"));
417 matrix_write_P(&matrix, PSTR("Raise"));
420 matrix_write_P(&matrix, PSTR("Lower"));
423 matrix_write_P(&matrix, PSTR("ADJUST"));
426 matrix_write(&matrix, buf);
429 // Host Keyboard LED Status
431 snprintf(led, sizeof(led), "\n%s %s %s",
432 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
433 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
434 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
435 matrix_write(&matrix, led);
436 matrix_update(&display, &matrix);