From 4ffcacd92086870eb7a3102d54178a7af64edb0c Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 27 Oct 2018 11:53:50 -0700 Subject: Add Bootmagic Lite to QMK (#4215) * Preliminary additon of bootmagic lite functionality * Cleanup code * Clean up bootmagic code * Add documentation and clean up code * Make 'lite' an option for BOOTMAGIC_ENABLE * Update Templates with note about Bootmagic Lite option * Detect Debounce variable * Make sure debounce is a non-zero number * Capitalize Bootmagic * Capitalize bootmagic * Update wording * Re-add EEPROM reset, by popular demand And add eeprom-less version to drashna userspace for his sanity * Fix spacing * Set BOOTMAGIC_ENABLE to use full/lite/off And default yes to "full" for compatibility * Add Bootmagic lite info to templates * Remove text from makefiles * Cleanup of makefile * mention yes in bootmagic docs * Wordsmitthing the docs * Fix white spaces * Readd default bootmagic setting, because it's necessary --- quantum/quantum.c | 34 +++++++++++++++++++++++++++++++++- quantum/quantum.h | 9 +++++++++ quantum/template/avr/config.h | 3 +++ quantum/template/ps2avrgb/config.h | 4 ++++ 4 files changed, 49 insertions(+), 1 deletion(-) (limited to 'quantum') diff --git a/quantum/quantum.c b/quantum/quantum.c index c9bec6740b..5f1a691c88 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -949,8 +949,40 @@ void tap_random_base64(void) { } } +__attribute__((weak)) +void bootmagic_lite(void) { + // The lite version of TMK's bootmagic based on Wilba. + // 100% less potential for accidentally making the + // keyboard do stupid things. + + // We need multiple scans because debouncing can't be turned off. + matrix_scan(); + #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 + wait_ms(DEBOUNCING_DELAY * 2); + #elif defined(DEBOUNCE) && DEBOUNCE > 0 + wait_ms(DEBOUNCE * 2); + #else + wait_ms(30); + #endif + matrix_scan(); + + // If the Esc and space bar are held down on power up, + // reset the EEPROM valid state and jump to bootloader. + // Assumes Esc is at [0,0]. + // This isn't very generalized, but we need something that doesn't + // rely on user's keymaps in firmware or EEPROM. + if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { + eeconfig_disable(); + // Jump to bootloader. + bootloader_jump(); + } +} + void matrix_init_quantum() { - if (!eeconfig_is_enabled() && !eeconfig_is_disabled()) { + #ifdef BOOTMAGIC_LITE + bootmagic_lite(); + #endif + if (!eeconfig_is_enabled()) { eeconfig_init(); } #ifdef BACKLIGHT_ENABLE diff --git a/quantum/quantum.h b/quantum/quantum.h index 87a61356c7..1d3ee033fd 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -224,6 +224,15 @@ bool process_action_kb(keyrecord_t *record); bool process_record_kb(uint16_t keycode, keyrecord_t *record); bool process_record_user(uint16_t keycode, keyrecord_t *record); +#ifndef BOOTMAGIC_LITE_COLUMN + #define BOOTMAGIC_LITE_COLUMN 0 +#endif +#ifndef BOOTMAGIC_LITE_ROW + #define BOOTMAGIC_LITE_ROW 0 +#endif + +void bootmagic_lite(void); + void reset_keyboard(void); void startup_user(void); diff --git a/quantum/template/avr/config.h b/quantum/template/avr/config.h index caa72af0c2..56395f376f 100644 --- a/quantum/template/avr/config.h +++ b/quantum/template/avr/config.h @@ -222,3 +222,6 @@ along with this program. If not, see . #endif */ +/* Bootmagic Lite key configuration */ +// #define BOOTMAGIC_LITE_ROW 0 +// #define BOOTMAGIC_LITE_COLUMN 0 diff --git a/quantum/template/ps2avrgb/config.h b/quantum/template/ps2avrgb/config.h index d2c83781fa..4ff3513bc7 100644 --- a/quantum/template/ps2avrgb/config.h +++ b/quantum/template/ps2avrgb/config.h @@ -44,3 +44,7 @@ along with this program. If not, see . /* key combination for command */ #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + +/* Bootmagic Lite key configuration */ +// #define BOOTMAGIC_LITE_ROW 0 +// #define BOOTMAGIC_LITE_COLUMN 0 -- cgit v1.2.3