rev2.c (2678B)
1 /* Copyright 2020 Harrison Chan (Xelus) 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 // Tested and verified working on ext65rev2 20 void matrix_io_delay(void) { 21 __asm__ volatile("nop\nnop\nnop\n"); 22 } 23 24 #ifdef OLED_ENABLE 25 void board_init(void) { 26 SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP; 27 SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP); 28 } 29 30 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { 31 return OLED_ROTATION_90; // rotates the display 90 degrees 32 } 33 34 void render_layer_state(void) { 35 oled_write_ln(PSTR("LAYER"), false); 36 oled_write_ln(PSTR("L1"), layer_state_is(1)); 37 oled_write_ln(PSTR("L2"), layer_state_is(2)); 38 oled_write_ln(PSTR("L3"), layer_state_is(3)); 39 oled_write_ln(PSTR(" "), false); 40 } 41 42 void render_keylock_status(led_t led_state) { 43 oled_write_ln(PSTR("Lock:"), false); 44 oled_write(PSTR("N"), led_state.num_lock); 45 oled_write(PSTR("C"), led_state.caps_lock); 46 oled_write_ln(PSTR("S"), led_state.scroll_lock); 47 oled_write_ln(PSTR(" "), false); 48 } 49 50 void render_mod_status(uint8_t modifiers) { 51 oled_write_ln(PSTR("Mods:"), false); 52 oled_write(PSTR("S"), (modifiers & MOD_MASK_SHIFT)); 53 oled_write(PSTR("C"), (modifiers & MOD_MASK_CTRL)); 54 oled_write(PSTR("A"), (modifiers & MOD_MASK_ALT)); 55 oled_write_ln(PSTR("G"), (modifiers & MOD_MASK_GUI)); 56 oled_write_ln(PSTR(" "), false); 57 } 58 59 bool oled_task_kb(void) { 60 if (!oled_task_user()) { 61 return false; 62 } 63 render_layer_state(); 64 render_keylock_status(host_keyboard_led_state()); 65 render_mod_status(get_mods() | get_oneshot_mods()); 66 return true; 67 } 68 69 #else 70 71 void keyboard_pre_init_kb(void) { 72 gpio_set_pin_output(A14); 73 74 keyboard_pre_init_user(); 75 } 76 77 layer_state_t layer_state_set_kb(layer_state_t state) { 78 switch (get_highest_layer(state)) { 79 case 1: 80 gpio_write_pin_high(A14); 81 break; 82 default: // for any other layers, or the default layer 83 gpio_write_pin_low(A14); 84 break; 85 } 86 return layer_state_set_user(state); 87 } 88 #endif