prompt before restarting

This commit is contained in:
krolyxon 2026-05-06 15:34:42 +05:30
parent 2e20bbf311
commit 8f6c64d4b3
3 changed files with 88 additions and 16 deletions

View File

@ -1,10 +1,6 @@
#include "buttons.h" #include "buttons.h"
#include <Arduino.h> #include <Arduino.h>
#include "config.h"
#define BTN_UP 4
#define BTN_DOWN 5
#define BTN_SELECT 6
#define BTN_BACK 7
void buttonsInit() void buttonsInit()
{ {
@ -12,9 +8,13 @@ void buttonsInit()
pinMode(BTN_DOWN, INPUT_PULLUP); pinMode(BTN_DOWN, INPUT_PULLUP);
pinMode(BTN_SELECT, INPUT_PULLUP); pinMode(BTN_SELECT, INPUT_PULLUP);
pinMode(BTN_BACK, INPUT_PULLUP); pinMode(BTN_BACK, INPUT_PULLUP);
pinMode(BTN_RIGHT, INPUT_PULLUP);
pinMode(BTN_LEFT, INPUT_PULLUP);
} }
bool btnUp() { return !digitalRead(BTN_UP); } bool btnUp() { return !digitalRead(BTN_UP); }
bool btnDown() { return !digitalRead(BTN_DOWN); } bool btnDown() { return !digitalRead(BTN_DOWN); }
bool btnSelect() { return !digitalRead(BTN_SELECT); } bool btnSelect() { return !digitalRead(BTN_SELECT); }
bool btnBack() { return !digitalRead(BTN_BACK); } bool btnBack() { return !digitalRead(BTN_BACK); }
bool btnRight() { return !digitalRead(BTN_RIGHT); }
bool btnLeft() { return !digitalRead(BTN_LEFT); }

View File

@ -6,3 +6,5 @@ bool btnUp();
bool btnDown(); bool btnDown();
bool btnSelect(); bool btnSelect();
bool btnBack(); bool btnBack();
bool btnRight();
bool btnLeft();

View File

@ -9,7 +9,7 @@
#include "wifi_scan.h" #include "wifi_scan.h"
#include "wifi_analyzer.h" #include "wifi_analyzer.h"
#include "device_check.h" #include "device_check.h"
#include "blemouse.h" #include "ble_mouse.h"
#include "sysinfo.h" #include "sysinfo.h"
#include "BleMouse.h" #include "BleMouse.h"
@ -36,7 +36,8 @@ Menu mainMenu = {mainMenuItems, sizeof(mainMenuItems) / sizeof(mainMenuItems[0])
// NRF Tools menu // NRF Tools menu
const char *nrfToolsItems[] = { const char *nrfToolsItems[] = {
"BLE Jammer", "BLE Jammer",
"Bluetooth Jammer" "Bluetooth Jammer",
"Wifi Jammer"
}; };
Menu nrfToolsMenu = {nrfToolsItems, sizeof(nrfToolsItems) / sizeof(nrfToolsItems[0])}; Menu nrfToolsMenu = {nrfToolsItems, sizeof(nrfToolsItems) / sizeof(nrfToolsItems[0])};
@ -226,13 +227,82 @@ void launchFeature()
device_check_run(); device_check_run();
break; break;
case 8: case 8:
{
// wait for button release
delay(200);
while (btnSelect())
delay(10);
bool confirm = false;
while (1)
{
u8g2.clearBuffer(); u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x13_tr); u8g2.setFont(u8g2_font_6x13_tr);
u8g2.drawStr(30, 30, "Restarting...");
u8g2.drawStr(18, 18, "Restart Device?");
if (confirm)
{
u8g2.drawBox(10, 35, 45, 15);
u8g2.setDrawColor(0);
u8g2.drawStr(20, 47, "YES");
u8g2.setDrawColor(1);
u8g2.drawStr(75, 47, "NO");
}
else
{
u8g2.drawStr(20, 47, "YES");
u8g2.drawBox(65, 35, 45, 15);
u8g2.setDrawColor(0);
u8g2.drawStr(78, 47, "NO");
u8g2.setDrawColor(1);
}
u8g2.sendBuffer(); u8g2.sendBuffer();
if (btnLeft() || btnUp())
{
confirm = true;
delay(150);
}
if (btnRight() || btnDown())
{
confirm = false;
delay(150);
}
if (btnSelect())
{
delay(150);
if (confirm)
{
u8g2.clearBuffer();
u8g2.drawStr(28, 30, "Restarting...");
u8g2.sendBuffer();
delay(1000); delay(1000);
ESP.restart(); ESP.restart();
}
else
{
break; break;
}
}
if (btnBack())
{
delay(150);
break;
}
}
}
break;
case 9: case 9:
// Begin Ble mouse // Begin Ble mouse
bleMouse.begin(); bleMouse.begin();