Merge pull request #1260 from tlyu/hostpower-cleanup

master
Jesse Vincent 2 years ago committed by GitHub
commit fefc6699ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,15 +26,10 @@
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult, EventHandlerResult::OK
// This is a terrible hack until Arduino#6964 gets implemented.
// It makes the `_usbSuspendState` symbol available to us.
extern uint8_t _usbSuspendState;
namespace kaleidoscope {
namespace plugin {
bool HostPowerManagement::was_suspended_ = false;
bool HostPowerManagement::initial_suspend_ = true;
bool HostPowerManagement::isSuspended() {
#if defined(__AVR__)
@ -48,17 +43,13 @@ bool HostPowerManagement::isSuspended() {
EventHandlerResult HostPowerManagement::beforeEachCycle() {
if (isSuspended()) {
if (!initial_suspend_) {
if (!was_suspended_) {
was_suspended_ = true;
hostPowerManagementEventHandler(Suspend);
} else {
hostPowerManagementEventHandler(Sleep);
}
}
} else {
if (initial_suspend_)
initial_suspend_ = false;
if (was_suspended_) {
was_suspended_ = false;
hostPowerManagementEventHandler(Resume);

@ -34,7 +34,6 @@ class HostPowerManagement : public kaleidoscope::Plugin {
private:
static bool was_suspended_;
static bool initial_suspend_;
bool isSuspended();
};

Loading…
Cancel
Save