Remove unused methods and banner

This commit is contained in:
Just Call Me Koko
2023-09-04 21:20:51 -04:00
parent edbd601af7
commit 8f2b9c709a
9 changed files with 36 additions and 470 deletions

View File

@@ -240,7 +240,6 @@ void CommandLine::runCommand(String input) {
Serial.println(HELP_SEL_CMD_A); Serial.println(HELP_SEL_CMD_A);
Serial.println(HELP_SSID_CMD_A); Serial.println(HELP_SSID_CMD_A);
Serial.println(HELP_SSID_CMD_B); Serial.println(HELP_SSID_CMD_B);
Serial.println(HELP_JOIN_WIFI_CMD);
// Bluetooth sniff/scan // Bluetooth sniff/scan
Serial.println(HELP_BT_SNIFF_CMD); Serial.println(HELP_BT_SNIFF_CMD);
@@ -995,7 +994,7 @@ void CommandLine::runCommand(String input) {
} }
} }
// Join WiFi // Join WiFi
else if (cmd_args.get(0) == JOINWIFI_CMD) { /*else if (cmd_args.get(0) == JOINWIFI_CMD) {
int n_sw = this->argSearch(&cmd_args, "-n"); // name int n_sw = this->argSearch(&cmd_args, "-n"); // name
int a_sw = this->argSearch(&cmd_args, "-a"); // access point int a_sw = this->argSearch(&cmd_args, "-a"); // access point
int s_sw = this->argSearch(&cmd_args, "-s"); // ssid int s_sw = this->argSearch(&cmd_args, "-s"); // ssid
@@ -1030,5 +1029,5 @@ void CommandLine::runCommand(String input) {
} }
Serial.println("Attempting to join WiFi with ssid " + (String)essid); Serial.println("Attempting to join WiFi with ssid " + (String)essid);
wifi_scan_obj.joinWiFi(essid, pwx); wifi_scan_obj.joinWiFi(essid, pwx);
} }*/
} }

View File

@@ -71,7 +71,6 @@ const char PROGMEM ATTACK_TYPE_RR[] = "rickroll";
const char PROGMEM LIST_AP_CMD[] = "list"; const char PROGMEM LIST_AP_CMD[] = "list";
const char PROGMEM SEL_CMD[] = "select"; const char PROGMEM SEL_CMD[] = "select";
const char PROGMEM SSID_CMD[] = "ssid"; const char PROGMEM SSID_CMD[] = "ssid";
const char PROGMEM JOINWIFI_CMD[] = "join";
// Bluetooth sniff/scan // Bluetooth sniff/scan
const char PROGMEM BT_SNIFF_CMD[] = "sniffbt"; const char PROGMEM BT_SNIFF_CMD[] = "sniffbt";
@@ -102,7 +101,6 @@ const char PROGMEM HELP_SNIFF_ESP_CMD[] = "sniffesp";
const char PROGMEM HELP_SNIFF_DEAUTH_CMD[] = "sniffdeauth"; const char PROGMEM HELP_SNIFF_DEAUTH_CMD[] = "sniffdeauth";
const char PROGMEM HELP_SNIFF_PMKID_CMD[] = "sniffpmkid [-c <channel>][-d][-l]"; const char PROGMEM HELP_SNIFF_PMKID_CMD[] = "sniffpmkid [-c <channel>][-d][-l]";
const char PROGMEM HELP_STOPSCAN_CMD[] = "stopscan"; const char PROGMEM HELP_STOPSCAN_CMD[] = "stopscan";
const char PROGMEM HELP_JOIN_WIFI_CMD[] = "join [-n <ssid_name>/-s <ssid_index>/-a <access_point_index>] -p <password>";
// WiFi attack // WiFi attack
const char PROGMEM HELP_ATTACK_CMD[] = "attack -t <beacon [-l/-r/-a]/deauth [-c]/[-s <src mac>] [-d <dst mac>]/probe/rickroll>"; const char PROGMEM HELP_ATTACK_CMD[] = "attack -t <beacon [-l/-r/-a]/deauth [-c]/[-s <src mac>] [-d <dst mac>]/probe/rickroll>";

View File

