logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

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