diff --git a/src/core/display.cpp b/src/core/display.cpp index b3f96d1f..780f82f0 100644 --- a/src/core/display.cpp +++ b/src/core/display.cpp @@ -2,6 +2,7 @@ #include "mykeyboard.h" #include "wg.h" //for isConnectedWireguard to print wireguard lock #include "settings.h" //for timeStr +#include "modules/others/webInterface.h" // for server #if defined(CARDPUTER) || defined(STICK_C_PLUS2) //Battery Calculation #include @@ -46,6 +47,9 @@ void initDisplay(int i) { ** Description: Display Red Stripe with information ***************************************************************************************/ void displayRedStripe(String text, uint16_t fgcolor, uint16_t bgcolor) { + // detect if not running in interactive mode -> show nothing onscreen and return immediately + if(server || isSleeping || isScreenOff) return; // webui is running + int size; if(fgcolor==bgcolor && fgcolor==TFT_WHITE) fgcolor=TFT_BLACK; if(text.length()*LW*FM<(tft.width()-2*FM*LW)) size = FM; @@ -119,7 +123,19 @@ void loopOptions(const std::vector> } #ifdef CARDPUTER - if(checkEscPress()) break; + if(checkEscPress()) break; + int pressed_number = checkNumberShortcutPress(); + if(pressed_number>=0) { + if(index == pressed_number) { + // press 2 times the same number to confirm + options[index].second(); + break; + } + // else only highlight the option + index = pressed_number; + if((index+1)>options.size()) index = options.size() - 1; + redraw = true; + } #endif } delay(200); diff --git a/src/core/mykeyboard.cpp b/src/core/mykeyboard.cpp index 1cb0d815..53a4bb25 100644 --- a/src/core/mykeyboard.cpp +++ b/src/core/mykeyboard.cpp @@ -110,19 +110,31 @@ bool checkAnyKeyPress() { } +#ifdef CARDPUTER void checkShortcutPress(){ - // some shortctus to quickly starts apps -#if defined (CARDPUTER) + // shortctus to quickly starts apps 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: other boards? // TODO: user-configurable +} + +int checkNumberShortcutPress() { + // shortctus to quickly select options + Keyboard.update(); + char c; + for (c = '1'; c <= '9'; c++) { + if(Keyboard.isKeyPressed(c)) return(c - '1'); + } + // else + return -1; #endif } + /* Starts keyboard to type data */ String keyboard(String mytext, int maxSize, String msg) { diff --git a/src/core/mykeyboard.h b/src/core/mykeyboard.h index d5fed3c8..dba18982 100644 --- a/src/core/mykeyboard.h +++ b/src/core/mykeyboard.h @@ -12,7 +12,10 @@ bool checkSelPress(); bool checkEscPress(); +#ifdef CARDPUTER void checkShortcutPress(); +int checkNumberShortcutPress(); +#endif bool checkAnyKeyPress();