@@ -751,20 +751,20 @@ void Display::listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
void Display::updateBanner(String msg) void Display::updateBanner(String msg)
{ {
this->img.deleteSprite(); //this->img.deleteSprite();
this->img.setColorDepth(8); //this->img.setColorDepth(8);
this->img.createSprite(SCREEN_WIDTH, TEXT_HEIGHT); //this->img.createSprite(SCREEN_WIDTH, TEXT_HEIGHT);
this->buildBanner(msg, current_banner_pos); this->buildBanner(msg, current_banner_pos);
this->img.pushSprite(0, STATUS_BAR_WIDTH); //this->img.pushSprite(0, STATUS_BAR_WIDTH);
current_banner_pos--; //current_banner_pos--;
if (current_banner_pos <= 0) //if (current_banner_pos <= 0)
current_banner_pos = SCREEN_WIDTH + 2; // current_banner_pos = SCREEN_WIDTH + 2;
} }
@@ -772,6 +772,13 @@ void Display::buildBanner(String msg, int xpos)
{ {
int h = TEXT_HEIGHT; int h = TEXT_HEIGHT;
this->tft.fillRect(0, STATUS_BAR_WIDTH, SCREEN_WIDTH, TEXT_HEIGHT, TFT_BLACK);
this->tft.setTextSize(BANNER_TEXT_SIZE); // Font size scaling is x1
this->tft.setTextFont(0); // Font 4 selected
this->tft.setTextColor(TFT_WHITE, TFT_BLACK); // Black text, no background colour
this->tft.drawCentreString(msg.c_str(), SCREEN_WIDTH / 2, TEXT_HEIGHT, 2);
/*
// We could just use fillSprite(color) but lets be a bit more creative... // We could just use fillSprite(color) but lets be a bit more creative...
// Fill with rainbow stripes // Fill with rainbow stripes
@@ -793,6 +800,7 @@ void Display::buildBanner(String msg, int xpos)
img.setCursor(xpos - SCREEN_WIDTH, 2); // Print text at xpos - sprite width img.setCursor(xpos - SCREEN_WIDTH, 2); // Print text at xpos - sprite width
img.print(msg); img.print(msg);
*/
} }
void Display::main(uint8_t scan_mode) void Display::main(uint8_t scan_mode)

View File

@@ -85,7 +85,7 @@ class Display
Display(); Display();
//Ticker tick; //Ticker tick;
TFT_eSPI tft = TFT_eSPI(); TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft); //TFT_eSprite img = TFT_eSprite(&tft);
TFT_eSPI_Button key[BUTTON_ARRAY_LEN]; TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
const String PROGMEM version_number = MARAUDER_VERSION; const String PROGMEM version_number = MARAUDER_VERSION;

View File

