mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-22 07:10:47 -08:00
PROGMEM commands and remove mini lv_arduino
This commit is contained in:
@@ -24,7 +24,7 @@ void CommandLine::parseCommand(String input) {
|
||||
if (input != "")
|
||||
Serial.println("#" + input);
|
||||
|
||||
if (input == "stopscan") {
|
||||
if (input == STOPSCAN_CMD) {
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_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);
|
||||
}
|
||||
|
||||
else if (input == "scanap") {
|
||||
else if (input == SCANAP_CMD) {
|
||||
display_obj.clearScreen();
|
||||
menu_function_obj.drawStatusBar();
|
||||
wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA);
|
||||
}
|
||||
|
||||
else if (input == "clearap") {
|
||||
else if (input == CLEARAP_CMD) {
|
||||
wifi_scan_obj.RunClearAPs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ extern MenuFunctions menu_function_obj;
|
||||
extern WiFiScan wifi_scan_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 {
|
||||
private:
|
||||
String getSerialInput();
|
||||
|
||||
@@ -14,14 +14,15 @@ MenuFunctions::MenuFunctions()
|
||||
// LVGL Stuff
|
||||
/* Interrupt driven periodic handler */
|
||||
|
||||
void MenuFunctions::lv_tick_handler()
|
||||
{
|
||||
#ifndef MARAUDER_MINI
|
||||
void MenuFunctions::lv_tick_handler()
|
||||
{
|
||||
lv_tick_inc(LVGL_TICK_PERIOD);
|
||||
}
|
||||
}
|
||||
|
||||
/* Display flushing */
|
||||
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
/* Display flushing */
|
||||
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
extern Display display_obj;
|
||||
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();
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuFunctions::initLVGL() {
|
||||
void MenuFunctions::initLVGL() {
|
||||
tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler);
|
||||
|
||||
lv_init();
|
||||
@@ -101,15 +102,15 @@ void MenuFunctions::initLVGL() {
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = my_touchpad_read;
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MenuFunctions::deinitLVGL() {
|
||||
void MenuFunctions::deinitLVGL() {
|
||||
Serial.println(F("Deinit LVGL"));
|
||||
//lv_deinit();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuFunctions::writeBadUSB(){
|
||||
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);
|
||||
@@ -153,19 +154,19 @@ void MenuFunctions::writeBadUSB(){
|
||||
// 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
|
||||
void setting_dropdown_cb(lv_obj_t * obj, lv_event_t event) {
|
||||
// Event handler for settings drop down menus
|
||||
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) {
|
||||
void settings_list_cb(lv_obj_t * btn, lv_event_t event) {
|
||||
extern Settings settings_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;
|
||||
|
||||
DynamicJsonDocument json(1024); // ArduinoJson v6
|
||||
@@ -299,10 +300,10 @@ void MenuFunctions::displaySettingsGFX(){
|
||||
//lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
//lv_btn_set_checkable(btn1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GFX Function to build a list showing all APs scanned
|
||||
void MenuFunctions::addAPGFX(){
|
||||
// GFX Function to build a list showing all APs scanned
|
||||
void MenuFunctions::addAPGFX(){
|
||||
extern LinkedList<AccessPoint>* access_points;
|
||||
|
||||
lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
|
||||
@@ -336,11 +337,11 @@ void MenuFunctions::addAPGFX(){
|
||||
//label = lv_label_create(btn1, NULL);
|
||||
//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 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;
|
||||
|
||||
String display_string = "";
|
||||
@@ -435,9 +436,9 @@ void MenuFunctions::addSSIDGFX(){
|
||||
lv_keyboard_set_textarea(kb, ta2);
|
||||
lv_keyboard_set_cursor_manage(kb, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MenuFunctions::joinWiFiGFX(){
|
||||
void MenuFunctions::joinWiFiGFX(){
|
||||
|
||||
// Create one text area
|
||||
ta1 = lv_textarea_create(lv_scr_act(), NULL);
|
||||
@@ -474,10 +475,10 @@ void MenuFunctions::joinWiFiGFX(){
|
||||
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) {
|
||||
// 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);
|
||||
@@ -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);
|
||||
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;
|
||||
|
||||
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)));
|
||||
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 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 MenuFunctions menu_function_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);
|
||||
display_obj.exit_draw = true; // set everything back to normal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard callback dedicated to joining wifi
|
||||
void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event){
|
||||
// Keyboard callback dedicated to joining wifi
|
||||
void add_ssid_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;
|
||||
@@ -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);
|
||||
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){
|
||||
// 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;
|
||||
@@ -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);
|
||||
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(kb != NULL)
|
||||
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");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
//// END LV_ARDUINO STUFF
|
||||
|
||||
void MenuFunctions::buttonNotSelected(uint8_t b) {
|
||||
display_obj.tft.setFreeFont(NULL);
|
||||
@@ -816,7 +820,7 @@ void MenuFunctions::main(uint32_t currentTime)
|
||||
}
|
||||
|
||||
if (currentTime != 0) {
|
||||
if (currentTime - initTime >= 100) {
|
||||
if (currentTime - initTime >= BANNER_TIME) {
|
||||
this->initTime = millis();
|
||||
if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) &&
|
||||
(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
|
||||
void MenuFunctions::RunSetup()
|
||||
{
|
||||
#ifndef MARAUDER_MINI
|
||||
this->initLVGL();
|
||||
#endif
|
||||
|
||||
// root menu stuff
|
||||
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]() {
|
||||
changeMenu(wifiGeneralMenu.parentMenu);
|
||||
});
|
||||
#ifndef MARAUDER_MINI
|
||||
addNodes(&wifiGeneralMenu, "Join WiFi", TFT_DARKCYAN, NULL, JOIN_WIFI, [this](){
|
||||
display_obj.clearScreen();
|
||||
wifi_scan_obj.currentScanMode = LV_JOIN_WIFI;
|
||||
wifi_scan_obj.StartScan(LV_JOIN_WIFI, TFT_YELLOW);
|
||||
joinWiFiGFX();
|
||||
});
|
||||
#endif
|
||||
addNodes(&wifiGeneralMenu, "Shutdown WiFi", TFT_CYAN, NULL, SHUTDOWN, [this]() {
|
||||
changeMenu(&shutdownWiFiMenu);
|
||||
wifi_scan_obj.RunShutdownWiFi();
|
||||
@@ -1533,12 +1541,14 @@ void MenuFunctions::RunSetup()
|
||||
changeMenu(&generateSSIDsMenu);
|
||||
wifi_scan_obj.RunGenerateSSIDs();
|
||||
});
|
||||
#ifndef MARAUDER_MINI
|
||||
addNodes(&wifiGeneralMenu, "Add SSID", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
|
||||
display_obj.clearScreen();
|
||||
//wifi_scan_obj.currentScanMode = LV_ADD_SSID;
|
||||
wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_YELLOW);
|
||||
addSSIDGFX();
|
||||
});
|
||||
#endif
|
||||
addNodes(&wifiGeneralMenu, "Clear SSIDs", TFT_SILVER, NULL, CLEAR_ICO, [this]() {
|
||||
changeMenu(&clearSSIDsMenu);
|
||||
wifi_scan_obj.RunClearSSIDs();
|
||||
@@ -1547,12 +1557,14 @@ void MenuFunctions::RunSetup()
|
||||
changeMenu(&clearAPsMenu);
|
||||
wifi_scan_obj.RunClearAPs();
|
||||
});
|
||||
#ifndef MARAUDER_MINI
|
||||
addNodes(&wifiGeneralMenu, "Select APs", TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
|
||||
display_obj.clearScreen();
|
||||
wifi_scan_obj.currentScanMode = LV_ADD_SSID;
|
||||
wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED);
|
||||
addAPGFX();
|
||||
});
|
||||
#endif
|
||||
|
||||
// Build shutdown wifi menu
|
||||
shutdownWiFiMenu.parentMenu = &wifiGeneralMenu;
|
||||
@@ -1638,12 +1650,14 @@ void MenuFunctions::RunSetup()
|
||||
addNodes(&badusbMenu, "Test BadUSB", TFT_PURPLE, NULL, TEST_BAD_USB_ICO, [this]() {
|
||||
a32u4_obj.test();
|
||||
});
|
||||
#ifndef MARAUDER_MINI
|
||||
addNodes(&badusbMenu, "Run Ducky Script", TFT_RED, NULL, BAD_USB_ICO, [this](){
|
||||
display_obj.clearScreen();
|
||||
wifi_scan_obj.currentScanMode = LV_ADD_SSID;
|
||||
wifi_scan_obj.StartScan(LV_ADD_SSID, TFT_RED);
|
||||
writeBadUSB();
|
||||
});
|
||||
#endif
|
||||
|
||||
// General apps menu
|
||||
generalMenu.parentMenu = &mainMenu;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#define configs_h
|
||||
|
||||
// #define MARAUDER_MINI
|
||||
#define MARAUDER_V4
|
||||
#define MARAUDER_MINI
|
||||
// #define MARAUDER_V4
|
||||
|
||||
#define MARAUDER_VERSION "v0.9.6"
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
|
||||
//// MENU DEFINITIONS
|
||||
#ifdef MARAUDER_V4
|
||||
#define BANNER_TIME 100
|
||||
|
||||
#define COMMAND_PREFIX "!"
|
||||
|
||||
// Keypad start position, key sizes and spacing
|
||||
@@ -155,13 +157,15 @@
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_MINI
|
||||
#define BANNER_TIME 50
|
||||
|
||||
#define COMMAND_PREFIX "!"
|
||||
|
||||
// Keypad start position, key sizes and spacing
|
||||
#define KEY_X (TFT_WIDTH/2) // Centre of key
|
||||
#define KEY_Y (TFT_HEIGHT/4.5)
|
||||
#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_Y 1
|
||||
#define KEY_TEXTSIZE 1 // Font size multiplier
|
||||
|
||||
Reference in New Issue
Block a user