PROGMEM commands and remove mini lv_arduino

This commit is contained in:
Just Call Me Koko
2022-05-07 14:36:44 -04:00
parent d9a6966574
commit 0f58a0657b
4 changed files with 760 additions and 737 deletions

View File

@@ -24,7 +24,7 @@ void CommandLine::parseCommand(String input) {
if (input != "") if (input != "")
Serial.println("#" + input); Serial.println("#" + input);
if (input == "stopscan") { if (input == STOPSCAN_CMD) {
wifi_scan_obj.StartScan(WIFI_SCAN_OFF); wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
// If we don't do this, the text and button coordinates will be off // If we don't do this, the text and button coordinates will be off
@@ -34,13 +34,13 @@ void CommandLine::parseCommand(String input) {
menu_function_obj.changeMenu(menu_function_obj.current_menu); menu_function_obj.changeMenu(menu_function_obj.current_menu);
} }
else if (input == "scanap") { else if (input == SCANAP_CMD) {
display_obj.clearScreen(); display_obj.clearScreen();
menu_function_obj.drawStatusBar(); menu_function_obj.drawStatusBar();
wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA); wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA);
} }
else if (input == "clearap") { else if (input == CLEARAP_CMD) {
wifi_scan_obj.RunClearAPs(); wifi_scan_obj.RunClearAPs();
} }
} }

View File