@@ -69,17 +69,9 @@ MenuFunctions::MenuFunctions()
data->state = touched ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; data->state = touched ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
//if(data->state == LV_INDEV_STATE_PR) touchpad_get_xy(&last_x, &last_y);
data->point.x = touchX; data->point.x = touchX;
data->point.y = touchY; data->point.y = touchY;
//Serial.print("Data x");
//Serial.println(touchX);
//Serial.print("Data y");
//Serial.println(touchY);
} }
return false; return false;
@@ -113,141 +105,10 @@ MenuFunctions::MenuFunctions()
//lv_deinit(); //lv_deinit();
} }
/*void MenuFunctions::writeBadUSB(){
// 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, write_bad_usb_keyboard_event_cb);
// Create one text area
// Store all SSIDs
ta1 = lv_textarea_create(lv_scr_act(), NULL);
lv_textarea_set_cursor_hidden(ta1, false);
lv_textarea_set_one_line(ta1, false);
lv_obj_set_width(ta1, LV_HOR_RES);
lv_obj_set_height(ta1, (LV_VER_RES / 2) - 35);
lv_obj_set_pos(ta1, 5, 20);
lv_textarea_set_cursor_hidden(ta1, true);
lv_obj_align(ta1, NULL, LV_ALIGN_IN_TOP_MID, NULL, NULL);
lv_textarea_set_text(ta1, "");
lv_textarea_set_placeholder_text(ta1, "Ducky script");
#ifndef WRITE_PACKETS_SERIAL
if (sd_obj.supported) {
// Create load button
lv_obj_t * label;
lv_obj_t * load_btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(load_btn, load_btn_cb);
lv_obj_set_height(load_btn, 35);
lv_obj_set_width(load_btn, LV_HOR_RES / 3);
lv_obj_align(load_btn, ta1, LV_ALIGN_IN_TOP_RIGHT, NULL, (LV_VER_RES / 2) - 35); // align to text area
label = lv_label_create(load_btn, NULL);
lv_label_set_text(label, text05);
// Create Save As button
lv_obj_t * label2;
lv_obj_t * save_as_btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(save_as_btn, load_btn_cb);
lv_obj_set_height(save_as_btn, 35);
lv_obj_set_width(save_as_btn, LV_HOR_RES / 3);
lv_obj_align(save_as_btn, ta1, LV_ALIGN_IN_TOP_MID, NULL, (LV_VER_RES / 2) - 35); // align to text area
label2 = lv_label_create(save_as_btn, NULL);
lv_label_set_text(label2, text06);
}
#endif
// Focus it on one of the text areas to start
lv_keyboard_set_textarea(kb, ta1);
lv_keyboard_set_cursor_manage(kb, true);
}*/
// Event handler for settings drop down menus // Event handler for settings drop down menus
void setting_dropdown_cb(lv_obj_t * obj, lv_event_t event) { void setting_dropdown_cb(lv_obj_t * obj, lv_event_t event) {
//lv_event_code_t code = lv_event_get_code(event);
//lv_obj_t * obj = lv_event_get_target(event);
//lv_obj_t * list1 = lv_obj_get_parent(lv_obj_get_parent(obj));
//if(event == LV_EVENT_CLICKED) {
// LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
//}
}
void settings_list_cb(lv_obj_t * btn, lv_event_t event) {
extern Settings settings_obj;
extern MenuFunctions menu_function_obj;
String btn_text = lv_list_get_btn_text(btn);
String display_string = "";
if (event == LV_EVENT_CLICKED) {
if (btn_text == text07) {
Serial.println("Exiting...");
lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn)));
printf("LV_EVENT_CANCEL\n");
Serial.println("Potato");
//menu_function_obj.deinitLVGL();
//wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
//display_obj.exit_draw = true; // set everything back to normal
}
else {
// Build base obj to host buttons
Serial.println("Creating base object...");
lv_obj_t * obj;
obj = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES);
lv_obj_t * exit_btn;
lv_obj_t * label;
// Build the generic Exit button
exit_btn = lv_btn_create(obj, NULL);
lv_obj_set_event_cb(exit_btn, settings_list_cb);
lv_label_set_text(label, text07);
//lv_obj_center(label);
label = lv_label_create(exit_btn, NULL);
// Create the type specific device
if (settings_obj.getSettingType(btn_text) == "bool") {
lv_obj_t * sw = lv_switch_create(obj, NULL);
lv_obj_align(sw, NULL, LV_ALIGN_CENTER, 0, 0);
}
}
}
}
void MenuFunctions::displaySettingsGFX(){
extern Settings settings_obj;
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, settings_obj.getSettingsString())) {
Serial.println("\nCould not parse json");
}
lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
lv_obj_set_size(list1, 160, 200);
lv_obj_set_width(list1, LV_HOR_RES);
lv_obj_align(list1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_t * list_btn;
lv_obj_t * label;
lv_obj_t * sw;
list_btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, text07);
lv_obj_set_event_cb(list_btn, ap_list_cb);
for (int i = 0; i < json[text09].size(); i++) {
char buf[json[text08][i]["name"].as<String>().length() + 1] = {};
json[text08][i]["name"].as<String>().toCharArray(buf, json[text08][i]["name"].as<String>().length() + 1);
list_btn = lv_list_add_btn(list1, LV_SYMBOL_WIFI, buf);
lv_btn_set_checkable(list_btn, false);
lv_obj_set_event_cb(list_btn, settings_list_cb);
}
} }
// GFX Function to build a list showing all Stations scanned // GFX Function to build a list showing all Stations scanned
@@ -285,9 +146,6 @@ MenuFunctions::MenuFunctions()
// Convert uint8_t MAC to char array // Convert uint8_t MAC to char array
wifi_scan_obj.getMAC(addr, cur_sta.mac, 0); wifi_scan_obj.getMAC(addr, cur_sta.mac, 0);
//char buf[stations->get(i).mac.length() + 1] = {};
//stations->get(i).mac.toCharArray(buf, stations->get(i).mac.length() + 1);
list_btn = lv_list_add_btn(list1, LV_SYMBOL_WIFI, addr); list_btn = lv_list_add_btn(list1, LV_SYMBOL_WIFI, addr);
lv_btn_set_checkable(list_btn, true); lv_btn_set_checkable(list_btn, true);
lv_obj_set_event_cb(list_btn, station_list_cb); lv_obj_set_event_cb(list_btn, station_list_cb);
@@ -310,7 +168,6 @@ MenuFunctions::MenuFunctions()
if (event == LV_EVENT_CLICKED) { if (event == LV_EVENT_CLICKED) {
if (btn_text != text09) { if (btn_text != text09) {
//lv_list_focus_btn(lv_obj_get_parent(lv_obj_get_parent(btn)), btn);
} }
else { else {
Serial.println("Exiting..."); Serial.println("Exiting...");
@@ -333,8 +190,6 @@ MenuFunctions::MenuFunctions()
if (event == LV_EVENT_VALUE_CHANGED) { if (event == LV_EVENT_VALUE_CHANGED) {
if (lv_btn_get_state(btn) == LV_BTN_STATE_CHECKED_RELEASED) { if (lv_btn_get_state(btn) == LV_BTN_STATE_CHECKED_RELEASED) {
//Serial.print("Toggle on: ");
//Serial.println(btn_text);
for (int i = 0; i < stations->size(); i++) { for (int i = 0; i < stations->size(); i++) {
wifi_scan_obj.getMAC(addr, stations->get(i).mac, 0); wifi_scan_obj.getMAC(addr, stations->get(i).mac, 0);
if (strcmp(addr, btn_text.c_str()) == 0) { if (strcmp(addr, btn_text.c_str()) == 0) {
@@ -347,8 +202,6 @@ MenuFunctions::MenuFunctions()
} }
} }
else { else {
//Serial.print("Toggle off: ");
//Serial.println(btn_text);
for (int i = 0; i < stations->size(); i++) { for (int i = 0; i < stations->size(); i++) {
wifi_scan_obj.getMAC(addr, stations->get(i).mac, 0); wifi_scan_obj.getMAC(addr, stations->get(i).mac, 0);
if (strcmp(addr, btn_text.c_str()) == 0) { if (strcmp(addr, btn_text.c_str()) == 0) {
@@ -403,7 +256,6 @@ MenuFunctions::MenuFunctions()
if (event == LV_EVENT_CLICKED) { if (event == LV_EVENT_CLICKED) {
if (btn_text != text09) { if (btn_text != text09) {
//lv_list_focus_btn(lv_obj_get_parent(lv_obj_get_parent(btn)), btn);
} }
else { else {
Serial.println("Exiting..."); Serial.println("Exiting...");
@@ -424,8 +276,6 @@ MenuFunctions::MenuFunctions()
if (event == LV_EVENT_VALUE_CHANGED) { if (event == LV_EVENT_VALUE_CHANGED) {
if (lv_btn_get_state(btn) == LV_BTN_STATE_CHECKED_RELEASED) { if (lv_btn_get_state(btn) == LV_BTN_STATE_CHECKED_RELEASED) {
//Serial.print("Toggle on: ");
//Serial.println(btn_text);
for (int i = 0; i < access_points->size(); i++) { for (int i = 0; i < access_points->size(); i++) {
if (access_points->get(i).essid == btn_text) { if (access_points->get(i).essid == btn_text) {
Serial.println("Adding AP: " + (String)access_points->get(i).essid); Serial.println("Adding AP: " + (String)access_points->get(i).essid);
@@ -436,8 +286,6 @@ MenuFunctions::MenuFunctions()
} }
} }
else { else {
//Serial.print("Toggle off: ");
//Serial.println(btn_text);
for (int i = 0; i < access_points->size(); i++) { for (int i = 0; i < access_points->size(); i++) {
if (access_points->get(i).essid == btn_text) { if (access_points->get(i).essid == btn_text) {
Serial.println("Removing AP: " + (String)access_points->get(i).essid); Serial.println("Removing AP: " + (String)access_points->get(i).essid);
@@ -491,244 +339,6 @@ MenuFunctions::MenuFunctions()
} }
void MenuFunctions::joinWiFiGFX(){
// 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, "");
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, text_table1[2]);
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, text_table1[3]);
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);
}
// Function to create keyboard for saving file name
void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) {
extern MenuFunctions menu_function_obj;
lv_keyboard_def_event_cb(save_as_kb, event);
// User canceled so we will get rid of the keyboard and text box
if (event == LV_EVENT_CANCEL) {
lv_obj_del_async(save_as_kb);
lv_obj_del_async(save_name);
}
// Save content from ta1 to file name in save_name
else if(event == LV_EVENT_APPLY){
String display_string = "";
printf("LV_EVENT_APPLY\n");
// Get ducky script
String content = lv_textarea_get_text(ta1);
String target_file_name = "/SCRIPTS/" + (String)lv_textarea_get_text(save_name);
Serial.println("Writing to target file: " + (String)target_file_name);
// Open file with the given name
File script = SD.open(target_file_name, FILE_WRITE);
if (script) {
menu_function_obj.loaded_file = target_file_name;
Serial.println("Writing content: ");
Serial.println(content);
script.print(content);
script.close();
}
lv_obj_del_async(save_as_kb);
lv_obj_del_async(save_name);
// Create Save button
lv_obj_t * save_label;
lv_obj_t * save_btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(save_btn, load_btn_cb);
lv_obj_set_height(save_btn, 35);
lv_obj_set_width(save_btn, LV_HOR_RES / 3);
lv_obj_align(save_btn, ta1, LV_ALIGN_IN_TOP_LEFT, NULL, (LV_VER_RES / 2) - 35); // align to text area
save_label = lv_label_create(save_btn, NULL);
lv_label_set_text(save_label, text13);
}
}
void test_btn_cb(lv_obj_t * btn, lv_event_t event) {
extern MenuFunctions menu_function_obj;
if (event == LV_EVENT_CLICKED) {
String btn_text = lv_list_get_btn_text(btn);
String display_string = "";
//printf("Clicked: %s\n", btn_text);
Serial.print("Clicked: ");
Serial.println(btn_text);
// Get file content and send to text area
if (btn_text != text12) {
File script = SD.open(btn_text);
if (script) {
while (script.available()) {
display_string.concat((char)script.read());
}
script.close();
Serial.println(display_string);
char buf[display_string.length() + 1] = {};
display_string.toCharArray(buf, display_string.length() + 1);
lv_textarea_set_text(ta1, buf);
// Create Save button
lv_obj_t * save_label;
lv_obj_t * save_btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(save_btn, load_btn_cb);
lv_obj_set_height(save_btn, 35);
lv_obj_set_width(save_btn, LV_HOR_RES / 3);
lv_obj_align(save_btn, ta1, LV_ALIGN_IN_TOP_LEFT, NULL, (LV_VER_RES / 2) - 35); // align to text area
save_label = lv_label_create(save_btn, NULL);
lv_label_set_text(save_label, text13);
}
}
// Delete the file list obj
lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn)));
menu_function_obj.loaded_file = btn_text;
}
}
void load_btn_cb(lv_obj_t * load_btn, lv_event_t event) {
extern SDInterface sd_obj;
extern MenuFunctions menu_function_obj;
String btn_text = lv_list_get_btn_text(load_btn);
if (btn_text == "Load") {
if (event == LV_EVENT_CLICKED)
Serial.println("Load button pressed");
else if (event == LV_EVENT_RELEASED) {
Serial.println("Load button released");
/*Create a list*/
lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
lv_obj_set_size(list1, 160, 200);
lv_obj_set_width(list1, LV_HOR_RES);
lv_obj_align(list1, NULL, LV_ALIGN_CENTER, 0, 0);
//lv_list_set_anim_time(list1, 0);
// Load file names into buttons
File scripts = SD.open("/SCRIPTS");
// Build list of files from the SD card
lv_obj_t * list_btn;
list_btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, text12);
lv_obj_set_event_cb(list_btn, test_btn_cb);
while (true) {
File entity = scripts.openNextFile();
if (!entity)
break;
if (!entity.isDirectory()) {
String file_name = entity.name();
// Fancy button text time
char buf[file_name.length() + 1] = {};
file_name.toCharArray(buf, file_name.length() + 1);
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, buf);
lv_obj_set_event_cb(list_btn, test_btn_cb);
}
entity.close();
}
scripts.close();
}
}
// Save current text bod content to new file
else if (btn_text == text06) {
if (event == LV_EVENT_CLICKED)
Serial.println("Save button pressed");
else if (event == LV_EVENT_RELEASED) {
Serial.println("Save button released");
save_name = lv_textarea_create(lv_scr_act(), ta2);
lv_textarea_set_cursor_hidden(save_name, false);
lv_textarea_set_one_line(save_name, true);
lv_obj_align(save_name, NULL, LV_ALIGN_IN_TOP_MID, NULL, (LV_VER_RES / 2) - 35);
lv_textarea_set_text(save_name, "");
lv_textarea_set_placeholder_text(save_name, "File Name");
// Create a keyboard and apply the styles
save_as_kb = lv_keyboard_create(lv_scr_act(), NULL);
lv_obj_set_size(save_as_kb, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_set_event_cb(save_as_kb, save_as_keyboard_event_cb);
lv_keyboard_set_textarea(save_as_kb, save_name);
lv_keyboard_set_cursor_manage(save_as_kb, true);
}
}
// Save current text box content to current loaded file
else if (btn_text == text13) {
if (event == LV_EVENT_CLICKED)
Serial.println("Save button pressed");
else if (event == LV_EVENT_RELEASED) {
Serial.println("Save button released");
Serial.println("Writing to file: " + (String)menu_function_obj.loaded_file);
File script = SD.open(menu_function_obj.loaded_file, FILE_WRITE);
// Write data to file
if (script) {
String content = lv_textarea_get_text(ta1);
Serial.println("Writing content:");
Serial.println(content);
Serial.println("to file: " + (String)menu_function_obj.loaded_file);
script.print(lv_textarea_get_text(ta1));
script.close();
}
}
}
}
// Keyboard callback dedicated to joining wifi // Keyboard callback dedicated to joining wifi
void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){ void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
extern Display display_obj; extern Display display_obj;
@@ -745,7 +355,6 @@ MenuFunctions::MenuFunctions()
// Get text from SSID text box // Get text from SSID text box
String ta2_text = lv_textarea_get_text(ta2); String ta2_text = lv_textarea_get_text(ta2);
//Serial.println(ta1_text);
Serial.println(ta2_text); Serial.println(ta2_text);
// Add text box text to list of SSIDs // Add text box text to list of SSIDs
@@ -759,32 +368,7 @@ MenuFunctions::MenuFunctions()
lv_textarea_set_text(ta2, ""); lv_textarea_set_text(ta2, "");
}else if(event == LV_EVENT_CANCEL){ }else if(event == LV_EVENT_CANCEL){
printf("LV_EVENT_CANCEL\n"); printf("LV_EVENT_CANCEL\n");
//lv_textarea_set_text(lv_keyboard_get_textarea(kb), "");
menu_function_obj.deinitLVGL(); menu_function_obj.deinitLVGL();
//wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
display_obj.exit_draw = true; // set everything back to normal
}
}
// Keyboard callback dedicated to joining wifi
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 display_obj.exit_draw = true; // set everything back to normal
} }
} }
@@ -830,11 +414,11 @@ void MenuFunctions::main(uint32_t currentTime)
this->orientDisplay(); this->orientDisplay();
wifi_scan_obj.orient_display = false; wifi_scan_obj.orient_display = false;
} }
#ifdef HAS_ILI9341 /*#ifdef HAS_ILI9341
if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) && if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) &&
(wifi_scan_obj.currentScanMode != LV_ADD_SSID)) (wifi_scan_obj.currentScanMode != LV_ADD_SSID))
display_obj.updateBanner(current_menu->name); display_obj.updateBanner(current_menu->name);
#endif #endif*/
} }
if (currentTime != 0) { if (currentTime != 0) {
@@ -843,9 +427,9 @@ void MenuFunctions::main(uint32_t currentTime)
if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) && if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) &&
(wifi_scan_obj.currentScanMode != LV_ADD_SSID)) (wifi_scan_obj.currentScanMode != LV_ADD_SSID))
this->updateStatusBar(); this->updateStatusBar();
#if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) //#if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC)
display_obj.updateBanner(current_menu->name); // display_obj.updateBanner(current_menu->name);
#endif //#endif
} }
} }
@@ -2168,6 +1752,7 @@ void MenuFunctions::displayCurrentMenu()
{ {
//Serial.println(F("Displaying current menu...")); //Serial.println(F("Displaying current menu..."));
display_obj.clearScreen(); display_obj.clearScreen();
display_obj.updateBanner(current_menu->name);
display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY); display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY);
this->drawStatusBar(); this->drawStatusBar();

