qmk_firmware/users/drashna/bootmagic_better.c
Drashna Jaelre 4a87af0e9a
[Keymap] Drashna updates for 0.19 (#19175)
* Fix up bastardkb boards since blackpill support is officially added.
  * Check for blackpill version, not elite c.
  * Add checks in chibiOS config since multiple ARM controllers supported.
  * Rework rules.mk for keymaps to better handle arm vs avr support
* Start moving away from `matrix_*_*` functions.
  * `housekeeping_task_*` instead of `matrix_scan_*`
  * `keyboard_(pre|post)_init_*` instead of `matrix_init_*` 
* Add ℂℴmⅈℂ unicode input method.
* Clean up unicode code to be more compact and flexible.
* Remove/move Pro Micro LED commands to userspace and better filter them
* Fixup OLED code
  * Use newer quantum keycode functions/preprocessors rather than manual bit manipulation
  * Make unicode mode render much more compact/simple.
* Make qmk secrets more self contained
* Remove custom implementation of split watchdog
2022-11-29 11:43:42 -08:00

56 lines
1.9 KiB
C

// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "drashna.h"
#include "bootmagic_lite.h"
void bootmagic_lite(void) {
bool perform_reset = false;
// We need multiple scans because debouncing can't be turned off.
matrix_scan();
#if defined(DEBOUNCE) && DEBOUNCE > 0
wait_ms(DEBOUNCE * 2);
#else
wait_ms(30);
#endif
matrix_scan();
// If the configured key (commonly Esc) is held down on power up,
// reset the EEPROM valid state and jump to bootloader.
// This isn't very generalized, but we need something that doesn't
// rely on user's keymaps in firmware or EEPROM.
uint8_t row = BOOTMAGIC_LITE_ROW, col = BOOTMAGIC_LITE_COLUMN;
#if defined(BOOTMAGIC_LITE_EEPROM_ROW) && defined(BOOTMAGIC_LITE_EEPROM_COLUMN)
uint8_t row_e = BOOTMAGIC_LITE_EEPROM_ROW, col_e = BOOTMAGIC_LITE_EEPROM_COLUMN;
#endif
#if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT)
if (!is_keyboard_left()) {
row = BOOTMAGIC_LITE_ROW_RIGHT;
col = BOOTMAGIC_LITE_COLUMN_RIGHT;
#if defined(BOOTMAGIC_LITE_EEPROM_ROW) && defined(BOOTMAGIC_LITE_EEPROM_COLUMN) && defined(BOOTMAGIC_LITE_EEPROM_ROW_RIGHT) && defined(BOOTMAGIC_LITE_EEPROM_COLUMN_RIGHT)
row_e = BOOTMAGIC_LITE_EEPROM_ROW_RIGHT;
col_e = BOOTMAGIC_LITE_EEPROM_COLUMN_RIGHT;
# endif
}
#endif
#if defined(BOOTMAGIC_LITE_EEPROM_ROW) && defined(BOOTMAGIC_LITE_EEPROM_COLUMN)
if (matrix_get_row(row_e) & (1 << col_e)) {
eeconfig_disable();
perform_reset = true;
}
#endif
if (matrix_get_row(row) & (1 << col)) {
perform_reset = true;
}
#if defined(STM32F411xE) && !defined(CONVERTER_ENABLED)
if (!readPin(A0)) {
perform_reset = true;
}
#endif
if (perform_reset) {
bootloader_jump();
}
}