@@ -9,6 +9,11 @@ extern MenuFunctions menu_function_obj;
extern WiFiScan wifi_scan_obj; extern WiFiScan wifi_scan_obj;
extern Display display_obj; extern Display display_obj;
// Commands
const char PROGMEM SCANAP_CMD[] = "scanap";
const char PROGMEM STOPSCAN_CMD[] = "stopscan";
const char PROGMEM CLEARAP_CMD[] = "clearap";
class CommandLine { class CommandLine {
private: private:
String getSerialInput(); String getSerialInput();

View File

@@ -14,14 +14,15 @@ MenuFunctions::MenuFunctions()
// LVGL Stuff // LVGL Stuff
/* Interrupt driven periodic handler */ /* Interrupt driven periodic handler */
void MenuFunctions::lv_tick_handler() #ifndef MARAUDER_MINI
{ void MenuFunctions::lv_tick_handler()
{
lv_tick_inc(LVGL_TICK_PERIOD); lv_tick_inc(LVGL_TICK_PERIOD);
} }
/* Display flushing */ /* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{ {
extern Display display_obj; extern Display display_obj;
uint16_t c; uint16_t c;
@@ -36,11 +37,11 @@ void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color
} }
display_obj.tft.endWrite(); display_obj.tft.endWrite();
lv_disp_flush_ready(disp); lv_disp_flush_ready(disp);
} }
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
{ {
extern Display display_obj; extern Display display_obj;
uint16_t touchX, touchY; uint16_t touchX, touchY;
@@ -79,9 +80,9 @@ bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
} }
return false; return false;
} }
void MenuFunctions::initLVGL() { void MenuFunctions::initLVGL() {
tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler); tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler);
lv_init(); lv_init();
@@ -101,15 +102,15 @@ void MenuFunctions::initLVGL() {
indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read; indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv); lv_indev_drv_register(&indev_drv);
} }
void MenuFunctions::deinitLVGL() { void MenuFunctions::deinitLVGL() {
Serial.println(F("Deinit LVGL")); Serial.println(F("Deinit LVGL"));
//lv_deinit(); //lv_deinit();
} }
void MenuFunctions::writeBadUSB(){ void MenuFunctions::writeBadUSB(){
// Create a keyboard and apply the styles // Create a keyboard and apply the styles
kb = lv_keyboard_create(lv_scr_act(), NULL); kb = lv_keyboard_create(lv_scr_act(), NULL);
lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2); lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2);
@@ -153,19 +154,19 @@ void MenuFunctions::writeBadUSB(){
// Focus it on one of the text areas to start // Focus it on one of the text areas to start
lv_keyboard_set_textarea(kb, ta1); lv_keyboard_set_textarea(kb, ta1);
lv_keyboard_set_cursor_manage(kb, true); 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_event_code_t code = lv_event_get_code(event);
//lv_obj_t * obj = lv_event_get_target(event); //lv_obj_t * obj = lv_event_get_target(event);
//lv_obj_t * list1 = lv_obj_get_parent(lv_obj_get_parent(obj)); //lv_obj_t * list1 = lv_obj_get_parent(lv_obj_get_parent(obj));
//if(event == LV_EVENT_CLICKED) { //if(event == LV_EVENT_CLICKED) {
// LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj)); // LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
//} //}
} }
void settings_list_cb(lv_obj_t * btn, lv_event_t event) { void settings_list_cb(lv_obj_t * btn, lv_event_t event) {
extern Settings settings_obj; extern Settings settings_obj;
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
@@ -237,9 +238,9 @@ void settings_list_cb(lv_obj_t * btn, lv_event_t event) {
} }
} }
}*/ }*/
} }
void MenuFunctions::displaySettingsGFX(){ void MenuFunctions::displaySettingsGFX(){
extern Settings settings_obj; extern Settings settings_obj;
DynamicJsonDocument json(1024); // ArduinoJson v6 DynamicJsonDocument json(1024); // ArduinoJson v6
@@ -299,10 +300,10 @@ void MenuFunctions::displaySettingsGFX(){
//lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0); //lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);
//lv_btn_set_checkable(btn1, true); //lv_btn_set_checkable(btn1, true);
} }
} }
// GFX Function to build a list showing all APs scanned // GFX Function to build a list showing all APs scanned
void MenuFunctions::addAPGFX(){ void MenuFunctions::addAPGFX(){
extern LinkedList<AccessPoint>* access_points; extern LinkedList<AccessPoint>* access_points;
lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL); lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
@@ -336,11 +337,11 @@ void MenuFunctions::addAPGFX(){
//label = lv_label_create(btn1, NULL); //label = lv_label_create(btn1, NULL);
//lv_label_set_text(label, buf); //lv_label_set_text(label, buf);
} }
} }
void ap_list_cb(lv_obj_t * btn, lv_event_t event) { void ap_list_cb(lv_obj_t * btn, lv_event_t event) {
extern LinkedList<AccessPoint>* access_points; extern LinkedList<AccessPoint>* access_points;
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
@@ -394,9 +395,9 @@ void ap_list_cb(lv_obj_t * btn, lv_event_t event) {
} }
} }
} }
} }
void MenuFunctions::addSSIDGFX(){ void MenuFunctions::addSSIDGFX(){
extern LinkedList<ssid>* ssids; extern LinkedList<ssid>* ssids;
String display_string = ""; String display_string = "";
@@ -435,9 +436,9 @@ void MenuFunctions::addSSIDGFX(){
lv_keyboard_set_textarea(kb, ta2); lv_keyboard_set_textarea(kb, ta2);
lv_keyboard_set_cursor_manage(kb, true); lv_keyboard_set_cursor_manage(kb, true);
} }
void MenuFunctions::joinWiFiGFX(){ void MenuFunctions::joinWiFiGFX(){
// Create one text area // Create one text area
ta1 = lv_textarea_create(lv_scr_act(), NULL); ta1 = lv_textarea_create(lv_scr_act(), NULL);
@@ -474,10 +475,10 @@ void MenuFunctions::joinWiFiGFX(){
lv_keyboard_set_textarea(kb, ta1); lv_keyboard_set_textarea(kb, ta1);
lv_keyboard_set_cursor_manage(kb, true); lv_keyboard_set_cursor_manage(kb, true);
} }
// Function to create keyboard for saving file name // Function to create keyboard for saving file name
void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) { void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) {
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
lv_keyboard_def_event_cb(save_as_kb, event); lv_keyboard_def_event_cb(save_as_kb, event);
@@ -527,10 +528,10 @@ void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) {
save_label = lv_label_create(save_btn, NULL); save_label = lv_label_create(save_btn, NULL);
lv_label_set_text(save_label, "Save"); lv_label_set_text(save_label, "Save");
} }
} }
void test_btn_cb(lv_obj_t * btn, lv_event_t event) { void test_btn_cb(lv_obj_t * btn, lv_event_t event) {
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
if (event == LV_EVENT_CLICKED) { if (event == LV_EVENT_CLICKED) {
@@ -573,9 +574,9 @@ void test_btn_cb(lv_obj_t * btn, lv_event_t event) {
lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn))); lv_obj_del_async(lv_obj_get_parent(lv_obj_get_parent(btn)));
menu_function_obj.loaded_file = btn_text; menu_function_obj.loaded_file = btn_text;
} }
} }
void load_btn_cb(lv_obj_t * load_btn, lv_event_t event) { void load_btn_cb(lv_obj_t * load_btn, lv_event_t event) {
extern SDInterface sd_obj; extern SDInterface sd_obj;
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
@@ -673,9 +674,9 @@ void load_btn_cb(lv_obj_t * load_btn, lv_event_t event) {
} }
} }
} }
} }
void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) { void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) {
extern Display display_obj; extern Display display_obj;
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
extern A32u4Interface a32u4_obj; extern A32u4Interface a32u4_obj;
@@ -698,10 +699,10 @@ void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event) {
wifi_scan_obj.StartScan(WIFI_SCAN_OFF); 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
} }
} }
// 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;
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
extern WiFiScan wifi_scan_obj; extern WiFiScan wifi_scan_obj;
@@ -735,10 +736,10 @@ void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
//wifi_scan_obj.StartScan(WIFI_SCAN_OFF); //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
} }
} }
// Keyboard callback dedicated to joining wifi // Keyboard callback dedicated to joining wifi
void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){ void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
extern Display display_obj; extern Display display_obj;
extern MenuFunctions menu_function_obj; extern MenuFunctions menu_function_obj;
extern WiFiScan wifi_scan_obj; extern WiFiScan wifi_scan_obj;
@@ -758,11 +759,11 @@ void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
//wifi_scan_obj.StartScan(WIFI_SCAN_OFF); //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
} }
} }
void ta_event_cb(lv_obj_t * ta, lv_event_t event) void ta_event_cb(lv_obj_t * ta, lv_event_t event)
{ {
if(event == LV_EVENT_CLICKED) { if(event == LV_EVENT_CLICKED) {
if(kb != NULL) if(kb != NULL)
lv_keyboard_set_textarea(kb, ta); lv_keyboard_set_textarea(kb, ta);
@@ -774,7 +775,10 @@ void ta_event_cb(lv_obj_t * ta, lv_event_t event)
// printf("Ready\n"); // printf("Ready\n");
// } // }
//} //}
} }
#endif
//// END LV_ARDUINO STUFF
void MenuFunctions::buttonNotSelected(uint8_t b) { void MenuFunctions::buttonNotSelected(uint8_t b) {
display_obj.tft.setFreeFont(NULL); display_obj.tft.setFreeFont(NULL);
@@ -816,7 +820,7 @@ void MenuFunctions::main(uint32_t currentTime)
} }
if (currentTime != 0) { if (currentTime != 0) {
if (currentTime - initTime >= 100) { if (currentTime - initTime >= BANNER_TIME) {
this->initTime = millis(); this->initTime = millis();
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))
@@ -1333,7 +1337,9 @@ void MenuFunctions::displaySetting(String key, Menu* menu, int index) {
// Function to build the menus // Function to build the menus
void MenuFunctions::RunSetup() void MenuFunctions::RunSetup()
{ {
#ifndef MARAUDER_MINI
this->initLVGL(); this->initLVGL();
#endif
// root menu stuff // root menu stuff
mainMenu.list = new LinkedList<MenuNode>(); // Get list in first menu ready mainMenu.list = new LinkedList<MenuNode>(); // Get list in first menu ready
@@ -1519,12 +1525,14 @@ void MenuFunctions::RunSetup()
addNodes(&wifiGeneralMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this]() { addNodes(&wifiGeneralMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this]() {
changeMenu(wifiGeneralMenu.parentMenu); changeMenu(wifiGeneralMenu.parentMenu);
}); });
#ifndef MARAUDER_MINI
addNodes(&wifiGeneralMenu, "Join WiFi", TFT_DARKCYAN, NULL, JOIN_WIFI, [this](){ addNodes(&wifiGeneralMenu, "Join WiFi", TFT_DARKCYAN, NULL, JOIN_WIFI, [this](){
display_obj.clearScreen(); display_obj.clearScreen();
wifi_scan_obj.currentScanMode = LV_JOIN_WIFI; wifi_scan_obj.currentScanMode = LV_JOIN_WIFI;
wifi_scan_obj.StartScan(LV_JOIN_WIFI, TFT_YELLOW); wifi_scan_obj.StartScan(LV_JOIN_WIFI, TFT_YELLOW);
joinWiFiGFX(); joinWiFiGFX();
}); });
#endif
addNodes(&wifiGeneralMenu, "Shutdown WiFi", TFT_CYAN, NULL, SHUTDOWN, [this]() { addNodes(&wifiGeneralMenu, "Shutdown WiFi", TFT_CYAN, NULL, SHUTDOWN, [this]() {
changeMenu(&shutdownWiFiMenu); changeMenu(&shutdownWiFiMenu);
wifi_scan_obj.RunShutdownWiFi(); wifi_scan_obj.RunShutdownWiFi();
@@ -1533,12 +1541,14 @@ void MenuFunctions::RunSetup()
changeMenu(&generateSSIDsMenu); changeMenu(&generateSSIDsMenu);
wifi_scan_obj.RunGenerateSSIDs(); wifi_scan_obj.RunGenerateSSIDs();
}); });
#ifndef MARAUDER_MINI
addNodes(&wifiGeneralMenu, "Add SSID", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){ addNodes(&wifiGeneralMenu, "Add SSID", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
display_obj.clearScreen(); display_obj.clearScreen();
//wifi_scan_obj.currentScanMode = LV_ADD_SSID; //wifi_scan_obj.currentScanMode = LV_ADD_SSID;
wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_YELLOW); wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_YELLOW);
addSSIDGFX(); addSSIDGFX();
}); });
#endif
addNodes(&wifiGeneralMenu, "Clear SSIDs", TFT_SILVER, NULL, CLEAR_ICO, [this]() { addNodes(&wifiGeneralMenu, "Clear SSIDs", TFT_SILVER, NULL, CLEAR_ICO, [this]() {
changeMenu(&clearSSIDsMenu); changeMenu(&clearSSIDsMenu);
wifi_scan_obj.RunClearSSIDs(); wifi_scan_obj.RunClearSSIDs();
@@ -1547,12 +1557,14 @@ void MenuFunctions::RunSetup()
changeMenu(&clearAPsMenu); changeMenu(&clearAPsMenu);
wifi_scan_obj.RunClearAPs(); wifi_scan_obj.RunClearAPs();
}); });
#ifndef MARAUDER_MINI
addNodes(&wifiGeneralMenu, "Select APs", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){ addNodes(&wifiGeneralMenu, "Select APs", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
display_obj.clearScreen(); display_obj.clearScreen();
wifi_scan_obj.currentScanMode = LV_ADD_SSID; wifi_scan_obj.currentScanMode = LV_ADD_SSID;
wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED); wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED);
addAPGFX(); addAPGFX();
}); });
#endif
// Build shutdown wifi menu // Build shutdown wifi menu
shutdownWiFiMenu.parentMenu = &wifiGeneralMenu; shutdownWiFiMenu.parentMenu = &wifiGeneralMenu;
@@ -1638,12 +1650,14 @@ void MenuFunctions::RunSetup()
addNodes(&badusbMenu, "Test BadUSB", TFT_PURPLE, NULL, TEST_BAD_USB_ICO, [this]() { addNodes(&badusbMenu, "Test BadUSB", TFT_PURPLE, NULL, TEST_BAD_USB_ICO, [this]() {
a32u4_obj.test(); a32u4_obj.test();
}); });
#ifndef MARAUDER_MINI
addNodes(&badusbMenu, "Run Ducky Script", TFT_RED, NULL, BAD_USB_ICO, [this](){ addNodes(&badusbMenu, "Run Ducky Script", TFT_RED, NULL, BAD_USB_ICO, [this](){
display_obj.clearScreen(); display_obj.clearScreen();
wifi_scan_obj.currentScanMode = LV_ADD_SSID; wifi_scan_obj.currentScanMode = LV_ADD_SSID;
wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED); wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED);
writeBadUSB(); writeBadUSB();
}); });
#endif
// General apps menu // General apps menu
generalMenu.parentMenu = &mainMenu; generalMenu.parentMenu = &mainMenu;