View File

@@ -8,12 +8,8 @@
#define BATTERY_ANALOG_ON 0 #define BATTERY_ANALOG_ON 0
#include "WiFiScan.h" #include "WiFiScan.h"
//#include "Display.h"
#include "BatteryInterface.h" #include "BatteryInterface.h"
#include "SDInterface.h" #include "SDInterface.h"
//#include "Web.h"
//#include "esp_interface.h"
//#include "a32u4_interface.h"
#include "settings.h" #include "settings.h"
#ifdef HAS_BUTTONS #ifdef HAS_BUTTONS
@@ -25,13 +21,9 @@
extern SwitchLib c_btn; extern SwitchLib c_btn;
#endif #endif
//extern Display display_obj;
extern WiFiScan wifi_scan_obj; extern WiFiScan wifi_scan_obj;
//extern Web web_obj;
extern SDInterface sd_obj; extern SDInterface sd_obj;
extern BatteryInterface battery_obj; extern BatteryInterface battery_obj;
//extern EspInterface esp_obj;
//extern A32u4Interface a32u4_obj;
extern Settings settings_obj; extern Settings settings_obj;
#define FLASH_BUTTON 0 #define FLASH_BUTTON 0
@@ -85,15 +77,10 @@ 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 write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void load_btn_cb(lv_obj_t * load_btn, lv_event_t event);
PROGMEM static void test_btn_cb(lv_obj_t * load_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);
PROGMEM static void station_list_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void station_list_cb(lv_obj_t * btn, lv_event_t event);
PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event); PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event);
PROGMEM static void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
// lvgl stuff // lvgl stuff
PROGMEM static lv_obj_t *kb; PROGMEM static lv_obj_t *kb;
@@ -130,7 +117,6 @@ class MenuFunctions
uint32_t initTime = 0; uint32_t initTime = 0;
//Menu* current_menu;
// Main menu stuff // Main menu stuff
Menu mainMenu; Menu mainMenu;
@@ -138,14 +124,12 @@ class MenuFunctions
Menu wifiMenu; Menu wifiMenu;
Menu bluetoothMenu; Menu bluetoothMenu;
Menu badusbMenu; Menu badusbMenu;
//Menu generalMenu;
Menu deviceMenu; Menu deviceMenu;
// Device menu stuff // Device menu stuff
Menu whichUpdateMenu; Menu whichUpdateMenu;
Menu failedUpdateMenu; Menu failedUpdateMenu;
Menu confirmMenu; Menu confirmMenu;
//Menu espUpdateMenu;
Menu updateMenu; Menu updateMenu;
Menu settingsMenu; Menu settingsMenu;
Menu specSettingMenu; Menu specSettingMenu;
@@ -160,11 +144,8 @@ class MenuFunctions
// Bluetooth menu stuff // Bluetooth menu stuff
Menu bluetoothSnifferMenu; Menu bluetoothSnifferMenu;
//Menu bluetoothGeneralMenu;
// Settings things menus // Settings things menus
//Menu shutdownWiFiMenu;
//Menu shutdownBLEMenu;
Menu generateSSIDsMenu; Menu generateSSIDsMenu;
#ifdef HAS_GPS #ifdef HAS_GPS
@@ -179,7 +160,6 @@ class MenuFunctions
// Menu icons // Menu icons
//TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = ""); void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
void updateStatusBar(); void updateStatusBar();
@@ -208,13 +188,9 @@ class MenuFunctions
void initLVGL(); void initLVGL();
void deinitLVGL(); void deinitLVGL();
void joinWiFiGFX();
void addSSIDGFX(); void addSSIDGFX();
void addAPGFX(); void addAPGFX();
void addStationGFX(); void addStationGFX();
void displaySettingsGFX();
void writeBadUSB();
void buildButtons(Menu* menu, int starting_index = 0); void buildButtons(Menu* menu, int starting_index = 0);
void changeMenu(Menu* menu); void changeMenu(Menu* menu);
void drawStatusBar(); void drawStatusBar();

