diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 6a0017319..867149351 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -56,19 +56,12 @@ jobs: repository: bigbrodude6119/ESPAsyncWebServer ref: master path: CustomESPAsyncWebServer - - #- name: Install TFT_eSPI - # uses: actions/checkout@v2 - # with: - # repository: justcallmekoko/TFT_eSPI - # ref: master - # path: CustomTFT_eSPI - name: Install TFT_eSPI uses: actions/checkout@v2 with: repository: Bodmer/TFT_eSPI - ref: 2.2.23 + ref: V2.5.34 path: CustomTFT_eSPI - name: Install lv_arduino @@ -106,12 +99,12 @@ jobs: ref: v6.18.2 path: CustomArduinoJson - - name: Install SwitchLib - uses: actions/checkout@v2 - with: - repository: justcallmekoko/SwitchLib - ref: main - path: CustomSwitchLib + #- name: Install SwitchLib + # uses: actions/checkout@v2 + # with: + # repository: justcallmekoko/SwitchLib + # ref: main + # path: CustomSwitchLib - name: Install LinkedList uses: actions/checkout@v2 @@ -138,6 +131,7 @@ jobs: cp User_Setup_marauder_mini.h CustomTFT_eSPI/ cp User_Setup_og_marauder.h CustomTFT_eSPI/ cp User_Setup_marauder_m5stickc.h CustomTFT_eSPI/ + cp User_Setup_marauder_rev_feather.h CustomTFT_eSPI/ pwd ls -la ls -la CustomTFT_eSPI @@ -182,6 +176,7 @@ jobs: - name: Configure configs.h for Flipper Zero WiFi Dev Board run: | + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_M5STICKC/ \/\/#define MARAUDER_M5STICKC/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h @@ -218,9 +213,11 @@ jobs: - name: Configure TFT_eSPI and configs.h for OG Marauder run: | pwd - find /home/runner/ -name "*TFT_eSPI*" + find /home/runner/ -name "*TFT_eSPI*" + sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^\/\/#include /#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ \/\/#define MARAUDER_V4/ #define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -244,8 +241,10 @@ jobs: - name: Configure TFT_eSPI and configs.h for Marauder v6 run: | + sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^\/\/#include /#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ \/\/#define MARAUDER_V6/ #define MARAUDER_V6/' esp32_marauder/configs.h @@ -286,6 +285,7 @@ jobs: - name: Configure TFT_eSPI and configs.h for Marauder v6.1 run: | + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -311,6 +311,7 @@ jobs: run: | sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^\/\/#include /#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -336,6 +337,7 @@ jobs: run: | sed -i 's/^\/\/#include /#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ \/\/#define MARAUDER_MINI/ #define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -359,6 +361,7 @@ jobs: - name: Configure TFT_eSPI and configs.h for ESP32 LDDB run: | + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -382,6 +385,7 @@ jobs: - name: Configure TFT_eSPI and configs.h for Marauder Dev Board Pro run: | + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -409,6 +413,7 @@ jobs: find /home/runner/ -name "*TFT_eSPI*" sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h sed -i 's/^\/\/#include /#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^ #define MARAUDER_REV_FEATHER/ \/\/#define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h @@ -430,6 +435,36 @@ jobs: - name: Rename Marauder M5StickC bin run: | mv ./esp32_marauder/build/esp32.esp32.m5stick-c/esp32_marauder.ino.bin ./esp32_marauder/build/esp32.esp32.m5stick-c/esp32_marauder.m5stickc_plus.bin + + - name: Configure TFT_eSPI and configs.h for Marauder Rev Feather + run: | + pwd + find /home/runner/ -name "*TFT_eSPI*" + sed -i 's/^\/\/#include /#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^#include /\/\/#include /' /home/runner/Arduino/libraries/CustomTFT_eSPI/User_Setup_Select.h + sed -i 's/^ \/\/#define MARAUDER_REV_FEATHER/ #define MARAUDER_REV_FEATHER/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_V6_1/ \/\/#define MARAUDER_V6_1/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_KIT/ \/\/#define MARAUDER_KIT/' esp32_marauder/configs.h + sed -i 's/^ #define GENERIC_ESP32/ \/\/#define GENERIC_ESP32/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h + sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_M5STICKC/ \/\/#define MARAUDER_M5STICKC/' esp32_marauder/configs.h + + - name: Build Marauder for Marauder Rev Feather + uses: ArminJo/arduino-test-compile@v3.2.1 + with: + sketch-names: esp32_marauder.ino + arduino-board-fqbn: esp32:esp32:esp32s2:PartitionScheme=min_spiffs,FlashSize=4M,PSRAM=enabled + extra-arduino-cli-args: "--warnings none" + + - name: Rename Marauder Marauder Rev Feather + run: | + mv ./esp32_marauder/build/esp32.esp32.esp32s2/esp32_marauder.ino.bin ./esp32_marauder/build/esp32.esp32.esp32s2/esp32_marauder.rev_feather.bin - name: Display finished bins run: | @@ -505,6 +540,13 @@ jobs: path: ./esp32_marauder/build/esp32.esp32.m5stick-c/esp32_marauder.m5stickc_plus.bin retention-days: 5 + - name: 'Upload Rev Feather Artifact' + uses: actions/upload-artifact@v3 + with: + name: esp32_marauder.rev_feather.bin + path: ./esp32_marauder/build/esp32.esp32.esp32s2/esp32_marauder.rev_feather.bin + retention-days: 5 + - name: Create Release id: create_release uses: actions/create-release@v1 @@ -636,3 +678,15 @@ jobs: asset_name: esp32_marauder.m5stickc_plus.bin asset_content_type: application/bin if: github.event_name != 'pull_request' + + - name: Upload Rev Feather Asset + id: upload-rev-feather-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./esp32_marauder/build/esp32.esp32.esp32s2/esp32_marauder.rev_feather.bin + asset_name: esp32_marauder.rev_feather.bin + asset_content_type: application/bin + if: github.event_name != 'pull_request' diff --git a/User_Setup_Select.h b/User_Setup_Select.h index 8b1f49612..82c61d38a 100644 --- a/User_Setup_Select.h +++ b/User_Setup_Select.h @@ -24,6 +24,7 @@ #include //#include //#include +//#include //#include // Setup file configured for my ILI9341 //#include // Setup file configured for my ST7735 diff --git a/User_Setup_marauder_mini.h b/User_Setup_marauder_mini.h index ed58b244b..c7a28107b 100644 --- a/User_Setup_marauder_mini.h +++ b/User_Setup_marauder_mini.h @@ -43,8 +43,8 @@ // For ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display // Try ONE option at a time to find the correct colour order for your display - #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue -// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red +// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue + #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red // For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below diff --git a/User_Setup_marauder_rev_feather.h b/User_Setup_marauder_rev_feather.h new file mode 100644 index 000000000..95e9dd54b --- /dev/null +++ b/User_Setup_marauder_rev_feather.h @@ -0,0 +1,59 @@ +// ST7789 135 x 240 display with no chip select line + +#define ST7789_DRIVER // Configure all registers + +#define TFT_WIDTH 135 +#define TFT_HEIGHT 240 + +#define CGRAM_OFFSET // Library will add offsets required + +//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue +//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red + +//#define TFT_INVERSION_ON +//#define TFT_INVERSION_OFF + +// DSTIKE stepup +//#define TFT_DC 23 +//#define TFT_RST 32 +//#define TFT_MOSI 26 +//#define TFT_SCLK 27 + +// Generic ESP32 setup +//#define TFT_MISO 19 +//#define TFT_MOSI 23 +//#define TFT_SCLK 18 +//#define TFT_CS -1 // Not connected +//#define TFT_DC 2 +//#define TFT_RST 4 // Connect reset to ensure display initialises + +// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation +#define TFT_MISO 37 +#define TFT_MOSI 35 +#define TFT_SCLK 36 +#define TFT_CS 42 // Define as not used +#define TFT_DC 40 // Data Command control pin +#define TFT_RST 41 // TFT reset pin (could connect to NodeMCU RST, see next line) +#define TFT_BL 45 + + +#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH +#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters +#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters +#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm +#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. +#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. +//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT +#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts + +#define SMOOTH_FONT + + +// #define SPI_FREQUENCY 27000000 +#define SPI_FREQUENCY 40000000 + +#define SPI_READ_FREQUENCY 20000000 + +#define SPI_TOUCH_FREQUENCY 2500000 + +// #define SUPPORT_TRANSACTIONS \ No newline at end of file diff --git a/esp32_marauder/.theia/launch.json b/esp32_marauder/.theia/launch.json new file mode 100644 index 000000000..7e4253b33 --- /dev/null +++ b/esp32_marauder/.theia/launch.json @@ -0,0 +1,8 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + "version": "0.2.0", + "configurations": [ + + ] +} diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index da835e44c..f150e5c29 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -28,6 +28,10 @@ void Display::RunSetup() tft.setRotation(1); #endif + #ifdef MARAUDER_REV_FEATHER + tft.setRotation(1); + #endif + tft.setCursor(0, 0); #ifdef HAS_ILI9341 @@ -53,6 +57,14 @@ void Display::RunSetup() #ifdef KIT pinMode(KIT_LED_BUILTIN, OUTPUT); #endif + + #ifdef MARAUDER_REV_FEATHER + pinMode(7, OUTPUT); + + delay(10); + + digitalWrite(7, HIGH); + #endif } void Display::drawFrame() diff --git a/esp32_marauder/EvilPortal.cpp b/esp32_marauder/EvilPortal.cpp index b17d0afaf..cd1aa3ade 100644 --- a/esp32_marauder/EvilPortal.cpp +++ b/esp32_marauder/EvilPortal.cpp @@ -92,7 +92,11 @@ bool EvilPortal::setHtml() { return true; } Serial.println("Setting HTML..."); - File html_file = sd_obj.getFile("/" + this->target_html_name); + #ifdef HAS_SD + File html_file = sd_obj.getFile("/" + this->target_html_name); + #else + File html_file; + #endif if (!html_file) { #ifdef HAS_SCREEN this->sendToDisplay("Could not find /" + this->target_html_name); @@ -139,7 +143,11 @@ bool EvilPortal::setAP(LinkedList* ssids, LinkedList* access_ // If there are no SSIDs and there are no APs selected, pull from file // This means the file is last resort if ((ssids->size() <= 0) && (temp_ap_name == "")) { - File ap_config_file = sd_obj.getFile("/ap.config.txt"); + #ifdef HAS_SD + File ap_config_file = sd_obj.getFile("/ap.config.txt"); + #else + File ap_config_file; + #endif // Could not open config file. return false if (!ap_config_file) { #ifdef HAS_SCREEN diff --git a/esp32_marauder/GpsInterface.cpp b/esp32_marauder/GpsInterface.cpp index 24c5c04a0..370c37f62 100644 --- a/esp32_marauder/GpsInterface.cpp +++ b/esp32_marauder/GpsInterface.cpp @@ -34,10 +34,6 @@ void GpsInterface::begin() { delay(3900); - MicroNMEA::sendSentence(Serial2, "$PSTMFORCESTANDBY,00006"); - - delay(100); - if (Serial2.available()) { Serial.println("GPS Attached Successfully"); this->gps_enabled = true; @@ -46,10 +42,8 @@ void GpsInterface::begin() { char c = Serial2.read(); //Serial.print(c); //Pass the character to the library - Serial.print(c); nmea.process(c); } - Serial.println(nmea.getSentence()); } else { this->gps_enabled = false; @@ -536,6 +530,10 @@ String GpsInterface::getNumSatsString() { return (String)num_sats; } +int GpsInterface::getNumSats() { + return num_sats; +} + bool GpsInterface::getFixStatus() { return this->good_fix; } diff --git a/esp32_marauder/GpsInterface.h b/esp32_marauder/GpsInterface.h index 5094d177a..27640ce8f 100644 --- a/esp32_marauder/GpsInterface.h +++ b/esp32_marauder/GpsInterface.h @@ -39,6 +39,7 @@ class GpsInterface { void begin(); void main(); + int getNumSats(); String getNumSatsString(); bool getFixStatus(); String getFixStatusAsString(); diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index b066c5ba0..5a7fd68ba 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -519,9 +519,6 @@ void MenuFunctions::main(uint32_t currentTime) if ((wifi_scan_obj.currentScanMode != LV_JOIN_WIFI) && (wifi_scan_obj.currentScanMode != LV_ADD_SSID)) this->updateStatusBar(); - //#if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) - // display_obj.updateBanner(current_menu->name); - //#endif } } @@ -930,13 +927,21 @@ void MenuFunctions::battery2(bool initial) void MenuFunctions::updateStatusBar() { display_obj.tft.setTextSize(1); + + bool status_changed = false; - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.setFreeFont(NULL); #endif uint16_t the_color; + if (this->old_gps_sat_count != gps_obj.getNumSats()) { + this->old_gps_sat_count = gps_obj.getNumSats(); + display_obj.tft.fillRect(0, 0, 240, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + status_changed = true; + } + // GPS Stuff #ifdef HAS_GPS if (gps_obj.getGpsModuleStatus()) { @@ -966,28 +971,32 @@ void MenuFunctions::updateStatusBar() display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR); // WiFi Channel Stuff - if (wifi_scan_obj.set_channel != wifi_scan_obj.old_channel) { + if ((wifi_scan_obj.set_channel != wifi_scan_obj.old_channel) || (status_changed)) { wifi_scan_obj.old_channel = wifi_scan_obj.set_channel; - display_obj.tft.fillRect(50, 0, TFT_WIDTH * 0.21, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) + display_obj.tft.fillRect(43, 0, TFT_WIDTH * 0.21, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + #else + display_obj.tft.fillRect(50, 0, TFT_WIDTH * 0.21, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + #endif #ifdef HAS_ILI9341 display_obj.tft.drawString("CH: " + (String)wifi_scan_obj.set_channel, 50, 0, 2); #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.drawString("CH: " + (String)wifi_scan_obj.set_channel, TFT_WIDTH/4, 0, 1); #endif } // RAM Stuff wifi_scan_obj.freeRAM(); - if (wifi_scan_obj.free_ram != wifi_scan_obj.old_free_ram) { + if ((wifi_scan_obj.free_ram != wifi_scan_obj.old_free_ram) || (status_changed)) { wifi_scan_obj.old_free_ram = wifi_scan_obj.free_ram; display_obj.tft.fillRect(100, 0, 60, STATUS_BAR_WIDTH, STATUSBAR_COLOR); #ifdef HAS_ILI9341 display_obj.tft.drawString((String)wifi_scan_obj.free_ram + "B", 100, 0, 2); #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.drawString((String)wifi_scan_obj.free_ram + "B", TFT_WIDTH/1.75, 0, 1); #endif } @@ -1013,22 +1022,24 @@ void MenuFunctions::updateStatusBar() // Draw SD info - if (sd_obj.supported) - the_color = TFT_GREEN; - else - the_color = TFT_RED; + #ifdef HAS_SD + if (sd_obj.supported) + the_color = TFT_GREEN; + else + the_color = TFT_RED; - #ifdef HAS_ILI9341 - display_obj.tft.drawXBitmap(170, - 0, - menu_icons[STATUS_SD], - 16, - 16, - STATUSBAR_COLOR, - the_color); + #ifdef HAS_ILI9341 + display_obj.tft.drawXBitmap(170, + 0, + menu_icons[STATUS_SD], + 16, + 16, + STATUSBAR_COLOR, + the_color); + #endif #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.setTextColor(the_color, STATUSBAR_COLOR); display_obj.tft.drawString("SD", TFT_WIDTH - 12, 0, 1); #endif @@ -1037,7 +1048,7 @@ void MenuFunctions::updateStatusBar() void MenuFunctions::drawStatusBar() { display_obj.tft.setTextSize(1); - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.setFreeFont(NULL); #endif display_obj.tft.fillRect(0, 0, 240, STATUS_BAR_WIDTH, STATUSBAR_COLOR); @@ -1073,12 +1084,16 @@ void MenuFunctions::drawStatusBar() // WiFi Channel Stuff wifi_scan_obj.old_channel = wifi_scan_obj.set_channel; - display_obj.tft.fillRect(50, 0, 50, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) + display_obj.tft.fillRect(43, 0, TFT_WIDTH * 0.21, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + #else + display_obj.tft.fillRect(50, 0, TFT_WIDTH * 0.21, STATUS_BAR_WIDTH, STATUSBAR_COLOR); + #endif #ifdef HAS_ILI9341 display_obj.tft.drawString("CH: " + (String)wifi_scan_obj.set_channel, 50, 0, 2); #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.drawString("CH: " + (String)wifi_scan_obj.set_channel, TFT_WIDTH/4, 0, 1); #endif @@ -1090,7 +1105,7 @@ void MenuFunctions::drawStatusBar() display_obj.tft.drawString((String)wifi_scan_obj.free_ram + "B", 100, 0, 2); #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.drawString((String)wifi_scan_obj.free_ram + "B", TFT_WIDTH/1.75, 0, 1); #endif @@ -1114,22 +1129,25 @@ void MenuFunctions::drawStatusBar() #endif // Draw SD info - if (sd_obj.supported) - the_color = TFT_GREEN; - else - the_color = TFT_RED; + #ifdef HAS_SD + if (sd_obj.supported) + the_color = TFT_GREEN; + else + the_color = TFT_RED; + - #ifdef HAS_ILI9341 - display_obj.tft.drawXBitmap(170, - 0, - menu_icons[STATUS_SD], - 16, - 16, - STATUSBAR_COLOR, - the_color); + #ifdef HAS_ILI9341 + display_obj.tft.drawXBitmap(170, + 0, + menu_icons[STATUS_SD], + 16, + 16, + STATUSBAR_COLOR, + the_color); + #endif #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.setTextColor(the_color, STATUSBAR_COLOR); display_obj.tft.drawString("SD", TFT_WIDTH - 12, 0, 1); #endif @@ -1242,9 +1260,16 @@ void MenuFunctions::RunSetup() // WiFi HTML menu stuff htmlMenu.list = new LinkedList(); - #ifdef MARAUDER_MINI + #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) miniKbMenu.list = new LinkedList(); #endif + #ifndef HAS_ILI9341 + #ifdef HAS_BUTTONS + #ifdef HAS_SD + sdDeleteMenu.list = new LinkedList(); + #endif + #endif + #endif // Bluetooth menu stuff bluetoothSnifferMenu.list = new LinkedList(); @@ -1280,9 +1305,14 @@ void MenuFunctions::RunSetup() gpsInfoMenu.name = "GPS Data"; #endif htmlMenu.name = "EP HTML List"; - #ifdef MARAUDER_MINI + #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) miniKbMenu.name = "Mini Keyboard"; #endif + #ifdef HAS_SD + #ifndef HAS_ILI9341 + sdDeleteMenu.name = "Delete SD Files"; + #endif + #endif // Build Main Menu mainMenu.parentMenu = NULL; @@ -1463,7 +1493,7 @@ void MenuFunctions::RunSetup() addSSIDGFX(); }); #endif - #ifdef MARAUDER_MINI + #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) this->addNodes(&wifiGeneralMenu, text_table1[1], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){ this->changeMenu(&miniKbMenu); this->miniKeyboard(&miniKbMenu); @@ -1504,7 +1534,7 @@ void MenuFunctions::RunSetup() #else // Mini EP HTML select this->addNodes(&wifiGeneralMenu, "Select EP HTML File", TFT_CYAN, NULL, KEYBOARD_ICO, [this](){ this->changeMenu(&htmlMenu); - #ifdef HAS_BUTTONS + #if (defined(HAS_BUTTONS) && defined(HAS_SD)) #if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1)) while(true) { if (d_btn.justPressed()) { @@ -1543,27 +1573,18 @@ void MenuFunctions::RunSetup() #endif }); - miniKbMenu.parentMenu = &wifiGeneralMenu; - this->addNodes(&miniKbMenu, "a", TFT_CYAN, NULL, 0, [this]() { - this->changeMenu(miniKbMenu.parentMenu); - }); + #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) + miniKbMenu.parentMenu = &wifiGeneralMenu; + this->addNodes(&miniKbMenu, "a", TFT_CYAN, NULL, 0, [this]() { + this->changeMenu(miniKbMenu.parentMenu); + }); + #endif htmlMenu.parentMenu = &wifiGeneralMenu; this->addNodes(&htmlMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { this->changeMenu(htmlMenu.parentMenu); }); - /*int loopLimit = min(evil_portal_obj.html_files->size(), BUTTON_ARRAY_LEN); - - for (int i = 0; i < loopLimit - 1; i++) { - this->addNodes(&htmlMenu, evil_portal_obj.html_files->get(i), TFT_CYAN, NULL, 0, [this, i]() { - evil_portal_obj.target_html_name = (String)evil_portal_obj.html_files->get(i); - Serial.println("Set Evil Portal HTML as " + evil_portal_obj.target_html_name); - evil_portal_obj.using_serial_html = false; - this->changeMenu(htmlMenu.parentMenu); - }); - }*/ - // Select APs on Mini this->addNodes(&wifiGeneralMenu, text_table1[56], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){ wifiAPMenu.list->clear(); @@ -1716,6 +1737,98 @@ void MenuFunctions::RunSetup() this->addNodes(&deviceMenu, text08, TFT_NAVY, NULL, KEYBOARD_ICO, [this]() { this->changeMenu(&settingsMenu); }); + + #ifdef HAS_SD + if (sd_obj.supported) { + this->addNodes(&deviceMenu, "Delete SD Files", TFT_CYAN, NULL, SD_UPDATE, [this]() { + #ifndef HAS_ILI9341 + #ifdef HAS_BUTTONS + this->changeMenu(&sdDeleteMenu); + #if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1)) + + bool deleting = true; + + display_obj.tft.setTextWrap(false); + display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3); + display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK); + display_obj.tft.println("Loading..."); + + while (deleting) { + // Build list of files + sd_obj.sd_files->clear(); + delete sd_obj.sd_files; + + sd_obj.sd_files = new LinkedList(); + + sd_obj.sd_files->add("Back"); + + sd_obj.listDirToLinkedList(sd_obj.sd_files); + + int sd_file_index = 0; + + this->sdDeleteMenu.list->set(0, MenuNode{sd_obj.sd_files->get(sd_file_index), false, TFT_CYAN, 0, NULL, true, NULL}); + this->buildButtons(&sdDeleteMenu); + this->displayCurrentMenu(); + + // Start button loop + while(true) { + #ifndef MARAUDER_M5STICKC + if (u_btn.justPressed()) { + if (sd_file_index > 0) + sd_file_index--; + else + sd_file_index = sd_obj.sd_files->size() - 1; + + this->sdDeleteMenu.list->set(0, MenuNode{sd_obj.sd_files->get(sd_file_index), false, TFT_CYAN, 0, NULL, true, NULL}); + this->buildButtons(&sdDeleteMenu); + this->displayCurrentMenu(); + } + #endif + if (d_btn.justPressed()) { + if (sd_file_index < sd_obj.sd_files->size() - 1) + sd_file_index++; + else + sd_file_index = 0; + + this->sdDeleteMenu.list->set(0, MenuNode{sd_obj.sd_files->get(sd_file_index), false, TFT_CYAN, 0, NULL, true, NULL}); + this->buildButtons(&sdDeleteMenu, 0, sd_obj.sd_files->get(sd_file_index)); + this->displayCurrentMenu(); + } + if (c_btn.justPressed()) { + if (sd_obj.sd_files->get(sd_file_index) != "Back") { + if (sd_obj.removeFile("/" + sd_obj.sd_files->get(sd_file_index))) + Serial.println("Successfully Removed File: /" + sd_obj.sd_files->get(sd_file_index)); + display_obj.tft.setTextWrap(false); + display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3); + display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK); + display_obj.tft.println("Deleting /" + sd_obj.sd_files->get(sd_file_index) + "..."); + } + else { + this->changeMenu(sdDeleteMenu.parentMenu); + deleting = false; + } + break; + } + } + } + #endif + #endif + #endif + }); + } + #endif + + #ifdef HAS_SD + #ifndef HAS_ILI9341 + #ifdef HAS_BUTTONS + sdDeleteMenu.parentMenu = &deviceMenu; + this->addNodes(&sdDeleteMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(sdDeleteMenu.parentMenu); + }); + #endif + #endif + #endif + // GPS Menu #ifdef HAS_GPS if (gps_obj.getGpsModuleStatus()) { @@ -1768,21 +1881,23 @@ void MenuFunctions::RunSetup() wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; this->changeMenu(whichUpdateMenu.parentMenu); }); - if (sd_obj.supported) addNodes(&whichUpdateMenu, text_table1[40], TFT_MAGENTA, NULL, SD_UPDATE, [this]() { - wifi_scan_obj.currentScanMode = OTA_UPDATE; - this->changeMenu(&confirmMenu); - }); + #ifdef HAS_SD + if (sd_obj.supported) addNodes(&whichUpdateMenu, text_table1[40], TFT_MAGENTA, NULL, SD_UPDATE, [this]() { + wifi_scan_obj.currentScanMode = OTA_UPDATE; + this->changeMenu(&confirmMenu); + }); - // Confirm SD update menu - confirmMenu.parentMenu = &whichUpdateMenu; - this->addNodes(&confirmMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { - this->changeMenu(confirmMenu.parentMenu); - }); - this->addNodes(&confirmMenu, text14, TFT_ORANGE, NULL, UPDATE, [this]() { - wifi_scan_obj.currentScanMode = OTA_UPDATE; - this->changeMenu(&failedUpdateMenu); - sd_obj.runUpdate(); - }); + // Confirm SD update menu + confirmMenu.parentMenu = &whichUpdateMenu; + this->addNodes(&confirmMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(confirmMenu.parentMenu); + }); + this->addNodes(&confirmMenu, text14, TFT_ORANGE, NULL, UPDATE, [this]() { + wifi_scan_obj.currentScanMode = OTA_UPDATE; + this->changeMenu(&failedUpdateMenu); + sd_obj.runUpdate(); + }); + #endif // Web Update updateMenu.parentMenu = &deviceMenu; @@ -1812,7 +1927,7 @@ void MenuFunctions::RunSetup() this->initTime = millis(); } -#ifdef MARAUDER_MINI +#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) void MenuFunctions::miniKeyboard(Menu * targetMenu) { // Prepare a char array and reset temp SSID string extern LinkedList* ssids; @@ -1836,8 +1951,8 @@ void MenuFunctions::RunSetup() #ifdef HAS_BUTTONS #if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1)) while(true) { - #ifndef MARAUDER_M5STICKC - // Cycle char previous + // Cycle char previous + #ifdef HAS_L if (l_btn.justPressed()) { pressed = true; if (this->mini_kb_index > 0) @@ -1847,19 +1962,40 @@ void MenuFunctions::RunSetup() targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFT_CYAN, 0, NULL, true, NULL}); this->buildButtons(targetMenu); - //this->displayCurrentMenu(); + 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, TFT_CYAN, 0, NULL, true, NULL}); + this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str()); + while (!r_btn.justReleased()) + delay(1); } + #endif - // Add character + //// 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 + // 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); @@ -1868,39 +2004,83 @@ void MenuFunctions::RunSetup() } #endif - // Cycle char next - 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, TFT_CYAN, 0, NULL, true, NULL}); - this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str()); - //this->displayCurrentMenu(); - } + //// 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; - // Add SSID - 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; + targetMenu->list->set(0, MenuNode{String(char_array[this->mini_kb_index]).c_str(), false, TFT_CYAN, 0, NULL, true, NULL}); + this->buildButtons(targetMenu, 0, String(char_array[this->mini_kb_index]).c_str()); } - delay(1); } - // If we have a string, add it to list of SSIDs - if (wifi_scan_obj.current_mini_kb_ssid != "") { + #endif + + // Prev char or remove char + #if (defined(HAS_U) && !defined(HAS_L)) + if (u_btn.justPressed()) { + bool was_held = false; 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 = ""; + 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, TFT_CYAN, 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 // Display info on screen if (pressed) { @@ -1916,10 +2096,8 @@ void MenuFunctions::RunSetup() display_obj.tft.println(ssids->get(0).essid); display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK); - display_obj.tft.println("U - Remove Char"); - display_obj.tft.println("D - Add Char"); - display_obj.tft.println("L - Previous Char"); - display_obj.tft.println("R - Next Char"); + display_obj.tft.println("U/D - Rem/Add Char"); + display_obj.tft.println("L/R - Prev/Nxt Char"); display_obj.tft.println("C - Save"); display_obj.tft.println("C(Hold) - Exit"); pressed = false; @@ -1996,7 +2174,6 @@ void MenuFunctions::buildButtons(Menu * menu, int starting_index, String button_ } } - void MenuFunctions::displayCurrentMenu(uint8_t start_index) { //Serial.println(F("Displaying current menu...")); @@ -2011,7 +2188,7 @@ void MenuFunctions::displayCurrentMenu(uint8_t start_index) display_obj.tft.setFreeFont(MENU_FONT); #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) display_obj.tft.setFreeFont(NULL); display_obj.tft.setTextSize(1); #endif @@ -2034,7 +2211,7 @@ void MenuFunctions::displayCurrentMenu(uint8_t start_index) #endif - #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) + #if defined(MARAUDER_MINI) || defined(MARAUDER_M5STICKC) || defined(MARAUDER_REV_FEATHER) if ((current_menu->selected == i) || (current_menu->list->get(i).selected)) display_obj.key[i - start_index].drawButton(true, current_menu->list->get(i).name); else diff --git a/esp32_marauder/MenuFunctions.h b/esp32_marauder/MenuFunctions.h index 84ee4d4f6..489797614 100644 --- a/esp32_marauder/MenuFunctions.h +++ b/esp32_marauder/MenuFunctions.h @@ -15,12 +15,12 @@ #include "settings.h" #ifdef HAS_BUTTONS - #include - extern SwitchLib u_btn; - extern SwitchLib d_btn; - extern SwitchLib l_btn; - extern SwitchLib r_btn; - extern SwitchLib c_btn; + #include "Switches.h" + extern Switches u_btn; + extern Switches d_btn; + extern Switches l_btn; + extern Switches r_btn; + extern Switches c_btn; #endif extern WiFiScan wifi_scan_obj; @@ -122,6 +122,7 @@ class MenuFunctions uint32_t initTime = 0; uint8_t menu_start_index = 0; uint8_t mini_kb_index = 0; + uint8_t old_gps_sat_count = 0; // Main menu stuff Menu mainMenu; @@ -140,6 +141,7 @@ class MenuFunctions Menu specSettingMenu; Menu infoMenu; Menu languageMenu; + Menu sdDeleteMenu; // WiFi menu stuff Menu wifiSnifferMenu; @@ -173,7 +175,7 @@ class MenuFunctions void displaySetting(String key, Menu* menu, int index); void buttonSelected(uint8_t b, int8_t x = -1); void buttonNotSelected(uint8_t b, int8_t x = -1); - #ifdef MARAUDER_MINI + #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) void miniKeyboard(Menu * targetMenu); #endif diff --git a/esp32_marauder/SDInterface.cpp b/esp32_marauder/SDInterface.cpp index adfbbefaf..c5a769eb0 100644 --- a/esp32_marauder/SDInterface.cpp +++ b/esp32_marauder/SDInterface.cpp @@ -79,6 +79,10 @@ bool SDInterface::initSD() { SD.mkdir("/SCRIPTS"); Serial.println("/SCRIPTS created"); } + + this->sd_files = new LinkedList(); + + this->sd_files->add("Back"); return true; } @@ -98,6 +102,13 @@ File SDInterface::getFile(String path) { } } +bool SDInterface::removeFile(String file_path) { + if (SD.remove(file_path)) + return true; + else + return false; +} + void SDInterface::listDirToLinkedList(LinkedList* file_names, String str_dir, String ext) { if (this->supported) { File dir = SD.open(str_dir); @@ -108,12 +119,18 @@ void SDInterface::listDirToLinkedList(LinkedList* file_names, String str { break; } + + if (entry.isDirectory()) + continue; + + String file_name = entry.name(); if (ext != "") { - String file_name = entry.name(); if (file_name.endsWith(ext)) { file_names->add(file_name); } } + else + file_names->add(file_name); } } } @@ -144,7 +161,7 @@ void SDInterface::runUpdate() { #ifdef HAS_SCREEN display_obj.tft.setTextWrap(false); display_obj.tft.setFreeFont(NULL); - display_obj.tft.setCursor(0, 100); + display_obj.tft.setCursor(0, TFT_HEIGHT / 3); display_obj.tft.setTextSize(1); display_obj.tft.setTextColor(TFT_WHITE); diff --git a/esp32_marauder/SDInterface.h b/esp32_marauder/SDInterface.h index af02262e6..eda62bafc 100644 --- a/esp32_marauder/SDInterface.h +++ b/esp32_marauder/SDInterface.h @@ -43,12 +43,15 @@ class SDInterface { bool initSD(); + LinkedList* sd_files; + void listDir(String str_dir); void listDirToLinkedList(LinkedList* file_names, String str_dir = "/", String ext = ""); File getFile(String path); void runUpdate(); void performUpdate(Stream &updateSource, size_t updateSize); void main(); + bool removeFile(String file_path); }; #endif diff --git a/esp32_marauder/Switches.cpp b/esp32_marauder/Switches.cpp new file mode 100644 index 000000000..b0c68dd0b --- /dev/null +++ b/esp32_marauder/Switches.cpp @@ -0,0 +1,98 @@ +#include "Switches.h" + +Switches::Switches() { + this->pin = 0; + this->pin = false; + this->pressed = false; + this->hold_lim = 2000; + this->cur_hold = 0; + this->isheld = false; + + pinMode(this->pin, INPUT); + + return; +} + +Switches::Switches(int pin, uint32_t hold_lim, bool pullup) { + this->pin = pin; + this->pullup = pullup; + this->pressed = false; + this->hold_lim = hold_lim; + this->cur_hold = 0; + this->isheld = false; + + if (pullup) + pinMode(this->pin, INPUT_PULLUP); + else + pinMode(this->pin, INPUT_PULLDOWN); + + return; +} + +int Switches::getPin() { + return this->pin; +} + +bool Switches::getPullup() { + return this->pullup; +} + +bool Switches::isHeld() { + return this->isheld; +} + +bool Switches::getButtonState() { + int buttonState = digitalRead(this->pin); + + if ((this->pullup) && (buttonState == LOW)) + return true; + else if ((!this->pullup) && (buttonState == HIGH)) + return true; + else + return false; +} + +bool Switches::justPressed() { + bool btn_state = this->getButtonState(); + + // Button was JUST pressed + if (btn_state && !this->pressed) { + this->hold_init = millis(); + this->pressed = btn_state; + return true; + } + else if (btn_state) { // Button is STILL pressed + // Check if button is held + //Serial.println("cur_hold: " + (String)this->cur_hold); + if ((millis() - this->hold_init) < this->hold_lim) { + this->isheld = false; + } + else { + this->isheld = true; + } + + this->pressed = btn_state; + return false; + } + else { // Button is not pressed + this->pressed = btn_state; + this->isheld = false; + return false; + } +} + +bool Switches::justReleased() { + bool btn_state = this->getButtonState(); + + // Button was JUST released + if (!btn_state && this->pressed) { + this->isheld = false; + this->pressed = btn_state; + return true; + } + else { // Button is STILL released + this->pressed = btn_state; + return false; + } + +} \ No newline at end of file diff --git a/esp32_marauder/Switches.h b/esp32_marauder/Switches.h new file mode 100644 index 000000000..8955709e6 --- /dev/null +++ b/esp32_marauder/Switches.h @@ -0,0 +1,35 @@ +#ifndef Switches_h +#define Switches_h + +#include + +class Switches { + private: + int pin; + uint32_t hold_lim; + uint32_t cur_hold; + + uint32_t hold_init = millis(); + + bool isheld; + + bool pullup; + + bool pressed; + + bool getButtonState(); + + public: + Switches(); + + Switches(int pin, uint32_t hold_lim, bool pullup); + + int getPin(); + bool getPullup(); + + bool justPressed(); + bool justReleased(); + bool isHeld(); +}; + +#endif \ No newline at end of file diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index 01f4831bf..01f024d94 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -1058,7 +1058,9 @@ void WiFiScan::RunAPScan(uint8_t scan_mode, uint16_t color) uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY Serial.println("Using TFT DIY"); #endif - display_obj.tft.setTouch(calData); + #ifdef HAS_ILI9341 + display_obj.tft.setTouch(calData); + #endif lv_obj_t * scr = lv_cont_create(NULL, NULL); @@ -4035,7 +4037,9 @@ void WiFiScan::activeEapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t uint16_t t_x = 0, t_y = 0; // To store the touch coordinates // Do the touch stuff - pressed = display_obj.tft.getTouch(&t_x, &t_y); + #ifdef HAS_ILI9341 + pressed = display_obj.tft.getTouch(&t_x, &t_y); + #endif if (pressed) { Serial.print("Got touch | X: "); @@ -4186,7 +4190,9 @@ void WiFiScan::activeEapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t uint16_t t_x = 0, t_y = 0; // To store the touch coordinates // Do the touch stuff - pressed = display_obj.tft.getTouch(&t_x, &t_y); + #ifdef HAS_ILI9341 + pressed = display_obj.tft.getTouch(&t_x, &t_y); + #endif if (pressed) { Serial.print("Got touch | X: "); diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 63c6cbb7f..22c5b9fe7 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -18,15 +18,18 @@ //#define ESP32_LDDB //#define MARAUDER_DEV_BOARD_PRO //#define XIAO_ESP32_S3 + //#define MARAUDER_REV_FEATHER //// END BOARD TARGETS - #define MARAUDER_VERSION "v0.13.8" + #define MARAUDER_VERSION "v0.13.9" //// HARDWARE NAMES #ifdef MARAUDER_M5STICKC #define HARDWARE_NAME "M5Stick-C Plus" #elif defined(MARAUDER_MINI) #define HARDWARE_NAME "Marauder Mini" + #elif defined(MARAUDER_REV_FEATHER) + #define HARDWARE_NAME "Adafruit Feather ESP32-S2 Reverse TFT" #elif defined(MARAUDER_V4) #define HARDWARE_NAME "Marauder v4" #elif defined(MARAUDER_V6) @@ -78,6 +81,20 @@ #define HAS_GPS #endif + #ifdef MARAUDER_REV_FEATHER + //#define FLIPPER_ZERO_HAT + //#define HAS_BATTERY + //#define HAS_BT + #define HAS_BUTTONS + #define HAS_NEOPIXEL_LED + //#define HAS_PWR_MGMT + #define HAS_SCREEN + #define HAS_SD + #define USE_SD + #define HAS_TEMP_SENSOR + #define HAS_GPS + #endif + #ifdef MARAUDER_V4 //#define FLIPPER_ZERO_HAT #define HAS_BATTERY @@ -201,12 +218,44 @@ //// BUTTON DEFINITIONS #ifdef HAS_BUTTONS + #ifdef MARAUDER_REV_FEATHER + #define L_BTN -1 + #define C_BTN 1 + #define U_BTN 0 + #define R_BTN -1 + #define D_BTN 2 + + //#define HAS_L + //#define HAS_R + #define HAS_U + #define HAS_D + #define HAS_C + + #define L_PULL true + #define C_PULL false + #define U_PULL true + #define R_PULL true + #define D_PULL false + #endif + #ifdef MARAUDER_MINI #define L_BTN 13 #define C_BTN 34 #define U_BTN 36 #define R_BTN 39 #define D_BTN 35 + + #define HAS_L + #define HAS_R + #define HAS_U + #define HAS_D + #define HAS_C + + #define L_PULL true + #define C_PULL true + #define U_PULL true + #define R_PULL true + #define D_PULL true #endif #ifdef MARAUDER_M5STICKC @@ -215,6 +264,18 @@ #define U_BTN -1 #define R_BTN -1 #define D_BTN 39 + + //#define HAS_L + //#define HAS_R + //#define HAS_U + #define HAS_D + #define HAS_C + + #define L_PULL true + #define C_PULL true + #define U_PULL true + #define R_PULL true + #define D_PULL true #endif #ifdef MARAUDER_V6 @@ -223,6 +284,18 @@ #define U_BTN -1 #define R_BTN -1 #define D_BTN -1 + + //#define HAS_L + //#define HAS_R + //#define HAS_U + //#define HAS_D + #define HAS_C + + #define L_PULL true + #define C_PULL true + #define U_PULL true + #define R_PULL true + #define D_PULL true #endif #ifdef MARAUDER_V6_1 @@ -231,6 +304,18 @@ #define U_BTN -1 #define R_BTN -1 #define D_BTN -1 + + //#define HAS_L + //#define HAS_R + //#define HAS_U + //#define HAS_D + #define HAS_C + + #define L_PULL true + #define C_PULL true + #define U_PULL true + #define R_PULL true + #define D_PULL true #endif #endif @@ -282,7 +367,7 @@ //#define MENU_FONT &FreeSans9pt7b //#define MENU_FONT &FreeSansBold9pt7b #define BUTTON_SCREEN_LIMIT 6 - #define BUTTON_ARRAY_LEN 13 + #define BUTTON_ARRAY_LEN 100 #define STATUS_BAR_WIDTH (TFT_HEIGHT/16) #define LVGL_TICK_PERIOD 6 @@ -524,7 +609,74 @@ //#define MENU_FONT &FreeSans9pt7b //#define MENU_FONT &FreeSansBold9pt7b #define BUTTON_SCREEN_LIMIT 10 - #define BUTTON_ARRAY_LEN 13 + #define BUTTON_ARRAY_LEN 100 + #define STATUS_BAR_WIDTH (TFT_HEIGHT/16) + #define LVGL_TICK_PERIOD 6 + + #define FRAME_X 100 + #define FRAME_Y 64 + #define FRAME_W 120 + #define FRAME_H 50 + + // Red zone size + #define REDBUTTON_X FRAME_X + #define REDBUTTON_Y FRAME_Y + #define REDBUTTON_W (FRAME_W/2) + #define REDBUTTON_H FRAME_H + + // Green zone size + #define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W) + #define GREENBUTTON_Y FRAME_Y + #define GREENBUTTON_W (FRAME_W/2) + #define GREENBUTTON_H FRAME_H + + #define STATUSBAR_COLOR 0x4A49 + #endif + + #ifdef MARAUDER_REV_FEATHER + #define SCREEN_CHAR_WIDTH 40 + //#define TFT_MISO 37 + //#define TFT_MOSI 35 + //#define TFT_SCLK 36 + #define TFT_CS 42 + #define TFT_DC 40 + #define TFT_RST 41 + #define TFT_BL 45 + //#define TOUCH_CS 21 + #define SD_CS 4 + + #define SCREEN_BUFFER + + #define MAX_SCREEN_BUFFER 9 + + #define BANNER_TEXT_SIZE 1 + + #ifndef TFT_WIDTH + #define TFT_WIDTH 240 + #endif + + #ifndef TFT_HEIGHT + #define TFT_HEIGHT 135 + #endif + + #define CHAR_WIDTH 6 + #define SCREEN_WIDTH TFT_WIDTH // Originally 240 + #define SCREEN_HEIGHT TFT_HEIGHT // Originally 320 + #define HEIGHT_1 TFT_WIDTH + #define WIDTH_1 TFT_WIDTH + #define STANDARD_FONT_CHAR_LIMIT (TFT_WIDTH/6) // number of characters on a single line with normal font + #define TEXT_HEIGHT (TFT_HEIGHT/10) // Height of text to be printed and scrolled + #define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen) + #define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen) + #define YMAX TFT_HEIGHT // Bottom of screen area + #define minimum(a,b) (((a) < (b)) ? (a) : (b)) + //#define MENU_FONT NULL + #define MENU_FONT &FreeMono9pt7b // Winner + //#define MENU_FONT &FreeMonoBold9pt7b + //#define MENU_FONT &FreeSans9pt7b + //#define MENU_FONT &FreeSansBold9pt7b + #define BUTTON_SCREEN_LIMIT 5 + #define BUTTON_ARRAY_LEN 100 #define STATUS_BAR_WIDTH (TFT_HEIGHT/16) #define LVGL_TICK_PERIOD 6 @@ -627,6 +779,24 @@ #define BUTTON_PADDING 10 #endif + #ifdef MARAUDER_REV_FEATHER + #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/12.8) + #define KEY_SPACING_X 0 // X and Y gap + #define KEY_SPACING_Y 1 + #define KEY_TEXTSIZE 1 // Font size multiplier + #define ICON_W 22 + #define ICON_H 22 + #define BUTTON_PADDING 10 + #endif + #ifdef MARAUDER_M5STICKC #define BANNER_TIME 50 @@ -669,6 +839,10 @@ #define SD_CS 4 #endif + #ifdef MARAUDER_REV_FEATHER + #define SD_CS 5 + #endif + #ifdef MARAUDER_M5STICKC #define SD_CS -1 #endif @@ -724,6 +898,8 @@ #define MEM_LOWER_LIM 20000 #elif defined(MARAUDER_MINI) #define MEM_LOWER_LIM 20000 + #elif defined(MARAUDER_REV_FEATHER) + #define MEM_LOWER_LIM 20000 #elif defined(MARAUDER_V4) #define MEM_LOWER_LIM 20000 #elif defined(MARAUDER_V6) || defined(MARAUDER_V6_1) @@ -750,6 +926,8 @@ #define PIN 17 #elif defined(MARAUDER_DEV_BOARD_PRO) #define PIN 16 + #elif defined(MARAUDER_REV_FEATHER) + #define PIN 33 #else #define PIN 25 #endif @@ -762,6 +940,8 @@ #define MAX_HTML_SIZE 11400 #elif defined(MARAUDER_MINI) #define MAX_HTML_SIZE 11400 + #elif defined(MARAUDER_REV_FEATHER) + #define MAX_HTML_SIZE 11400 #elif defined(MARAUDER_V4) #define MAX_HTML_SIZE 11400 #elif defined(MARAUDER_V6) || defined(MARAUDER_V6_1) @@ -820,6 +1000,11 @@ #define GPS_TX 33 #define GPS_RX 32 #define mac_history_len 512 + #elif defined(MARAUDER_REV_FEATHER) + #define GPS_SERIAL_INDEX 1 + #define GPS_TX 6 + #define GPS_RX 9 + #define mac_history_len 512 #endif #else #define mac_history_len 512 @@ -835,6 +1020,8 @@ #define MARAUDER_TITLE_BYTES 13578 #elif defined(MARAUDER_MINI) #define MARAUDER_TITLE_BYTES 13578 + #elif defined(MARAUDER_REV_FEATHER) + #define MARAUDER_TITLE_BYTES 13578 #else #define MARAUDER_TITLE_BYTES 13578 #endif diff --git a/esp32_marauder/esp32_marauder.ino b/esp32_marauder/esp32_marauder.ino index d5ce728ce..a974e19e9 100644 --- a/esp32_marauder/esp32_marauder.ino +++ b/esp32_marauder/esp32_marauder.ino @@ -13,7 +13,6 @@ https://www.online-utility.org/image/convert/to/XBM #endif #include -//#include "Web.h" #include "EvilPortal.h" #include #include "esp_wifi.h" @@ -41,11 +40,10 @@ https://www.online-utility.org/image/convert/to/XBM #include "xiaoLED.h" #elif defined(MARAUDER_M5STICKC) #include "stickcLED.h" -#else +#elif defined(HAS_NEOPIXEL_LED) #include "LedInterface.h" #endif -//#include "esp_interface.h" #include "settings.h" #include "CommandLine.h" #include "lang_var.h" @@ -54,42 +52,35 @@ https://www.online-utility.org/image/convert/to/XBM #include "BatteryInterface.h" #endif -//#ifdef HAS_TEMP_SENSOR -// #include "TemperatureInterface.h" -//#endif - #ifdef HAS_SCREEN #include "Display.h" #include "MenuFunctions.h" - //#include "a32u4_interface.h" #endif #ifdef HAS_BUTTONS - #include + #include "Switches.h" #if (U_BTN >= 0) - SwitchLib u_btn = SwitchLib(U_BTN, 1000, true); + Switches u_btn = Switches(U_BTN, 1000, U_PULL); #endif #if (D_BTN >= 0) - SwitchLib d_btn = SwitchLib(D_BTN, 1000, true); + Switches d_btn = Switches(D_BTN, 1000, D_PULL); #endif #if (L_BTN >= 0) - SwitchLib l_btn = SwitchLib(L_BTN, 1000, true); + Switches l_btn = Switches(L_BTN, 1000, L_PULL); #endif #if (R_BTN >= 0) - SwitchLib r_btn = SwitchLib(R_BTN, 1000, true); + Switches r_btn = Switches(R_BTN, 1000, R_PULL); #endif #if (C_BTN >= 0) - SwitchLib c_btn = SwitchLib(C_BTN, 1000, true); + Switches c_btn = Switches(C_BTN, 1000, C_PULL); #endif #endif WiFiScan wifi_scan_obj; EvilPortal evil_portal_obj; -//Web web_obj; Buffer buffer_obj; -//EspInterface esp_obj; Settings settings_obj; CommandLine cli_obj; @@ -101,14 +92,9 @@ CommandLine cli_obj; BatteryInterface battery_obj; #endif -//#ifdef HAS_TEMP_SENSOR -// TemperatureInterface temp_obj; -//#endif - #ifdef HAS_SCREEN Display display_obj; MenuFunctions menu_function_obj; - //A32u4Interface a32u4_obj; #endif #ifdef HAS_SD @@ -169,8 +155,6 @@ void setup() axp192_obj.begin(); #endif - //pinMode(FLASH_BUTTON, INPUT); - #ifdef HAS_SCREEN pinMode(TFT_BL, OUTPUT); #endif @@ -198,16 +182,8 @@ void setup() Serial.begin(115200); - //Serial.println("\n\nHello, World!\n"); - Serial.println("ESP-IDF version is: " + String(esp_get_idf_version())); - //#ifdef HAS_SCREEN - // Serial.println("Has Screen"); - //#else - // Serial.println("Does not have screen"); - //#endif - #ifdef HAS_SCREEN display_obj.RunSetup(); display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK); @@ -225,7 +201,6 @@ void setup() #endif #ifdef HAS_SCREEN - //showCenterText(version_number, 250); #ifndef MARAUDER_MINI display_obj.tft.drawCentreString(display_obj.version_number, 120, 250, 2); #endif @@ -264,20 +239,10 @@ void setup() display_obj.tft.println(text_table0[1]); #endif - //Serial.println("Internal Temp: " + (String)((temprature_sens_read() - 32) / 1.8)); - settings_obj.begin(); - //Serial.println("This is a test Channel: " + (String)settings_obj.loadSetting("Channel")); - //if (settings_obj.loadSetting( "Force PMKID")) - // Serial.println("This is a test Force PMKID: true"); - //else - // Serial.println("This is a test Force PMKID: false"); - wifi_scan_obj.RunSetup(); - //Serial.println(wifi_scan_obj.freeRAM()); - #ifdef HAS_SCREEN display_obj.tft.println(F(text_table0[2])); #endif @@ -309,23 +274,12 @@ void setup() display_obj.tft.println(F(text_table0[5])); #endif - // Temperature stuff - //#ifdef HAS_TEMP_SENSOR - // temp_obj.RunSetup(); - //#endif - #ifdef HAS_SCREEN display_obj.tft.println(F(text_table0[6])); #endif #ifdef HAS_BATTERY battery_obj.battery_level = battery_obj.getBatteryLevel(); - -// if (battery_obj.i2c_supported) { -// Serial.println(F("IP5306 I2C Supported: true")); -// } -// else -// Serial.println(F("IP5306 I2C Supported: false")); #endif // Do some LED stuff @@ -366,12 +320,6 @@ void setup() #ifdef HAS_SCREEN menu_function_obj.RunSetup(); #endif - - //Serial.println(F("\n\n--------------------------------\n")); - //Serial.println(F(" ESP32 Marauder \n")); - //Serial.println(" " + version_number + "\n"); - //Serial.println(F(" By: justcallmekoko\n")); - //Serial.println(F("--------------------------------\n\n")); Serial.println(F("CLI Ready")); cli_obj.RunSetup();