Skip to content

Commit

Permalink
Disable deep sleep when charging in wireless
Browse files Browse the repository at this point in the history
The usb port interrupts the MCU and causes the board to wake/sleep repeatedly. I don't have a solution to detect when it stops charging as sleeping the RF module results in board reporting as not charging.
  • Loading branch information
jincao1 committed Apr 13, 2024
1 parent f633762 commit 4cdf28c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions keyboards/nuphy/air75_v2/ansi/customizations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ BT mode key. No indicator for RF as the sidelight is a different colour.
- Light Sleep (NRF off, LED off) - no real reason to use this, but might wake up quicker. Right indicator blinks yellow.
- No Sleep - for those that want their board to always be on... Right indicator blinks red.
- Keyboard will never go to deep sleep in USB mode. This seems to cause issues on wake and I don't have a solution. I'm expecting that the device is powered and if it's not the keyboard would reset anyway.
- Keyboard won't go to deep sleep if charging on wireless mode as charging interrupts the MCU causing it to sleep and wake repeatedly. To restore the proper sleep mode you must wake the board while it's off the charger.

## Fixes

Expand Down
11 changes: 7 additions & 4 deletions keyboards/nuphy/air75_v2/ansi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void deep_sleep_handle(void) {
enter_deep_sleep(); // puts the board in WFI mode and pauses the MCU
exit_deep_sleep(); // This gets called when there is an interrupt (wake) event.

no_act_time = 0; // required to not cause an immediate sleep on first wake
no_act_time = 0; // required to not cause an immediate sleep on first wake
}

/**
Expand All @@ -73,9 +73,12 @@ void sleep_handle(void) {
rf_linking_time = 0;
usb_suspend_debounce = 0;

// Don't deep sleep if in USB mode. Board may have issues waking as reported by others. I assume it's being
// powered if USB port is on, or otherwise it's disconnected at the hardware level if USB port is off..
if (kb_config.sleep_mode != SLEEP_MODE_OFF && dev_info.link_mode == LINK_USB) {
// don't deep sleep if charging on wireless, charging interrupts and wakes the MCU
if (kb_config.sleep_mode != SLEEP_MODE_OFF && dev_info.link_mode < LINK_USB && dev_info.rf_charge & 0x01) {
enter_light_sleep();
// Don't deep sleep if in USB mode. Board may have issues waking as reported by others. I assume it's being
// powered if USB port is on, or otherwise it's disconnected at the hardware level if USB port is off..
} else if (kb_config.sleep_mode != SLEEP_MODE_OFF && dev_info.link_mode == LINK_USB) {
enter_light_sleep();
} else if (kb_config.sleep_mode == SLEEP_MODE_DEEP) {
deep_sleep_handle();
Expand Down

0 comments on commit 4cdf28c

Please sign in to comment.