Add Join WiFi for touch hardware

This commit is contained in:
Just Call Me Koko
2025-06-03 23:13:11 -04:00
parent 75e3e71453
commit 51eddd5b8f
7 changed files with 431 additions and 128 deletions

View File

@@ -11,7 +11,7 @@ Display::Display()
{ {
} }
int8_t Display::menuButton(uint16_t *x, uint16_t *y, bool pressed) { int8_t Display::menuButton(uint16_t *x, uint16_t *y, bool pressed, bool check_hold) {
#ifdef HAS_ILI9341 #ifdef HAS_ILI9341
for (uint8_t b = BUTTON_ARRAY_LEN; b < BUTTON_ARRAY_LEN + 3; b++) { for (uint8_t b = BUTTON_ARRAY_LEN; b < BUTTON_ARRAY_LEN + 3; b++) {
if (pressed && this->key[b].contains(*x, *y)) { if (pressed && this->key[b].contains(*x, *y)) {
@@ -22,8 +22,15 @@ int8_t Display::menuButton(uint16_t *x, uint16_t *y, bool pressed) {
} }
for (uint8_t b = BUTTON_ARRAY_LEN; b < BUTTON_ARRAY_LEN + 3; b++) { for (uint8_t b = BUTTON_ARRAY_LEN; b < BUTTON_ARRAY_LEN + 3; b++) {
if ((this->key[b].justReleased()) && (!pressed)) { if (!check_hold) {
return b - BUTTON_ARRAY_LEN; if ((this->key[b].justReleased()) && (!pressed)) {
return b - BUTTON_ARRAY_LEN;
}
}
else {
if ((this->key[b].isPressed())) {
return b - BUTTON_ARRAY_LEN;
}
} }
} }
@@ -80,6 +87,28 @@ uint8_t Display::updateTouch(uint16_t *x, uint16_t *y, uint16_t threshold) {
return 0; return 0;
} }
bool Display::isTouchHeld(uint16_t threshold) {
static unsigned long touchStartTime = 0;
static bool touchHeld = false;
uint16_t x, y;
if (this->updateTouch(&x, &y, threshold)) {
// Touch detected
if (touchStartTime == 0) {
touchStartTime = millis(); // First touch timestamp
} else if (!touchHeld && millis() - touchStartTime >= 1000) {
touchHeld = true; // Held for at least 1000ms
return true;
}
} else {
// Touch released
touchStartTime = 0;
touchHeld = false;
}
return false;
}
// Function to prepare the display and the menus // Function to prepare the display and the menus
void Display::RunSetup() void Display::RunSetup()
{ {

View File

@@ -118,8 +118,9 @@ class Display
// We can speed up scrolling of short text lines by just blanking the character we drew // We can speed up scrolling of short text lines by just blanking the character we drew
int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
int8_t menuButton(uint16_t *x, uint16_t *y, bool pressed); int8_t menuButton(uint16_t *x, uint16_t *y, bool pressed, bool check_hold = false);
uint8_t updateTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600); uint8_t updateTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600);
bool isTouchHeld(uint16_t threshold = 600);
void tftDrawRedOnOffButton(); void tftDrawRedOnOffButton();
void tftDrawGreenOnOffButton(); void tftDrawGreenOnOffButton();
void tftDrawGraphObjects(byte x_scale); void tftDrawGraphObjects(byte x_scale);

View File

@@ -581,6 +581,67 @@ MenuFunctions::MenuFunctions()
display_obj.exit_draw = true; // set everything back to normal display_obj.exit_draw = true; // set everything back to normal
} }
} }
void MenuFunctions::joinWiFiGFX(String essid){
// Create one text area
ta1 = lv_textarea_create(lv_scr_act(), NULL);
lv_textarea_set_one_line(ta1, true);
lv_obj_set_width(ta1, LV_HOR_RES / 2 - 20);
lv_obj_set_pos(ta1, 5, 20);
//lv_ta_set_cursor_type(ta, LV_CURSOR_BLOCK);
lv_textarea_set_text(ta1, essid.c_str());
lv_obj_set_event_cb(ta1, ta_event_cb);
// Create first label
lv_obj_t * ssid_label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(ssid_label, "SSID:");
lv_obj_align(ssid_label, ta1, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
// Create second text area
ta2 = lv_textarea_create(lv_scr_act(), ta1);
//lv_textarea_set_pwd_mode(ta2, true); // This shit makes it so backspace does not work
//lv_textarea_set_pwd_show_time(ta2, 1000);
lv_textarea_set_cursor_hidden(ta2, true);
lv_obj_align(ta2, NULL, LV_ALIGN_IN_TOP_RIGHT, -5, 20);
// Create second label
lv_obj_t * pw_label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(pw_label, "Password:");
lv_obj_align(pw_label, ta2, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
// Create a keyboard and apply the styles
kb = lv_keyboard_create(lv_scr_act(), NULL);
lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_set_event_cb(kb, join_wifi_keyboard_event_cb);
// Focus it on one of the text areas to start
lv_keyboard_set_textarea(kb, ta1);
lv_keyboard_set_cursor_manage(kb, true);
}
void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
extern Display display_obj;
extern MenuFunctions menu_function_obj;
extern WiFiScan wifi_scan_obj;
lv_keyboard_def_event_cb(kb, event);
if(event == LV_EVENT_APPLY){
printf("LV_EVENT_APPLY\n");
//String ta1_text = lv_textarea_get_text(lv_keyboard_get_textarea(kb));
String ta1_text = lv_textarea_get_text(ta1);
String ta2_text = lv_textarea_get_text(ta2);
Serial.println(ta1_text);
Serial.println(ta2_text);
wifi_scan_obj.joinWiFi(ta1_text, ta2_text);
}else if(event == LV_EVENT_CANCEL){
printf("LV_EVENT_CANCEL\n");
//lv_textarea_set_text(lv_keyboard_get_textarea(kb), "");
menu_function_obj.deinitLVGL();
//wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
display_obj.exit_draw = true; // set everything back to normal
}
}
void ta_event_cb(lv_obj_t * ta, lv_event_t event) void ta_event_cb(lv_obj_t * ta, lv_event_t event)
@@ -1652,9 +1713,9 @@ void MenuFunctions::RunSetup()
// WiFi HTML menu stuff // WiFi HTML menu stuff
htmlMenu.list = new LinkedList<MenuNode>(); htmlMenu.list = new LinkedList<MenuNode>();
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
miniKbMenu.list = new LinkedList<MenuNode>(); miniKbMenu.list = new LinkedList<MenuNode>();
#endif //#endif
//#ifndef HAS_ILI9341 //#ifndef HAS_ILI9341
// #ifdef HAS_BUTTONS // #ifdef HAS_BUTTONS
#ifdef HAS_SD #ifdef HAS_SD
@@ -1723,9 +1784,9 @@ void MenuFunctions::RunSetup()
wardrivingMenu.name = "Wardriving"; wardrivingMenu.name = "Wardriving";
#endif #endif
htmlMenu.name = "EP HTML List"; htmlMenu.name = "EP HTML List";
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
miniKbMenu.name = "Mini Keyboard"; miniKbMenu.name = "Mini Keyboard";
#endif //#endif
#ifdef HAS_SD #ifdef HAS_SD
// #ifndef HAS_ILI9341 // #ifndef HAS_ILI9341
sdDeleteMenu.name = "Delete SD Files"; sdDeleteMenu.name = "Delete SD Files";
@@ -2029,12 +2090,12 @@ void MenuFunctions::RunSetup()
this->changeMenu(&htmlMenu); this->changeMenu(&htmlMenu);
}); });
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
miniKbMenu.parentMenu = &wifiGeneralMenu; miniKbMenu.parentMenu = &wifiGeneralMenu;
this->addNodes(&miniKbMenu, "a", TFTCYAN, NULL, 0, [this]() { this->addNodes(&miniKbMenu, "a", TFTCYAN, NULL, 0, [this]() {
this->changeMenu(miniKbMenu.parentMenu); this->changeMenu(miniKbMenu.parentMenu);
}); });
#endif //#endif
htmlMenu.parentMenu = &wifiGeneralMenu; htmlMenu.parentMenu = &wifiGeneralMenu;
this->addNodes(&htmlMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { this->addNodes(&htmlMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
@@ -2153,6 +2214,29 @@ void MenuFunctions::RunSetup()
this->changeMenu(&wifiAPMenu); this->changeMenu(&wifiAPMenu);
}); });
this->addNodes(&wifiGeneralMenu, "Join WiFi", TFTWHITE, NULL, KEYBOARD_ICO, [this](){
// Add the back button
wifiAPMenu.list->clear();
this->addNodes(&wifiAPMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
this->changeMenu(wifiAPMenu.parentMenu);
});
// Populate the menu with buttons
for (int i = 0; i < access_points->size(); i++) {
// This is the menu node
this->addNodes(&wifiAPMenu, access_points->get(i).essid, TFTCYAN, NULL, 255, [this, i](){
//this->changeMenu(&miniKbMenu);
//this->miniKeyboard(&miniKbMenu);
#ifdef HAS_TOUCH
wifi_scan_obj.currentScanMode = LV_JOIN_WIFI;
wifi_scan_obj.StartScan(LV_JOIN_WIFI, TFT_YELLOW);
joinWiFiGFX(access_points->get(i).essid);
#endif
});
}
this->changeMenu(&wifiAPMenu);
});
wifiStationMenu.parentMenu = &wifiAPMenu; wifiStationMenu.parentMenu = &wifiAPMenu;
this->addNodes(&wifiStationMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { this->addNodes(&wifiStationMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
this->changeMenu(wifiStationMenu.parentMenu); this->changeMenu(wifiStationMenu.parentMenu);
@@ -2172,6 +2256,11 @@ void MenuFunctions::RunSetup()
this->changeMenu(&setMacMenu); this->changeMenu(&setMacMenu);
}); });
this->addNodes(&wifiGeneralMenu, "Shutdown WiFi", TFTRED, NULL, 0, [this]() {
wifi_scan_obj.StartScan(WIFI_SCAN_OFF, TFT_RED);
this->changeMenu(current_menu);
});
// Menu for generating and setting MAC addrs for AP and STA // Menu for generating and setting MAC addrs for AP and STA
setMacMenu.parentMenu = &wifiGeneralMenu; setMacMenu.parentMenu = &wifiGeneralMenu;
@@ -2763,7 +2852,7 @@ void MenuFunctions::RunSetup()
this->initTime = millis(); this->initTime = millis();
} }
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
void MenuFunctions::miniKeyboard(Menu * targetMenu) { void MenuFunctions::miniKeyboard(Menu * targetMenu) {
// Prepare a char array and reset temp SSID string // Prepare a char array and reset temp SSID string
extern LinkedList<ssid>* ssids; extern LinkedList<ssid>* ssids;
@@ -2772,10 +2861,12 @@ void MenuFunctions::RunSetup()
wifi_scan_obj.current_mini_kb_ssid = ""; wifi_scan_obj.current_mini_kb_ssid = "";
if (c_btn.isHeld()) { #ifdef HAS_MINI_KB
while (!c_btn.justReleased()) if (c_btn.isHeld()) {
delay(1); while (!c_btn.justReleased())
} delay(1);
}
#endif
int str_len = wifi_scan_obj.alfa.length() + 1; int str_len = wifi_scan_obj.alfa.length() + 1;
@@ -2783,13 +2874,157 @@ void MenuFunctions::RunSetup()
wifi_scan_obj.alfa.toCharArray(char_array, str_len); wifi_scan_obj.alfa.toCharArray(char_array, str_len);
#ifdef HAS_TOUCH
uint16_t t_x = 0, t_y = 0;
#endif
// Button loop until hold center button // Button loop until hold center button
#ifdef HAS_BUTTONS #ifdef HAS_BUTTONS
#if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1) || defined(MARAUDER_CYD_MICRO)) //#if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1) || defined(MARAUDER_CYD_MICRO))
while(true) { while(true) {
// Cycle char previous // Keyboard functions for switch hardware
#ifdef HAS_L #ifdef HAS_MINI_KB
if (l_btn.justPressed()) { // Cycle char previous
#ifdef HAS_L
if (l_btn.justPressed()) {
pressed = true;
if (this->mini_kb_index > 0)
this->mini_kb_index--;
else
this->mini_kb_index = str_len - 2;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu);
while (!l_btn.justReleased())
delay(1);
}
#endif
// Cycle char next
#ifdef HAS_R
if (r_btn.justPressed()) {
pressed = true;
if (this->mini_kb_index < str_len - 2)
this->mini_kb_index++;
else
this->mini_kb_index = 0;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str());
while (!r_btn.justReleased())
delay(1);
}
#endif
//// 5-WAY SWITCH STUFF
// Add character
#if (defined(HAS_D) && defined(HAS_R))
if (d_btn.justPressed()) {
pressed = true;
wifi_scan_obj.current_mini_kb_ssid.concat(String(char_array[this->mini_kb_index]).c_str());
while (!d_btn.justReleased())
delay(1);
}
#endif
// Remove character
#if (defined(HAS_U) && defined(HAS_L))
if (u_btn.justPressed()) {
pressed = true;
wifi_scan_obj.current_mini_kb_ssid.remove(wifi_scan_obj.current_mini_kb_ssid.length() - 1);
while (!u_btn.justReleased())
delay(1);
}
#endif
//// PARTIAL SWITCH STUFF
// Advance char or add char
#if (defined(HAS_D) && !defined(HAS_R))
if (d_btn.justPressed()) {
bool was_held = false;
pressed = true;
while(!d_btn.justReleased()) {
d_btn.justPressed();
// Add letter to string
if (d_btn.isHeld()) {
wifi_scan_obj.current_mini_kb_ssid.concat(String(char_array[this->mini_kb_index]).c_str());
was_held = true;
break;
}
}
if (!was_held) {
if (this->mini_kb_index < str_len - 2)
this->mini_kb_index++;
else
this->mini_kb_index = 0;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str());
}
}
#endif
// Prev char or remove char
#if (defined(HAS_U) && !defined(HAS_L))
if (u_btn.justPressed()) {
bool was_held = false;
pressed = true;
while(!u_btn.justReleased()) {
u_btn.justPressed();
// Remove letter from string
if (u_btn.isHeld()) {
wifi_scan_obj.current_mini_kb_ssid.remove(wifi_scan_obj.current_mini_kb_ssid.length() - 1);
was_held = true;
break;
}
}
if (!was_held) {
if (this->mini_kb_index > 0)
this->mini_kb_index--;
else
this->mini_kb_index = str_len - 2;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu);
}
}
#endif
// Add SSID
#ifdef HAS_C
if (c_btn.justPressed()) {
while (!c_btn.justReleased()) {
c_btn.justPressed(); // Need to continue updating button hold status. My shitty library.
// Exit
if (c_btn.isHeld()) {
this->changeMenu(targetMenu->parentMenu);
return;
}
delay(1);
}
// If we have a string, add it to list of SSIDs
if (wifi_scan_obj.current_mini_kb_ssid != "") {
pressed = true;
ssid s = {wifi_scan_obj.current_mini_kb_ssid, random(1, 12), {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
ssids->unshift(s);
wifi_scan_obj.current_mini_kb_ssid = "";
}
}
#endif
#endif
// Keyboard functions for touch hardware
#ifdef HAS_TOUCH
bool touched = display_obj.updateTouch(&t_x, &t_y);
uint8_t menu_button = display_obj.menuButton(&t_x, &t_y, touched);
// Cycle char previous
if (menu_button == UP_BUTTON) {
pressed = true; pressed = true;
if (this->mini_kb_index > 0) if (this->mini_kb_index > 0)
this->mini_kb_index--; this->mini_kb_index--;
@@ -2798,14 +3033,13 @@ void MenuFunctions::RunSetup()
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL}); targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu); this->buildButtons(targetMenu);
while (!l_btn.justReleased()) while (display_obj.updateTouch(&t_x, &t_y) > 0)
delay(1); delay(1);
display_obj.menuButton(&t_x, &t_y, display_obj.updateTouch(&t_x, &t_y));
} }
#endif
// Cycle char next // Cycle char next
#ifdef HAS_R if (menu_button == DOWN_BUTTON) {
if (r_btn.justPressed()) {
pressed = true; pressed = true;
if (this->mini_kb_index < str_len - 2) if (this->mini_kb_index < str_len - 2)
this->mini_kb_index++; this->mini_kb_index++;
@@ -2814,108 +3048,119 @@ void MenuFunctions::RunSetup()
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL}); targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str()); this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str());
while (!r_btn.justReleased()) while (display_obj.updateTouch(&t_x, &t_y) > 0)
delay(1); delay(1);
display_obj.menuButton(&t_x, &t_y, display_obj.updateTouch(&t_x, &t_y));
} }
#endif
//// 5-WAY SWITCH STUFF //// 5-WAY SWITCH STUFF
// Add character // Add character when select button is pressed
#if (defined(HAS_D) && defined(HAS_R)) if (menu_button == SELECT_BUTTON) {
if (d_btn.justPressed()) {
pressed = true; pressed = true;
wifi_scan_obj.current_mini_kb_ssid.concat(String(char_array[this->mini_kb_index]).c_str()); wifi_scan_obj.current_mini_kb_ssid.concat(String(char_array[this->mini_kb_index]).c_str());
while (!d_btn.justReleased()) while (display_obj.updateTouch(&t_x, &t_y) > 0)
delay(1); delay(1);
display_obj.menuButton(&t_x, &t_y, display_obj.updateTouch(&t_x, &t_y));
} }
#endif
// Remove character // Remove character when select button is held
#if (defined(HAS_U) && defined(HAS_L)) if ((display_obj.isTouchHeld()) && (display_obj.menuButton(&t_x, &t_y, touched, true) == SELECT_BUTTON)) {
if (u_btn.justPressed()) {
pressed = true; pressed = true;
wifi_scan_obj.current_mini_kb_ssid.remove(wifi_scan_obj.current_mini_kb_ssid.length() - 1); wifi_scan_obj.current_mini_kb_ssid.remove(wifi_scan_obj.current_mini_kb_ssid.length() - 1);
while (!u_btn.justReleased()) while (display_obj.menuButton(&t_x, &t_y, display_obj.updateTouch(&t_x, &t_y)) < 0)
delay(1); delay(1);
} }
#endif
//// PARTIAL SWITCH STUFF //// PARTIAL SWITCH STUFF
// Advance char or add char // Advance char or add char
#if (defined(HAS_D) && !defined(HAS_R)) #if (defined(HAS_D) && !defined(HAS_R))
if (d_btn.justPressed()) { if (d_btn.justPressed()) {
bool was_held = false; bool was_held = false;
pressed = true;
while(!d_btn.justReleased()) {
d_btn.justPressed();
// Add letter to string
if (d_btn.isHeld()) {
wifi_scan_obj.current_mini_kb_ssid.concat(String(char_array[this->mini_kb_index]).c_str());
was_held = true;
break;
}
}
if (!was_held) {
if (this->mini_kb_index < str_len - 2)
this->mini_kb_index++;
else
this->mini_kb_index = 0;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str());
}
}
#endif
// Prev char or remove char
#if (defined(HAS_U) && !defined(HAS_L))
if (u_btn.justPressed()) {
bool was_held = false;
pressed = true;
while(!u_btn.justReleased()) {
u_btn.justPressed();
// Remove letter from string
if (u_btn.isHeld()) {
wifi_scan_obj.current_mini_kb_ssid.remove(wifi_scan_obj.current_mini_kb_ssid.length() - 1);
was_held = true;
break;
}
}
if (!was_held) {
if (this->mini_kb_index > 0)
this->mini_kb_index--;
else
this->mini_kb_index = str_len - 2;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu);
}
}
#endif
// Add SSID
#ifdef HAS_C
if (c_btn.justPressed()) {
while (!c_btn.justReleased()) {
c_btn.justPressed(); // Need to continue updating button hold status. My shitty library.
// Exit
if (c_btn.isHeld()) {
this->changeMenu(targetMenu->parentMenu);
return;
}
delay(1);
}
// If we have a string, add it to list of SSIDs
if (wifi_scan_obj.current_mini_kb_ssid != "") {
pressed = true; pressed = true;
ssid s = {wifi_scan_obj.current_mini_kb_ssid, random(1, 12), {random(256), random(256), random(256), random(256), random(256), random(256)}, false}; while(!d_btn.justReleased()) {
ssids->unshift(s); d_btn.justPressed();
wifi_scan_obj.current_mini_kb_ssid = "";
// Add letter to string
if (d_btn.isHeld()) {
wifi_scan_obj.current_mini_kb_ssid.concat(String(char_array[this->mini_kb_index]).c_str());
was_held = true;
break;
}
}
if (!was_held) {
if (this->mini_kb_index < str_len - 2)
this->mini_kb_index++;
else
this->mini_kb_index = 0;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str());
}
} }
#endif
// Prev char or remove char
#if (defined(HAS_U) && !defined(HAS_L))
if (u_btn.justPressed()) {
bool was_held = false;
pressed = true;
while(!u_btn.justReleased()) {
u_btn.justPressed();
// Remove letter from string
if (u_btn.isHeld()) {
wifi_scan_obj.current_mini_kb_ssid.remove(wifi_scan_obj.current_mini_kb_ssid.length() - 1);
was_held = true;
break;
}
}
if (!was_held) {
if (this->mini_kb_index > 0)
this->mini_kb_index--;
else
this->mini_kb_index = str_len - 2;
targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFTCYAN, 0, NULL, true, NULL});
this->buildButtons(targetMenu);
}
}
#endif
// Add SSID
/*#ifdef HAS_C
if (menu_button == SELECT_BUTTON) {
while (display_obj.updateTouch(&t_x, &t_y)) {
///c_btn.justPressed(); // Need to continue updating button hold status. My shitty library.
delay(1);
}
// If we have a string, add it to list of SSIDs
if (wifi_scan_obj.current_mini_kb_ssid != "") {
pressed = true;
ssid s = {wifi_scan_obj.current_mini_kb_ssid, random(1, 12), {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
ssids->unshift(s);
wifi_scan_obj.current_mini_kb_ssid = "";
}
}
#endif*/
// Exit if UP button is held
if ((display_obj.isTouchHeld()) && (display_obj.menuButton(&t_x, &t_y, touched, true) == UP_BUTTON)) {
display_obj.clearScreen();
while (display_obj.menuButton(&t_x, &t_y, display_obj.updateTouch(&t_x, &t_y)) < 0)
delay(1);
// Reset the touch keys so we don't activate the keys when we go back
display_obj.menuButton(&t_x, &t_y, display_obj.updateTouch(&t_x, &t_y));
this->changeMenu(targetMenu->parentMenu);
return;
} }
// If the screen is touched but none of the keys are used, don't refresh display
if (menu_button < 0)
pressed = false;
#endif #endif
// Display info on screen // Display info on screen
@@ -2932,17 +3177,26 @@ void MenuFunctions::RunSetup()
display_obj.tft.println(ssids->get(0).essid); display_obj.tft.println(ssids->get(0).essid);
display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK); display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK);
display_obj.tft.println("U/D - Rem/Add Char"); #ifdef HAS_MINI_KB
display_obj.tft.println("L/R - Prev/Nxt Char"); display_obj.tft.println("U/D - Rem/Add Char");
display_obj.tft.println("C - Save"); display_obj.tft.println("L/R - Prev/Nxt Char");
display_obj.tft.println("C(Hold) - Exit"); display_obj.tft.println("C - Save");
display_obj.tft.println("C(Hold) - Exit");
#endif
#ifdef HAS_TOUCH
display_obj.tft.println("U/D - Prev/Nxt Char");
display_obj.tft.println("C - Add Char");
display_obj.tft.println("C(Hold) - Rem Char");
display_obj.tft.println("U(Hold) - Enter");
#endif
pressed = false; pressed = false;
} }
} }
#endif //#endif
#endif #endif
} }
#endif //#endif
// Function to show all MenuNodes in a Menu // Function to show all MenuNodes in a Menu
void MenuFunctions::showMenuList(Menu * menu, int layer) void MenuFunctions::showMenuList(Menu * menu, int layer)