View File

@@ -2,8 +2,8 @@
#define configs_h #define configs_h
// #define MARAUDER_MINI #define MARAUDER_MINI
#define MARAUDER_V4 // #define MARAUDER_V4
#define MARAUDER_VERSION "v0.9.6" #define MARAUDER_VERSION "v0.9.6"
@@ -138,6 +138,8 @@
//// MENU DEFINITIONS //// MENU DEFINITIONS
#ifdef MARAUDER_V4 #ifdef MARAUDER_V4
#define BANNER_TIME 100
#define COMMAND_PREFIX "!" #define COMMAND_PREFIX "!"
// Keypad start position, key sizes and spacing // Keypad start position, key sizes and spacing
@@ -155,13 +157,15 @@
#endif #endif
#ifdef MARAUDER_MINI #ifdef MARAUDER_MINI
#define BANNER_TIME 50
#define COMMAND_PREFIX "!" #define COMMAND_PREFIX "!"
// Keypad start position, key sizes and spacing // Keypad start position, key sizes and spacing
#define KEY_X (TFT_WIDTH/2) // Centre of key #define KEY_X (TFT_WIDTH/2) // Centre of key
#define KEY_Y (TFT_HEIGHT/4.5) #define KEY_Y (TFT_HEIGHT/4.5)
#define KEY_W TFT_WIDTH // Width and height #define KEY_W TFT_WIDTH // Width and height
#define KEY_H (TFT_HEIGHT/10) #define KEY_H (TFT_HEIGHT/12.8)
#define KEY_SPACING_X 0 // X and Y gap #define KEY_SPACING_X 0 // X and Y gap
#define KEY_SPACING_Y 1 #define KEY_SPACING_Y 1
#define KEY_TEXTSIZE 1 // Font size multiplier #define KEY_TEXTSIZE 1 // Font size multiplier