MCPcopy Create free account
hub / github.com/TailsmanDesign/PocketMage_PDA / waitForKeypress

Function waitForKeypress

Code/PocketMage_V3/src/UTILS.cpp:1062–1191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1060#endif
1061
1062void waitForKeypress(String message) {
1063 KB().setKeyboardState(NORMAL);
1064 pocketmage::setCpuSpeed(240); // Boost clock for smooth animation
1065
1066 String msg = message;
1067 String bottomMsg = "Press any key to continue...";
1068
1069 u8g2.clearBuffer();
1070 const uint16_t dw = u8g2.getDisplayWidth();
1071 const uint16_t dh = u8g2.getDisplayHeight();
1072
1073 int y_offset = 0;
1074 int x_offset = 0;
1075 const uint8_t* activeFont;
1076
1077 // --- 1. Find the largest font that fits and calculate offsets ---
1078 u8g2.setFont(u8g2_font_ncenB14_tf);
1079 if (u8g2.getUTF8Width(msg.c_str()) < dw) {
1080 y_offset = 16 + 3;
1081 x_offset = (dw - u8g2.getUTF8Width(msg.c_str())) / 2;
1082 activeFont = u8g2_font_ncenB14_tf;
1083 }
1084 else {
1085 u8g2.setFont(u8g2_font_ncenB12_tf);
1086 if (u8g2.getUTF8Width(msg.c_str()) < dw) {
1087 y_offset = 16 + 2;
1088 x_offset = (dw - u8g2.getUTF8Width(msg.c_str())) / 2;
1089 activeFont = u8g2_font_ncenB12_tf;
1090 }
1091 else {
1092 u8g2.setFont(u8g2_font_ncenB10_tf);
1093 if (u8g2.getUTF8Width(msg.c_str()) < dw) {
1094 y_offset = 16 + 1;
1095 x_offset = (dw - u8g2.getUTF8Width(msg.c_str())) / 2;
1096 activeFont = u8g2_font_ncenB10_tf;
1097 }
1098 else {
1099 u8g2.setFont(u8g2_font_ncenB08_tf);
1100 if (u8g2.getUTF8Width(msg.c_str()) < dw) {
1101 y_offset = 16;
1102 x_offset = (dw - u8g2.getUTF8Width(msg.c_str())) / 2;
1103 }
1104 else {
1105 y_offset = 16;
1106 x_offset = dw - u8g2.getUTF8Width(msg.c_str());
1107 }
1108 activeFont = u8g2_font_ncenB08_tf;
1109 }
1110 }
1111 }
1112
1113 // --- 2. Slide Up Animation ---
1114 for (int y = dh; y > 0; y-=2) {
1115 u8g2.clearBuffer();
1116
1117 // Draw Main Message
1118 u8g2.setFont(activeFont);
1119 u8g2.drawUTF8(x_offset, y + y_offset, msg.c_str());

Callers 3

checkCrashStateFunction · 0.85
wr_waitForKeypressFunction · 0.85
processKB_FILEWIZFunction · 0.85

Calls 7

setCpuSpeedFunction · 0.85
checkTimeoutFunction · 0.85
printDebugFunction · 0.85
updateBattStateFunction · 0.85
setKeyboardStateMethod · 0.80
getPrevTimeMillisMethod · 0.80
updateKeypressMethod · 0.80

Tested by

no test coverage detected