Added support for passkey display and passkey confirmation when pairing. Passkey display is enabled automatically when a display is enabled. Passkey confirm can be manually enabled if the keyboard has an Enter key. Updated the passkey entry code to require all 6 digits have been entered before confirming and to support backspace to remove a digit. Added a pairing screen for displays and refactored the display code to allow for switching between multiple screens. The screens are now initialized immediately instead of on the display work queue, because widgets will read state from other files when they are initialized, and this can only be done safely from the system queue. Blank on idle and theme initialization are pulled out to separate files to simplify the main file. The pairing screen supports all three passkey modes: - Passkey display just shows the passkey. - Passkey confirm shows the passkey and an icon indicating that you must press Enter to confirm. - Passkey entry shows the current passkey entry state and shows an icon indicating that you must press Enter to confirm once all 6 digits have been entered. (If passkey display or confirm are supported, it seems that Windows will always choose those over passkey entry, but the pairing screen still supports this in case other OSes work differently.) Added configs for normal and large font sizes. The large font is used for the passkey on the pairing screen on larger displays. CONFIG_LV_FONT_DEFAULT is no longer used for the normal font size, because setting a default value for it in display/Kconfig prevented display shields from picking a more appropriate default.
38 lines
882 B
C
38 lines
882 B
C
/*
|
|
* Copyright (c) 2023 The ZMK Contributors
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <zmk/display.h>
|
|
#include <zmk/event_manager.h>
|
|
#include <zmk/events/activity_state_changed.h>
|
|
|
|
#include <zephyr/logging/log.h>
|
|
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|
|
|
static int display_event_handler(const zmk_event_t *eh) {
|
|
struct zmk_activity_state_changed *ev = as_zmk_activity_state_changed(eh);
|
|
if (!ev) {
|
|
return 0;
|
|
}
|
|
|
|
switch (ev->state) {
|
|
case ZMK_ACTIVITY_ACTIVE:
|
|
zmk_display_blanking_off();
|
|
return 0;
|
|
|
|
case ZMK_ACTIVITY_IDLE:
|
|
case ZMK_ACTIVITY_SLEEP:
|
|
zmk_display_blanking_on();
|
|
return 0;
|
|
|
|
default:
|
|
LOG_WRN("Unhandled activity state: %d", ev->state);
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
ZMK_LISTENER(display_idle, display_event_handler);
|
|
ZMK_SUBSCRIPTION(display_idle, zmk_activity_state_changed);
|