Skip to content

Commit

Permalink
wakeup from screensaver with any key, added badusb shortcut (pr3y#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
eadmaster committed Jul 23, 2024
1 parent 08c1445 commit 0f3ba0f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ void loop() {
tft.fillRect(0,0,WIDTH,HEIGHT,BGCOLOR);
while(1){
handleSerialCommands();
// TODO: screenSleep(); // turn off screen with a timer -> wake up on any button press

if(returnToMenu) {
returnToMenu = false;
tft.fillScreen(BGCOLOR); //fix any problem with the mainMenu screen when coming back from submenus or functions
redraw=true;
}

if(checkAnyKeyPress()) reset_screensaver_timer();

if (redraw) {
reset_screensaver_timer();
drawMainMenu(index);
redraw = false;
delay(200);
Expand Down
16 changes: 16 additions & 0 deletions src/mykeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,23 @@ bool checkEscPress(){
else { return false; }
}

bool checkAnyKeyPress() {
#if defined (CARDPUTER) // If any key is pressed, it'll jump the boot screen
Keyboard.update();
if(Keyboard.isPressed())
#else
if(digitalRead(SEL_BTN)==LOW) // If M5 key is pressed, it'll jump the boot screen
#endif
return true;
// else
return false;

}


#include "TV-B-Gone.h"
#include "rf.h"
#include "bad_usb.h"
#include "webInterface.h"

void checkShortcutPress(){
Expand All @@ -69,6 +84,7 @@ void checkShortcutPress(){
Keyboard.update();
if(Keyboard.isKeyPressed('i')) otherIRcodes();
if(Keyboard.isKeyPressed('r') || Keyboard.isKeyPressed('s')) otherRFcodes();
if(Keyboard.isKeyPressed('b')) usb_setup(); // badusb
if(Keyboard.isKeyPressed('w')) loopOptionsWebUi();
// TODO: other boards
// TODO: user-configurable
Expand Down
2 changes: 2 additions & 0 deletions src/mykeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ bool checkSelPress();
bool checkEscPress();

void checkShortcutPress();

bool checkAnyKeyPress();

0 comments on commit 0f3ba0f

Please sign in to comment.