View File

@@ -84,6 +84,7 @@ PROGMEM static lv_disp_buf_t disp_buf;
PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10]; PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event); PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
PROGMEM static void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event); PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void html_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void html_list_cb(lv_obj_t * btn, lv_event_t event);
PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
@@ -213,9 +214,9 @@ class MenuFunctions
void displaySetting(String key, Menu* menu, int index); void displaySetting(String key, Menu* menu, int index);
void buttonSelected(int b, int x = -1); void buttonSelected(int b, int x = -1);
void buttonNotSelected(int b, int x = -1); void buttonNotSelected(int b, int x = -1);
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
void miniKeyboard(Menu * targetMenu); void miniKeyboard(Menu * targetMenu);
#endif //#endif
public: public:
MenuFunctions(); MenuFunctions();
@@ -249,6 +250,7 @@ class MenuFunctions
String loaded_file = ""; String loaded_file = "";
void joinWiFiGFX(String essid);
void setGraphScale(float scale); void setGraphScale(float scale);
void initLVGL(); void initLVGL();
void deinitLVGL(); void deinitLVGL();

View File

@@ -691,7 +691,7 @@ int WiFiScan::generateSSIDs(int count) {
return num_gen; return num_gen;
} }
/*void WiFiScan::joinWiFi(String ssid, String password) void WiFiScan::joinWiFi(String ssid, String password)
{ {
static const char * btns[] ={text16, ""}; static const char * btns[] ={text16, ""};
int count = 0; int count = 0;
@@ -712,10 +712,10 @@ int WiFiScan::generateSSIDs(int count) {
WiFi.disconnect(); WiFi.disconnect();
} }
esp_wifi_init(&cfg); //esp_wifi_init(&cfg);
esp_wifi_set_storage(WIFI_STORAGE_RAM); //esp_wifi_set_storage(WIFI_STORAGE_RAM);
esp_wifi_set_mode(WIFI_MODE_NULL); //esp_wifi_set_mode(WIFI_MODE_NULL);
esp_wifi_start(); //esp_wifi_start();
WiFi.begin(ssid.c_str(), password.c_str()); WiFi.begin(ssid.c_str(), password.c_str());
@@ -724,7 +724,7 @@ int WiFiScan::generateSSIDs(int count) {
delay(500); delay(500);
Serial.print("."); Serial.print(".");
count++; count++;
if (count == 10) if (count == 20)
{ {
Serial.println("\nCould not connect to WiFi network"); Serial.println("\nCould not connect to WiFi network");
#ifdef HAS_SCREEN #ifdef HAS_SCREEN
@@ -753,7 +753,7 @@ int WiFiScan::generateSSIDs(int count) {
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
this->wifi_initialized = true; this->wifi_initialized = true;
}*/ }
// Apply WiFi settings // Apply WiFi settings
void WiFiScan::initWiFi(uint8_t scan_mode) { void WiFiScan::initWiFi(uint8_t scan_mode) {
@@ -881,6 +881,11 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
RunLvJoinWiFi(scan_mode, color); RunLvJoinWiFi(scan_mode, color);
#endif #endif
} }
else if (scan_mode == LV_JOIN_WIFI) {
#ifdef HAS_SCREEN
RunLvJoinWiFi(scan_mode, color);
#endif
}
else if (scan_mode == WIFI_SCAN_GPS_NMEA){ else if (scan_mode == WIFI_SCAN_GPS_NMEA){
#ifdef HAS_GPS #ifdef HAS_GPS
gps_obj.enable_queue(); gps_obj.enable_queue();
@@ -1066,7 +1071,8 @@ void WiFiScan::StopScan(uint8_t scan_mode)
(currentScanMode == WIFI_PACKET_MONITOR) || (currentScanMode == WIFI_PACKET_MONITOR) ||
(currentScanMode == WIFI_SCAN_CHAN_ANALYZER) || (currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(currentScanMode == WIFI_SCAN_PACKET_RATE) || (currentScanMode == WIFI_SCAN_PACKET_RATE) ||
(currentScanMode == LV_JOIN_WIFI)) (currentScanMode == LV_JOIN_WIFI) ||
(this->wifi_initialized))
{ {
this->shutdownWiFi(); this->shutdownWiFi();

View File

@@ -586,7 +586,7 @@ class WiFiScan
bool shutdownWiFi(); bool shutdownWiFi();
bool shutdownBLE(); bool shutdownBLE();
bool scanning(); bool scanning();
//void joinWiFi(String ssid, String password); void joinWiFi(String ssid, String password);
String getStaMAC(); String getStaMAC();
String getApMAC(); String getApMAC();
String freeRAM(); String freeRAM();

View File

@@ -27,7 +27,7 @@
//#define MARAUDER_CYD_GUITION // ESP32-2432S024 GUITION //#define MARAUDER_CYD_GUITION // ESP32-2432S024 GUITION
//// END BOARD TARGETS //// END BOARD TARGETS
#define MARAUDER_VERSION "v1.6.2" #define MARAUDER_VERSION "v1.7.0"
#define GRAPH_REFRESH 100 #define GRAPH_REFRESH 100
@@ -75,6 +75,7 @@
//// BOARD FEATURES //// BOARD FEATURES
#if defined(MARAUDER_M5STICKC) || defined(MARAUDER_M5STICKCP2) #if defined(MARAUDER_M5STICKC) || defined(MARAUDER_M5STICKCP2)
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
#define HAS_MINI_KB
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT
#define HAS_BUTTONS #define HAS_BUTTONS
@@ -91,6 +92,7 @@
#ifdef MARAUDER_MINI #ifdef MARAUDER_MINI
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
//#define HAS_BATTERY //#define HAS_BATTERY
#define HAS_MINI_KB
#define HAS_BT #define HAS_BT
#define HAS_BUTTONS #define HAS_BUTTONS
#define HAS_NEOPIXEL_LED #define HAS_NEOPIXEL_LED
@@ -105,6 +107,7 @@
#ifdef MARAUDER_V7 #ifdef MARAUDER_V7
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
#define HAS_MINI_KB
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT
#define HAS_BT_REMOTE #define HAS_BT_REMOTE
@@ -121,6 +124,7 @@
#ifdef MARAUDER_V7_1 #ifdef MARAUDER_V7_1
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
#define HAS_MINI_KB
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT
#define HAS_BT_REMOTE #define HAS_BT_REMOTE
@@ -140,6 +144,7 @@
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
//#define HAS_BATTERY //#define HAS_BATTERY
//#define HAS_BT //#define HAS_BT
#define HAS_MINI_KB
#define HAS_BUTTONS #define HAS_BUTTONS
#define HAS_NEOPIXEL_LED #define HAS_NEOPIXEL_LED
//#define HAS_PWR_MGMT //#define HAS_PWR_MGMT
@@ -152,6 +157,7 @@
#endif #endif
#ifdef MARAUDER_V4 #ifdef MARAUDER_V4
#define HAS_TOUCH
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT
@@ -167,6 +173,7 @@
#endif #endif
#if defined(MARAUDER_V6) || defined(MARAUDER_V6_1) #if defined(MARAUDER_V6) || defined(MARAUDER_V6_1)
#define HAS_TOUCH
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT
@@ -183,6 +190,7 @@
#endif #endif
#ifdef MARAUDER_CYD_MICRO #ifdef MARAUDER_CYD_MICRO
#define HAS_TOUCH
#define HAS_FLIPPER_LED #define HAS_FLIPPER_LED
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
//#define HAS_BATTERY //#define HAS_BATTERY
@@ -201,6 +209,7 @@
#endif #endif
#ifdef MARAUDER_CYD_2USB #ifdef MARAUDER_CYD_2USB
#define HAS_TOUCH
#define HAS_FLIPPER_LED #define HAS_FLIPPER_LED
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
//#define HAS_BATTERY //#define HAS_BATTERY
@@ -220,6 +229,7 @@
#endif #endif
#ifdef MARAUDER_CYD_GUITION #ifdef MARAUDER_CYD_GUITION
#define HAS_TOUCH
#define HAS_FLIPPER_LED #define HAS_FLIPPER_LED
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
//#define HAS_BATTERY //#define HAS_BATTERY
@@ -238,6 +248,7 @@
#endif #endif
#ifdef MARAUDER_KIT #ifdef MARAUDER_KIT
#define HAS_TOUCH
//#define FLIPPER_ZERO_HAT //#define FLIPPER_ZERO_HAT
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT