1 #include QMK_KEYBOARD_H
4 #include "split_util.h"
7 #include "common/ssd1306.h"
10 extern keymap_config_t keymap_config;
12 #ifdef RGBLIGHT_ENABLE
13 //Following line allows macro to read current RGB settings
14 extern rgblight_config_t rgblight_config;
17 extern uint8_t is_master;
19 // Each layer gets a name for readability, which is then used in the keymap matrix below.
20 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
21 // Layer names don't all need to be of the same length, obviously, and you can also skip them
22 // entirely and just use numbers.
30 enum custom_keycodes {
45 #define FN_ESC LT(_FN, KC_ESC)
46 #define FN_CAPS LT(_FN, KC_CAPS)
47 // Define your non-alpha grouping in this define's LAYOUT, and all your BASE_LAYERS will share the same mod/macro columns
49 #define BASE_LAYOUT( \
50 _00, _01, _02, _03, _04, \
51 _10, _11, _12, _13, _14, \
52 _20, _21, _22, _23, _24, \
53 _30, _31, _32, _33, _34 \
56 KC_GESC, _00, _01, _02, _03, _04, \
57 KC_TAB, _10, _11, _12, _13, _14, \
58 FN_CAPS, _20, _21, _22, _23, _24, \
59 KC_LSFT, _30, _31, _32, _33, _34, \
60 KC_LCTL, KC_LGUI, KC_LALT, RGB_TOG, ADJ, KC_SPC \
63 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
64 [_QWERTY] = BASE_LAYOUT( \
65 KC_1, KC_2, KC_3, KC_4, KC_5, \
66 KC_Q, KC_W, KC_E, KC_R, KC_T, \
67 KC_A, KC_S, KC_D, KC_F, KC_G, \
68 KC_Z, KC_X, KC_C, KC_V, KC_B \
71 [_MACROPAD] = BASE_LAYOUT( \
72 KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, \
73 KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, \
74 KC_A, KC_S, KC_D, KC_F, KC_G, \
75 KC_Z, KC_X, KC_C, KC_V, KC_B \
78 [_FN] = LAYOUT_ortho_5x6( \
79 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \
80 _______, KC_PGDN, KC_UP, KC_PGUP, _______, _______, \
81 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, \
82 _______, _______, _______, _______, _______, _______, \
83 _______, _______, _______, RGB_MOD, _______, _______ \
86 [_ADJ] = LAYOUT_ortho_5x6( \
87 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, \
88 _______, RGB_SAD, RGB_VAI, RGB_SAI, RESET, _______, \
89 _______, RGB_HUD, RGB_VAD, RGB_HUI, RGBRST, _______, \
90 _______, _______, _______, _______, _______, _______, \
91 _______, _______, _______, RGB_MOD, _______, _______ \
95 // define variables for reactive RGB
96 bool TOG_STATUS = false;
99 // Setting ADJ layer RGB back to default
100 void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
101 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
102 #ifdef RGBLIGHT_ENABLE
103 //rgblight_mode(RGB_current_mode);
111 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
112 //uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
116 if (record->event.pressed) {
117 set_single_persistent_default_layer(_QWERTY);
122 if(record->event.pressed) {
123 set_single_persistent_default_layer(_MACROPAD);
128 if (record->event.pressed) {
129 //not sure how to have keyboard check mode and set it to a variable, so my work around
130 //uses another variable that would be set to true after the first time a reactive key is pressed.
131 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
133 TOG_STATUS = !TOG_STATUS;
134 #ifdef RGBLIGHT_ENABLE
140 #ifdef RGBLIGHT_ENABLE
141 //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
149 if (record->event.pressed) {
156 //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
158 #ifdef RGBLIGHT_ENABLE
159 if (record->event.pressed) {
160 eeconfig_update_rgblight_default();
162 RGB_current_mode = rgblight_config.mode;
170 void matrix_init_user(void) {
171 #ifdef RGBLIGHT_ENABLE
172 RGB_current_mode = rgblight_config.mode;
174 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
176 iota_gfx_init(!has_usb()); // turns on the display
181 //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
184 // hook point for 'led_test' keymap
185 // 'default' keymap's led_test_init() is empty function, do nothing
186 // 'led_test' keymap's led_test_init() force rgblight_mode_noeeprom(35);
187 __attribute__ ((weak))
188 void led_test_init(void) {}
190 void matrix_scan_user(void) {
192 iota_gfx_task(); // this is what updates the display continuously
195 void matrix_update(struct CharacterMatrix *dest,
196 const struct CharacterMatrix *source) {
197 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
198 memcpy(dest->display, source->display, sizeof(dest->display));
203 //assign the right code to your layers for OLED display
205 #define L_FN (1<<_FN)
206 #define L_ADJ (1<<_ADJ)
208 static void render_logo(struct CharacterMatrix *matrix) {
211 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
212 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
213 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
215 matrix_write(matrix, logo);
216 //matrix_write_P(&matrix, PSTR(" Split keyboard kit"));
221 void render_status(struct CharacterMatrix *matrix) {
223 // Render to mode icon
224 static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
225 if(keymap_config.swap_lalt_lgui==false){
226 matrix_write(matrix, logo[0][0]);
227 matrix_write_P(matrix, PSTR("\n"));
228 matrix_write(matrix, logo[0][1]);
230 matrix_write(matrix, logo[1][0]);
231 matrix_write_P(matrix, PSTR("\n"));
232 matrix_write(matrix, logo[1][1]);
235 // 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
237 snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
238 matrix_write_P(matrix, PSTR("\nLayer: "));
239 switch (layer_state) {
241 matrix_write_P(matrix, PSTR("Default"));
244 matrix_write_P(matrix, PSTR("FN"));
248 matrix_write_P(matrix, PSTR("ADJ"));
251 matrix_write(matrix, buf);
254 // Host Keyboard LED Status
256 snprintf(led, sizeof(led), "\n%s %s %s",
257 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
258 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
259 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
260 matrix_write(matrix, led);
264 void iota_gfx_task_user(void) {
265 struct CharacterMatrix matrix;
273 matrix_clear(&matrix);
275 render_status(&matrix);
277 render_logo(&matrix);
279 matrix_update(&display, &matrix);