diff --git a/app/Kconfig b/app/Kconfig index 11a2697a3..2b5852cf7 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -691,11 +691,6 @@ config ZMK_KEYMAP_SENSORS_DEFAULT_TRIGGERS_PER_ROTATION endif # ZMK_KEYMAP_SENSORS -choice CBPRINTF_IMPLEMENTATION - default CBPRINTF_NANO - -endchoice - DT_COMPAT_ZMK_BOOT_MAGIC_KEY := zmk,boot-magic-key config ZMK_BOOT_MAGIC_KEY bool "Enable actions when keys are held at boot" diff --git a/app/include/zmk/reset.h b/app/include/zmk/reset.h index fad6db6a4..11a6d214b 100644 --- a/app/include/zmk/reset.h +++ b/app/include/zmk/reset.h @@ -11,9 +11,10 @@ /** * Reboot the system. - * @param type A ZMK_RESET_* value indicating how to reboot. + * @param type If CONFIG_RETENTION_BOOT_MODE is set: A BOOT_MODE_TYPE_* value indicating which type + * of reboot. Otherwise, A ZMK_RESET_* value indicating how to reboot. */ -FUNC_NORETURN void zmk_reset(int type); +void zmk_reset(int type); /** * Clear all persistent settings. diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index f9e4d50ad..6acf91e0f 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -36,24 +36,11 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, const struct device *dev = zmk_behavior_get_binding(binding->behavior_dev); const struct behavior_reset_config *cfg = dev->config; -<<<<<<< HEAD #if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) - int ret = bootmode_set(cfg->boot_mode); - if (ret < 0) { - LOG_ERR("Failed to set the bootloader mode (%d)", ret); - return ZMK_BEHAVIOR_OPAQUE; - } - - sys_reboot(SYS_REBOOT_WARM); + zmk_reset(cfg->boot_mode); #else - // See - // https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 - sys_reboot(cfg->type); -#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ - -======= zmk_reset(cfg->type); ->>>>>>> 1d73fc26 (refactor: Move reset logic to a new function) +#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ return ZMK_BEHAVIOR_OPAQUE; } diff --git a/app/src/boot_magic_key.c b/app/src/boot_magic_key.c index bc29873af..a4b430f4d 100644 --- a/app/src/boot_magic_key.c +++ b/app/src/boot_magic_key.c @@ -17,6 +17,12 @@ #include #include +#if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) + +#include + +#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct boot_key_config { @@ -51,11 +57,19 @@ static void trigger_boot_key(const struct boot_key_config *config) { if (config->jump_to_bootloader) { LOG_INF("Boot key: jumping to bootloader"); +#if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) + zmk_reset(BOOT_MODE_TYPE_BOOTLOADER); +#else zmk_reset(ZMK_RESET_BOOTLOADER); +#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ } else if (config->reset_settings) { // If resetting settings but not jumping to bootloader, we need to reboot // to ensure all subsystems are properly reset. +#if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) + zmk_reset(BOOT_MODE_TYPE_NORMAL); +#else zmk_reset(ZMK_RESET_WARM); +#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ } } diff --git a/app/src/reset.c b/app/src/reset.c index c0fff9871..dbdb52066 100644 --- a/app/src/reset.c +++ b/app/src/reset.c @@ -13,13 +13,27 @@ #endif #include +#if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) + +#include + +#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); // AdaFruit nrf52 Bootloader Specific. See // https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 #define ADAFRUIT_MAGIC_UF2 0x57 -FUNC_NORETURN void zmk_reset(int type) { +void zmk_reset(int type) { +#if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) + int ret = bootmode_set(type); + if (ret < 0) { + LOG_ERR("Failed to set the bootloader mode (%d)", ret); + } else { + sys_reboot(SYS_REBOOT_WARM); + } +#else switch (type) { case ZMK_RESET_WARM: sys_reboot(SYS_REBOOT_WARM); @@ -38,6 +52,7 @@ FUNC_NORETURN void zmk_reset(int type) { LOG_ERR("Unknown reset type %d", type); break; } +#endif /* IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) */ } void zmk_reset_settings(void) { @@ -45,4 +60,4 @@ void zmk_reset_settings(void) { zmk_ble_unpair_all(); #endif // TODO: clear settings for all subsystems. -} \ No newline at end of file +} diff --git a/docs/docs/config/system.md b/docs/docs/config/system.md index 631be86eb..cf55d06fb 100644 --- a/docs/docs/config/system.md +++ b/docs/docs/config/system.md @@ -14,7 +14,7 @@ Definition file: [zmk/app/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/ ### General | Config | Type | Description | Default | -|----------------------------------------|--------|---------------------------------------------------------------------------------------|---------| +| -------------------------------------- | ------ | ------------------------------------------------------------------------------------- | ------- | | `CONFIG_ZMK_KEYBOARD_NAME` | string | The name of the keyboard (max 16 characters) | | | `CONFIG_ZMK_BOOT_MAGIC_KEY_TIMEOUT_MS` | int | Milliseconds to watch for [boot magic keys](../features/boot-magic-key.md) at startup | 500 | | `CONFIG_ZMK_WPM` | bool | Enable calculating words per minute | n | diff --git a/docs/sidebars.js b/docs/sidebars.js index 5fa647fdb..0b81c9c0b 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -1,95 +1,11 @@ module.exports = { - docs: { - "Getting Started": [ - "intro", - "hardware", - "faq", - "user-setup", - "customization", - "troubleshooting", - ], - Features: [ - "features/keymaps", - "features/bluetooth", - "features/boot-magic-key", - "features/combos", - "features/conditional-layers", - "features/debouncing", - "features/displays", - "features/encoders", - "features/underglow", - "features/backlight", - "features/battery", - "features/beta-testing", - ], - Behaviors: [ - "behaviors/key-press", - "behaviors/layers", - "behaviors/misc", - "behaviors/hold-tap", - "behaviors/mod-tap", - "behaviors/mod-morph", - "behaviors/macros", - "behaviors/key-toggle", - "behaviors/sticky-key", - "behaviors/sticky-layer", - "behaviors/tap-dance", - "behaviors/caps-word", - "behaviors/key-repeat", - "behaviors/sensor-rotate", - "behaviors/reset", - "behaviors/bluetooth", - "behaviors/outputs", - "behaviors/underglow", - "behaviors/backlight", - "behaviors/power", - ], - Codes: [ - "codes/index", - "codes/keyboard-keypad", - "codes/modifiers", - "codes/editing", - "codes/media", - "codes/applications", - "codes/input-assist", - "codes/power", - "codes/keymap-upgrader", - ], - Configuration: [ - "config/index", - "config/backlight", - "config/battery", - "config/behaviors", - "config/bluetooth", - "config/combos", - "config/displays", - "config/encoders", - "config/keymap", - "config/kscan", - "config/power", - "config/underglow", - "config/system", - ], - Development: [ - "development/clean-room", - "development/pre-commit", - "development/documentation", - "development/setup", - "development/build-flash", - "development/boards-shields-keymaps", - "development/posix-board", - "development/tests", - "development/usb-logging", - "development/ide-integration", - { - type: "category", - label: "Guides", - collapsed: false, - items: [ - "development/new-shield", - "development/hardware-metadata-files", - "development/new-behavior", - ], + docs: [ + { + type: "category", + label: "Getting Started", + link: { + type: "doc", + id: "intro", }, collapsed: false, items: [