Draw "> Scanning..." at startup on OLED

This commit is contained in:
Spacehuhn 2021-01-11 11:58:01 +01:00
parent 85a7c12b97
commit 0c908c577c
4 changed files with 54 additions and 30 deletions

View File

@ -1094,11 +1094,11 @@ void CLI::runCommand(String input) {
// ------- loop function ----- //
currentTime = millis();
wifi::update(); // manage access point
wifi::update(); // manage access point
scan.update(); // run scan
attack.update(); // run attacks
ssids.update(); // run random mode, if enabled
led::update(); // update LED color
led::update(); // update LED color
// auto-save
if (settings::getAutosaveSettings().enabled && (currentTime - autosaveTime > settings::getAutosaveSettings().time)) {
@ -1229,10 +1229,10 @@ void CLI::runCommand(String input) {
// ===== SCREEN ===== //
// screen mode <menu/packetmonitor/buttontest/loading>
else if (eqlsCMD(0, CLI_SCREEN) && eqlsCMD(1, CLI_MODE)) {
if (eqlsCMD(2, CLI_MODE_BUTTONTEST)) displayUI.mode = displayUI.DISPLAY_MODE::BUTTON_TEST;
else if (eqlsCMD(2, CLI_MODE_PACKETMONITOR)) displayUI.mode = displayUI.DISPLAY_MODE::PACKETMONITOR;
else if (eqlsCMD(2, CLI_MODE_LOADINGSCREEN)) displayUI.mode = displayUI.DISPLAY_MODE::LOADSCAN;
else if (eqlsCMD(2, CLI_MODE_MENU)) displayUI.mode = displayUI.DISPLAY_MODE::MENU;
if (eqlsCMD(2, CLI_MODE_BUTTONTEST)) displayUI.mode = DISPLAY_MODE::BUTTON_TEST;
else if (eqlsCMD(2, CLI_MODE_PACKETMONITOR)) displayUI.mode = DISPLAY_MODE::PACKETMONITOR;
else if (eqlsCMD(2, CLI_MODE_LOADINGSCREEN)) displayUI.mode = DISPLAY_MODE::LOADSCAN;
else if (eqlsCMD(2, CLI_MODE_MENU)) displayUI.mode = DISPLAY_MODE::MENU;
else parameterError(list->get(2));
prntln(CLI_CHANGED_SCREEN);
}

View File

@ -69,10 +69,10 @@ void DisplayUI::setup() {
clock.setClockMode(false);
clockHour = clock.getHour(h12, PM_time);
clockMinute = clock.getMinute();
#else
#else // ifdef RTC_DS3231
clockHour = random(12);
clockMinute = random(60);
#endif
#endif // ifdef RTC_DS3231
// ===== MENUS ===== //
@ -461,7 +461,7 @@ void DisplayUI::setupLED() {
#endif // ifdef HIGHLIGHT_LED
void DisplayUI::update() {
void DisplayUI::update(bool force) {
if (!enabled) return;
up->update();
@ -469,7 +469,7 @@ void DisplayUI::update() {
a->update();
b->update();
draw();
draw(force);
uint32_t timeout = settings::getDisplaySettings().timeout * 1000;
@ -521,7 +521,7 @@ void DisplayUI::setupButtons() {
else currentMenu->selected = currentMenu->list->size() - 1;
} else if (mode == DISPLAY_MODE::PACKETMONITOR) { // when in packet monitor, change channel
scan.setChannel(wifi_channel + 1);
} else if (mode == DISPLAY_MODE::CLOCK) { // when in packet monitor, change channel
} else if (mode == DISPLAY_MODE::CLOCK) {
setTime(clockHour, clockMinute + 1, clockSecond);
}
}
@ -654,18 +654,18 @@ String DisplayUI::getChannel() {
return ch;
}
void DisplayUI::draw() {
if ((currentTime - drawTime > drawInterval) && currentMenu) {
void DisplayUI::draw(bool force) {
if (force || ((currentTime - drawTime > drawInterval) && currentMenu)) {
drawTime = currentTime;
updatePrefix();
#ifndef RTC_DS3231
if (clockTime < currentTime - 1000) {
setTime(clockHour, clockMinute++, clockSecond + 1);
clockTime += 1000;
}
#endif
#endif // ifndef RTC_DS3231
switch (mode) {
case DISPLAY_MODE::BUTTON_TEST:
@ -685,7 +685,7 @@ void DisplayUI::draw() {
break;
case DISPLAY_MODE::INTRO:
if (currentTime - startTime >= screenIntroTime) {
if (!scan.isScanning() && (currentTime - startTime >= screenIntroTime)) {
mode = DISPLAY_MODE::MENU;
}
drawIntro();
@ -693,6 +693,9 @@ void DisplayUI::draw() {
case DISPLAY_MODE::CLOCK:
drawClock();
break;
case DISPLAY_MODE::RESETTING:
drawResetting();
break;
}
updateSuffix();
@ -786,8 +789,13 @@ void DisplayUI::drawIntro() {
drawString(0, center(str(D_INTRO_0), maxLen));
drawString(1, center(str(D_INTRO_1), maxLen));
drawString(2, center(str(D_INTRO_2), maxLen));
drawString(3, center(str(D_INTRO_3), maxLen));
drawString(4, center(DEAUTHER_VERSION, maxLen));
drawString(3, center(DEAUTHER_VERSION, maxLen));
if (scan.isScanning()) {
if (currentTime - startTime >= screenIntroTime+4500) drawString(4, left(str(D_SCANNING_3), maxLen));
else if (currentTime - startTime >= screenIntroTime+3000) drawString(4, left(str(D_SCANNING_2), maxLen));
else if (currentTime - startTime >= screenIntroTime+1500) drawString(4, left(str(D_SCANNING_1), maxLen));
else if (currentTime - startTime >= screenIntroTime) drawString(4, left(str(D_SCANNING_0), maxLen));
}
}
void DisplayUI::drawClock() {
@ -800,6 +808,10 @@ void DisplayUI::drawClock() {
display.drawString(64, 20, clockTime);
}
void DisplayUI::drawResetting() {
drawString(2, center(str(D_RESETTING), maxLen));
}
void DisplayUI::clearMenu(Menu* menu) {
while (menu->list->size() > 0) {
menu->list->remove(0);
@ -906,5 +918,5 @@ void DisplayUI::setTime(int h, int m, int s) {
clock.setHour(clockHour);
clock.setMinute(clockMinute);
clock.setSecond(clockSecond);
#endif
}
#endif // ifdef RTC_DS3231
}

View File

@ -47,10 +47,14 @@ extern String right(String a, int len);
extern String leftRight(String a, String b, int len);
extern String replaceUtf8(String str, String r);
const char D_INTRO_0[] PROGMEM = "";
const char D_INTRO_1[] PROGMEM = "ESP8266 Deauther";
const char D_INTRO_2[] PROGMEM = "by @Spacehuhn";
const char D_INTRO_3[] PROGMEM = DISPLAY_TEXT;
const char D_INTRO_0[] PROGMEM = "ESP8266 Deauther";
const char D_INTRO_1[] PROGMEM = "by @Spacehuhn";
const char D_INTRO_2[] PROGMEM = DISPLAY_TEXT;
const char D_RESETTING[] PROGMEM = "Resetting...";
const char D_SCANNING_0[] PROGMEM = "> Scanning";
const char D_SCANNING_1[] PROGMEM = "> Scanning.";
const char D_SCANNING_2[] PROGMEM = "> Scanning..";
const char D_SCANNING_3[] PROGMEM = "> Scanning...";
struct MenuNode {
std::function<String()>getStr; // function used to create the displayed string
@ -65,11 +69,18 @@ struct Menu {
std::function<void()> build; // function that is executed when button is clicked
};
enum class DISPLAY_MODE { OFF,
BUTTON_TEST,
MENU,
LOADSCAN,
PACKETMONITOR,
INTRO,
CLOCK,
RESETTING };
class DisplayUI {
public:
enum DISPLAY_MODE { OFF = 0, BUTTON_TEST = 1, MENU = 2, LOADSCAN = 3, PACKETMONITOR = 4, INTRO = 5, CLOCK = 6 };
uint8_t mode = DISPLAY_MODE::MENU;
DISPLAY_MODE mode = DISPLAY_MODE::MENU;
bool highlightLED = false;
Button* up = NULL;
@ -115,7 +126,7 @@ class DisplayUI {
void setupLED();
#endif // ifdef HIGHLIGHT_LED
void update();
void update(bool force = false);
void on();
void off();
@ -160,12 +171,13 @@ class DisplayUI {
String getChannel();
// draw functions
void draw();
void draw(bool force = false);
void drawButtonTest();
void drawMenu();
void drawLoadingScan();
void drawPacketMonitor();
void drawIntro();
void drawResetting();
void clearMenu(Menu* menu);
// menu functions

View File

@ -116,7 +116,7 @@ void setup() {
// start display
if (settings::getDisplaySettings().enabled) {
displayUI.setup();
displayUI.mode = displayUI.DISPLAY_MODE::INTRO;
displayUI.mode = DISPLAY_MODE::INTRO;
}
// copy web files to SPIFFS