Skip to content

Commit

Permalink
Merge pull request #251 from jpconstantineau/sleep-splits
Browse files Browse the repository at this point in the history
added code to prevent sleeping when data is received from the other half
  • Loading branch information
jpconstantineau authored Nov 28, 2021
2 parents 1c61379 + 047516a commit 4e55d9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions firmware/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ void notify_callback(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
KeyScanner::updateRemoteReport(remotedata.modifier,remotedata.keycode[0],remotedata.keycode[1],remotedata.keycode[2], remotedata.keycode[3],remotedata.keycode[4], remotedata.keycode[5]);
KeyScanner::updateRemoteLayer(remotedata.layer);
KeyScanner::remotespecialkeycode = remotedata.specialkeycode;
if (remotedata.modifier != 0 || remotedata.keycode[0] != 0)
keyboardstate.lastuseractiontime = millis();
}
}

Expand Down Expand Up @@ -399,6 +401,7 @@ LOG_LV1("CB_CHR","layer_request_callback: len %i offset %i data %i" ,len, data[
{
statedata=*(StatePayload*) data; // update state
KeyScanner::updateRemoteLayer(statedata.layer);
keyboardstate.lastuseractiontime = millis(); // would this prevent both boards from sleeping because of the ping pong of data between sides?
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion firmware/firmware_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ void keyscantimer_callback(TimerHandle_t _handle) {
sendKeyPresses();
#endif
keyboardstate.lastuseractiontime = max(KeyScanner::getLastPressed(),keyboardstate.lastuseractiontime); // use the latest time to check for sleep...
unsigned long timesincelastkeypress = keyboardstate.timestamp - keyboardstate.lastuseractiontime;
unsigned long timesincelastkeypress = (keyboardstate.timestamp > keyboardstate.lastuseractiontime) ? keyboardstate.timestamp - keyboardstate.lastuseractiontime : 0;

#if SLEEP_ACTIVE == 1
switch (keyboardstate.connectionState)
Expand Down

0 comments on commit 4e55d9b

Please sign in to comment.