View File

@@ -207,7 +207,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;
@@ -218,7 +218,7 @@ void WiFiScan::joinWiFi(String ssid, String password)
lv_msgbox_set_text(mbox1, text_table4[2]); lv_msgbox_set_text(mbox1, text_table4[2]);
lv_msgbox_add_btns(mbox1, btns); lv_msgbox_add_btns(mbox1, btns);
lv_obj_set_width(mbox1, 200); lv_obj_set_width(mbox1, 200);
lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/ lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner
#endif #endif
this->wifi_initialized = true; this->wifi_initialized = true;
return; return;
@@ -249,7 +249,7 @@ void WiFiScan::joinWiFi(String ssid, String password)
lv_msgbox_add_btns(mbox1, btns); lv_msgbox_add_btns(mbox1, btns);
lv_obj_set_width(mbox1, 200); lv_obj_set_width(mbox1, 200);
//lv_obj_set_event_cb(mbox1, event_handler); //lv_obj_set_event_cb(mbox1, event_handler);
lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/ lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner
#endif #endif
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
return; return;
@@ -261,7 +261,7 @@ void WiFiScan::joinWiFi(String ssid, String password)
lv_msgbox_set_text(mbox1, text_table4[4]); lv_msgbox_set_text(mbox1, text_table4[4]);
lv_msgbox_add_btns(mbox1, btns); lv_msgbox_add_btns(mbox1, btns);
lv_obj_set_width(mbox1, 200); lv_obj_set_width(mbox1, 200);
lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/ lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner
#endif #endif
connected_network = ssid; connected_network = ssid;
@@ -269,7 +269,7 @@ void WiFiScan::joinWiFi(String ssid, String password)
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) {

View File

@@ -125,7 +125,7 @@ esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, b
LinkedList<int>* stations; LinkedList<int>* stations;
};*/ };*/
#define mac_history_len 29 #define mac_history_len 512
struct mac_addr { struct mac_addr {
unsigned char bytes[6]; unsigned char bytes[6];
@@ -314,7 +314,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

@@ -281,7 +281,7 @@
#ifdef MARAUDER_V4 #ifdef MARAUDER_V4
#define SCREEN_CHAR_WIDTH 40 #define SCREEN_CHAR_WIDTH 40
#define HAS_ILI9341 #define HAS_ILI9341
#define BANNER_TEXT_SIZE 2 #define BANNER_TEXT_SIZE 1
#ifndef TFT_WIDTH #ifndef TFT_WIDTH
#define TFT_WIDTH 240 #define TFT_WIDTH 240
@@ -338,7 +338,7 @@
#define SCREEN_CHAR_WIDTH 40 #define SCREEN_CHAR_WIDTH 40
#define HAS_ILI9341 #define HAS_ILI9341
#define BANNER_TEXT_SIZE 2 #define BANNER_TEXT_SIZE 1
#ifndef TFT_WIDTH #ifndef TFT_WIDTH
#define TFT_WIDTH 240 #define TFT_WIDTH 240
@@ -395,7 +395,7 @@
#define SCREEN_CHAR_WIDTH 40 #define SCREEN_CHAR_WIDTH 40
#define HAS_ILI9341 #define HAS_ILI9341
#define BANNER_TEXT_SIZE 2 #define BANNER_TEXT_SIZE 1
#ifndef TFT_WIDTH #ifndef TFT_WIDTH
#define TFT_WIDTH 240 #define TFT_WIDTH 240