v1.c (2641B)
1 /* Copyright 2018 Yiancar 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 "quantum.h" 17 18 #ifndef DEBOUNCE 19 # define DEBOUNCE 5 20 #endif 21 22 void bootmagic_lite(void) 23 { 24 // The lite version of TMK's bootmagic made by Wilba. 25 // 100% less potential for accidentally making the 26 // keyboard do stupid things. 27 28 // We need multiple scans because debouncing can't be turned off. 29 matrix_scan(); 30 wait_ms(DEBOUNCE); 31 matrix_scan(); 32 33 // If the Esc and space bar are held down on power up, 34 // reset the EEPROM valid state and jump to bootloader. 35 // Assumes Esc is at [0,0] and spacebar is at [4,6]. 36 // This isn't very generalized, but we need something that doesn't 37 // rely on user's keymaps in firmware or EEPROM. 38 if ( ( matrix_get_row(0) & (1<<0) ) && 39 ( matrix_get_row(4) & (1<<6) ) ) 40 { 41 // Set the TMK/QMK EEPROM state as invalid. 42 eeconfig_disable(); 43 //eeprom_set_valid(false); 44 // Jump to bootloader. 45 bootloader_jump(); 46 } 47 } 48 49 void matrix_init_kb(void) { 50 // put your keyboard start-up code here 51 // runs once when the firmware starts up 52 53 bootmagic_lite(); 54 55 // Please ignore this is for upcoming features 56 // If the EEPROM has the magic, the data is good. 57 // OK to load from EEPROM. 58 /*if (eeprom_is_valid()) 59 { 60 backlight_config_load(); 61 62 // TODO: do something to "turn on" keymaps in EEPROM? 63 } 64 else 65 { 66 // If the EEPROM has not been saved before, or is out of date, 67 // save the default values to the EEPROM. Default values 68 // come from construction of the zeal_backlight_config instance. 69 backlight_config_save(); 70 71 // Clear the LED colors stored in EEPROM 72 for ( int row=0; row < MATRIX_ROWS; row++ ) 73 { 74 hsv_t hsv; 75 for ( int column=0; column < MATRIX_COLS; column++ ) 76 { 77 hsv.h = rand() & 0xFF; 78 hsv.s = rand() & 0x7F; 79 hsv.v = 255; 80 backlight_set_key_color( row, column, hsv ); 81 } 82 } 83 #ifdef USE_KEYMAPS_IN_EEPROM 84 keymap_default_save(); 85 #endif 86 // Save the magic number last, in case saving was interrupted 87 eeprom_set_valid(true); 88 }*/ 89 90 matrix_init_user(); 91 }