Skip to content

Commit

Permalink
Prevent deep-sleep when connected to USB
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike committed Feb 26, 2020
1 parent 0a7e629 commit 0cad84c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions firmware/HID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,7 @@ void HID::sendKeys(
}
}
}

bool HID::isUSB(void) {
return usb_hid.ready();
}
1 change: 1 addition & 0 deletions firmware/HID.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class HID {
HID(void);
void begin(void);
void sendKeys(const Keymap *km);
bool isUSB(void);
private:

enum class Scancode : uint8_t {
Expand Down
5 changes: 5 additions & 0 deletions firmware/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ void Keyboard::indicateBatteryLevel(void) {
}

void Keyboard::sleepCheck(void) {

if(hid.isUSB()) {
return;
}

if ((millis() - idleTime) > (sleepMinutes * 60 * 1000)) {
led.offAll();
matrix.sleep();
Expand Down

0 comments on commit 0cad84c

Please sign in to comment.