aboutsummaryrefslogtreecommitdiff
path: root/quantum/bootmagic/bootmagic_lite.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/bootmagic/bootmagic_lite.c')
-rw-r--r--quantum/bootmagic/bootmagic_lite.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/quantum/bootmagic/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c
new file mode 100644
index 000000000..9cbdcb0bb
--- /dev/null
+++ b/quantum/bootmagic/bootmagic_lite.c
@@ -0,0 +1,66 @@
1/* Copyright 2021 QMK
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 3 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/** \brief Reset eeprom
19 *
20 * ...just incase someone wants to only change the eeprom behaviour
21 */
22__attribute__((weak)) void bootmagic_lite_reset_eeprom(void) {
23#if defined(VIA_ENABLE)
24 via_eeprom_reset();
25#else
26 eeconfig_disable();
27#endif
28}
29
30/** \brief The lite version of TMK's bootmagic based on Wilba.
31 *
32 * 100% less potential for accidentally making the keyboard do stupid things.
33 */
34__attribute__((weak)) void bootmagic_lite(void) {
35 // We need multiple scans because debouncing can't be turned off.
36 matrix_scan();
37#if defined(DEBOUNCE) && DEBOUNCE > 0
38 wait_ms(DEBOUNCE * 2);
39#else
40 wait_ms(30);
41#endif
42 matrix_scan();
43
44 // If the configured key (commonly Esc) is held down on power up,
45 // reset the EEPROM valid state and jump to bootloader.
46 // This isn't very generalized, but we need something that doesn't
47 // rely on user's keymaps in firmware or EEPROM.
48 uint8_t row = BOOTMAGIC_LITE_ROW;
49 uint8_t col = BOOTMAGIC_LITE_COLUMN;
50
51#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT)
52 if (!is_keyboard_left()) {
53 row = BOOTMAGIC_LITE_ROW_RIGHT;
54 col = BOOTMAGIC_LITE_COLUMN_RIGHT;
55 }
56#endif
57
58 if (matrix_get_row(row) & (1 << col)) {
59 bootmagic_lite_reset_eeprom();
60
61 // Jump to bootloader.
62 bootloader_jump();
63 }
64}
65
66void bootmagic(void) { bootmagic_lite(); }