keymap.c (5741B)
1 /* Copyright 2020 plut0nium 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 #include QMK_KEYBOARD_H 17 18 // Defines names for use in layer keycodes and the keymap 19 enum layer_names { 20 _QWERTY, 21 _FN 22 }; 23 24 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 25 /* Base */ 26 [_QWERTY] = LAYOUT( 27 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, 28 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, 29 MO(_FN), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, 30 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PGUP, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, 31 KC_LCTL, KC_LGUI, KC_MENU, KC_LALT, KC_SPC, KC_SPC, KC_PGDN, KC_SPC, KC_SPC, KC_RALT, KC_LBRC, KC_RBRC, KC_RCTL 32 ), 33 [_FN] = LAYOUT( 34 KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL, 35 QK_BOOT, _______, KC_UP, _______, _______, _______, _______, _______, _______, KC_F11, KC_F12, _______, 36 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, 37 _______, UG_HUEU, UG_SATU, UG_VALU, UG_NEXT, _______, KC_END, _______, _______, BL_UP, KC_MPLY, KC_VOLU, KC_MUTE, 38 _______, UG_HUED, UG_SATD, UG_VALD, UG_TOGG, UG_TOGG, KC_HOME, BL_TOGG, BL_TOGG, BL_DOWN, KC_MPRV, KC_VOLD, KC_MNXT 39 ) 40 }; 41 42 #ifdef OLED_ENABLE 43 static void render_logo(void) { 44 static const char PROGMEM my_logo[] = { 45 // '0x3E_logo_32x16', 32x16px 46 0xff, 0x0f, 0x07, 0xf3, 0x73, 0xb3, 0x07, 0x0f, 0xff, 0x3f, 0x3f, 0xff, 0xff, 0x3f, 0x3f, 0xff, 47 0xe7, 0xe3, 0x33, 0x33, 0x03, 0x87, 0xff, 0xff, 0x03, 0x03, 0x33, 0x33, 0x33, 0xf3, 0xff, 0xff, 48 0x7f, 0x78, 0x70, 0x66, 0x67, 0x67, 0x70, 0x78, 0x7f, 0x67, 0x62, 0x78, 0x78, 0x62, 0x67, 0x7f, 49 0x73, 0x63, 0x67, 0x67, 0x60, 0x70, 0x7f, 0x7f, 0x60, 0x60, 0x67, 0x67, 0x67, 0x67, 0x7f, 0x7f 50 }; 51 oled_write_raw_P(my_logo, sizeof(my_logo)); 52 } 53 54 #ifdef RGBLIGHT_ENABLE 55 56 void render_rgb_status(void) { 57 oled_write_ln_P(PSTR("RGB"), false); 58 if (!rgblight_is_enabled()) { 59 oled_write_P(PSTR(" off\n\n\n"), false); 60 } 61 else { 62 static char string[4] = {0}; 63 oled_write_P(PSTR("M:"), false); 64 uint8_t n = rgblight_get_mode(); 65 string[3] = '\0'; 66 string[2] = '0' + n % 10; 67 string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 68 string[0] = n / 10 ? '0' + n / 10 : ' '; 69 oled_write(string, false); 70 71 oled_write_P(PSTR("H:"), false); 72 n = rgblight_get_hue(); 73 string[3] = '\0'; 74 string[2] = '0' + n % 10; 75 string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 76 string[0] = n / 10 ? '0' + n / 10 : ' '; 77 oled_write(string, false); 78 79 oled_write_P(PSTR("S:"), false); 80 n = rgblight_get_sat(); 81 string[3] = '\0'; 82 string[2] = '0' + n % 10; 83 string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 84 string[0] = n / 10 ? '0' + n / 10 : ' '; 85 oled_write(string, false); 86 87 oled_write_P(PSTR("V:"), false); 88 n = rgblight_get_val()/RGBLIGHT_VAL_STEP; 89 string[3] = '\0'; 90 string[2] = '0' + n % 10; 91 string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 92 string[0] = n / 10 ? '0' + n / 10 : ' '; 93 oled_write(string, false); 94 } 95 } 96 #endif 97 98 99 void render_backlight_status(void) { 100 oled_write_ln_P(PSTR("BKL"), false); 101 if (!is_backlight_enabled()) { 102 oled_write_P(PSTR(" off"), false); 103 } 104 else { 105 char string[4]; 106 oled_write_P(PSTR("L:"), false); 107 uint8_t n = get_backlight_level(); 108 string[3] = '\0'; 109 string[2] = '0' + n % 10; 110 string[1] = ( n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' '; 111 string[0] = n / 10 ? '0' + n / 10 : ' '; 112 oled_write(string, false); 113 } 114 } 115 116 oled_rotation_t oled_init_user(oled_rotation_t rotation) { 117 return OLED_ROTATION_270; // flips the display 180 degrees if offhand 118 } 119 120 bool oled_task_user(void) { 121 render_logo(); 122 oled_set_cursor(0,2); // default logo is 16px high (2 lines) 123 124 // Host Keyboard Layer Status 125 oled_write_P(PSTR("Layer"), false); 126 127 switch (get_highest_layer(layer_state)) { 128 case _QWERTY: 129 oled_write_P(PSTR("QWTY\n"), false); 130 break; 131 case _FN: 132 oled_write_P(PSTR("FN\n"), false); 133 break; 134 default: 135 // Or use the write_ln shortcut over adding '\n' to the end of your string 136 oled_write_ln_P(PSTR("Undf"), false); 137 } 138 139 oled_write_P(PSTR("-----"), false); 140 render_backlight_status(); 141 142 // Host Keyboard RGB status 143 #ifdef RGBLIGHT_ENABLE 144 oled_write_P(PSTR("-----"), false); 145 render_rgb_status(); 146 #endif 147 148 return false; 149 } 150 #endif