refactor: easier to read
This commit is contained in:
parent
3176ada2d2
commit
4ccfeb2abd
1 changed files with 6 additions and 4 deletions
|
@ -72,19 +72,21 @@ int activity_event_listener(const zmk_event_t *eh) {
|
||||||
void activity_work_handler(struct k_work *work) {
|
void activity_work_handler(struct k_work *work) {
|
||||||
int32_t current = k_uptime_get();
|
int32_t current = k_uptime_get();
|
||||||
int32_t inactive_time = current - activity_last_uptime;
|
int32_t inactive_time = current - activity_last_uptime;
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_ZMK_SLEEP)
|
#if IS_ENABLED(CONFIG_ZMK_SLEEP)
|
||||||
if (inactive_time > MAX_SLEEP_MS && !is_usb_power_present()
|
bool prevent_sleep = is_usb_power_present();
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_ZMK_NO_SLEEP_WHILE_BLE_CONNECTED)
|
#if IS_ENABLED(CONFIG_ZMK_NO_SLEEP_WHILE_BLE_CONNECTED)
|
||||||
/* if user inactive and USB is not connected,
|
/* if user inactive and USB is not connected,
|
||||||
* keyboard will sleep as soon as BLE is disconnected
|
* keyboard will sleep as soon as BLE is disconnected
|
||||||
*/
|
*/
|
||||||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
#if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
||||||
&& !zmk_ble_active_profile_is_connected()
|
prevent_sleep = prevent_sleep || zmk_ble_active_profile_is_connected();
|
||||||
#else
|
#else
|
||||||
&& !zmk_split_bt_peripheral_is_connected()
|
prevent_sleep = prevent_sleep || zmk_split_bt_peripheral_is_connected();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
) {
|
if (inactive_time > MAX_SLEEP_MX && !prevent_sleep) {
|
||||||
// Put devices in suspend power mode before sleeping
|
// Put devices in suspend power mode before sleeping
|
||||||
set_state(ZMK_ACTIVITY_SLEEP);
|
set_state(ZMK_ACTIVITY_SLEEP);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue