work_board.c (2974B)
1 /* Copyright 2021 Drashna Jael're 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 17 #include "quantum.h" 18 19 #ifdef OLED_ENABLE 20 # ifdef RGB_MATRIX_ENABLE 21 # error Cannot run OLED and Per Key RGB at the same time due to pin conflicts 22 # endif 23 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { 24 return OLED_ROTATION_90; 25 } 26 27 bool oled_task_kb(void) { 28 if (!oled_task_user()) { 29 return false; 30 } 31 oled_write_P(PSTR("LAYER"), false); 32 oled_write_P(PSTR("Lower"), layer_state_is(3)); 33 oled_write_P(PSTR("Raise"), layer_state_is(4)); 34 oled_write_P(PSTR("Adjst"), layer_state_is(5)); 35 36 led_t led_usb_state = host_keyboard_led_state(); 37 oled_write_P(PSTR("Lock:"), false); 38 oled_write_P(PSTR(" "), false); 39 oled_write_P(PSTR("N"), led_usb_state.num_lock); 40 oled_write_P(PSTR("C"), led_usb_state.caps_lock); 41 oled_write_ln_P(PSTR("S"), led_usb_state.scroll_lock); 42 43 uint8_t modifiers = get_mods() | get_oneshot_mods(); 44 oled_write_P(PSTR("Mods:"), false); 45 oled_write_P(PSTR(" "), false); 46 oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT)); 47 oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL)); 48 oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT)); 49 oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI)); 50 51 /* Show Ctrl-Gui Swap options */ 52 static const char PROGMEM logo[][2][3] = { 53 {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}, 54 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, 55 }; 56 oled_write_P(PSTR("BTMGK"), false); 57 oled_write_P(PSTR(" "), false); 58 oled_write_P(logo[0][0], !keymap_config.swap_lctl_lgui); 59 oled_write_P(logo[1][0], keymap_config.swap_lctl_lgui); 60 oled_write_P(PSTR(" "), false); 61 oled_write_P(logo[0][1], !keymap_config.swap_lctl_lgui); 62 oled_write_P(logo[1][1], keymap_config.swap_lctl_lgui); 63 oled_write_P(PSTR(" NKRO"), keymap_config.nkro); 64 65 return false; 66 } 67 #endif 68 69 #ifdef RGB_MATRIX_ENABLE 70 bool rgb_matrix_indicators_kb(void) { 71 if (!rgb_matrix_indicators_user()) { 72 return false; 73 } 74 rgb_matrix_set_color(5, 0, 0, 0); 75 rgb_matrix_set_color(7, 0, 0, 0); 76 return true; 77 } 78 79 void keyboard_pre_init_kb(void) { 80 gpio_set_pin_output(B2); 81 gpio_set_pin_output(B3); 82 gpio_set_pin_output(B7); 83 84 gpio_write_pin_low(B2); 85 gpio_write_pin_low(B3); 86 gpio_write_pin_low(B7); 87 88 keyboard_pre_init_user(); 89 } 90 91 #endif