From 4f04e91d0a2383a7f09ca79008e31b5b4b398cc3 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Sat, 30 Jul 2022 20:48:25 -0400 Subject: [PATCH] Add screen buffer for mini --- esp32_marauder/Display.cpp | 65 +++++++++++++++++++++++++++---------- esp32_marauder/Display.h | 8 +++++ esp32_marauder/WiFiScan.cpp | 7 ++-- esp32_marauder/configs.h | 11 +++++-- esp32_marauder/lang_var.h | 30 ++++++++--------- 5 files changed, 84 insertions(+), 37 deletions(-) diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index 4c343b8..757be0e 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -14,6 +14,10 @@ void Display::RunSetup() // Need to declare new display_buffer = new LinkedList(); + + #ifdef SCREEN_BUFFER + screen_buffer = new LinkedList(); + #endif tft.init(); tft.setRotation(0); // Portrait @@ -252,30 +256,57 @@ void Display::clearScreen() tft.setCursor(0, 0); } +#ifdef SCREEN_BUFFER +void Display::scrollScreenBuffer(bool down) { + // Scroll screen normal direction (Up) + if (!down) { + this->screen_buffer->shift(); + } +} +#endif + void Display::displayBuffer(bool do_clear) { if (this->display_buffer->size() > 0) { delay(1); - + while (display_buffer->size() > 0) { - xPos = 0; - if ((display_buffer->size() > 0) && (!loading)) - { - printing = true; - delay(print_delay_1); - yDraw = scroll_line(TFT_RED); - tft.setCursor(xPos, yDraw); - tft.setTextColor(TFT_GREEN, TFT_BLACK); - tft.print(display_buffer->shift()); - printing = false; - delay(print_delay_2); - } - if (!tteBar) - blank[(18+(yStart - TOP_FIXED_AREA) / TEXT_HEIGHT)%19] = xPos; - else - blank[(18+(yStart - TOP_FIXED_AREA_2) / TEXT_HEIGHT)%19] = xPos; + + #ifndef SCREEN_BUFFER + xPos = 0; + if ((display_buffer->size() > 0) && (!loading)) + { + printing = true; + delay(print_delay_1); + yDraw = scroll_line(TFT_RED); + tft.setCursor(xPos, yDraw); + tft.setTextColor(TFT_GREEN, TFT_BLACK); + tft.print(display_buffer->shift()); + printing = false; + delay(print_delay_2); + } + if (!tteBar) + blank[(18+(yStart - TOP_FIXED_AREA) / TEXT_HEIGHT)%19] = xPos; + else + blank[(18+(yStart - TOP_FIXED_AREA_2) / TEXT_HEIGHT)%19] = xPos; + #else + xPos = 0; + if (this->screen_buffer->size() >= MAX_SCREEN_BUFFER) + this->scrollScreenBuffer(); + + screen_buffer->add(display_buffer->shift()); + + for (int i = 0; i < this->screen_buffer->size(); i++) { + tft.setCursor(xPos, (i * 12) + (SCREEN_HEIGHT / 3)); + for (int x = 0; x < TFT_WIDTH / CHAR_WIDTH; x++) + tft.print(" "); + tft.setCursor(xPos, (i * 12) + (SCREEN_HEIGHT / 3)); + tft.setTextColor(TFT_GREEN, TFT_BLACK); + tft.print(this->screen_buffer->get(i)); + } + #endif } } } diff --git a/esp32_marauder/Display.h b/esp32_marauder/Display.h index 3356ea0..55b045e 100644 --- a/esp32_marauder/Display.h +++ b/esp32_marauder/Display.h @@ -72,6 +72,10 @@ class Display void drawFrame(); + #ifdef SCREEN_BUFFER + void scrollScreenBuffer(bool down = false); + #endif + //void addNodes(Menu* menu, String name, Menu* child, std::function callable); //void changeMenu(Menu* menu); //void showMenuList(Menu* menu, int layer); @@ -103,6 +107,10 @@ class Display LinkedList* display_buffer; + #ifdef SCREEN_BUFFER + LinkedList* screen_buffer; + #endif + // The initial y coordinate of the top of the bottom text line uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT; diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index a0f3ab6..f528f9b 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -443,6 +443,9 @@ void WiFiScan::StopScan(uint8_t scan_mode) #ifdef HAS_SCREEN display_obj.display_buffer->clear(); + #ifdef SCREEN_BUFFER + display_obj.screen_buffer->clear(); + #endif //Serial.print("display_buffer->size(): "); Serial.println(display_obj.display_buffer->size()); @@ -682,11 +685,11 @@ void WiFiScan::RunInfo() #ifdef HAS_SCREEN display_obj.tft.setTextWrap(false); display_obj.tft.setFreeFont(NULL); - display_obj.tft.setCursor(0, 100); + display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3); display_obj.tft.setTextSize(1); display_obj.tft.setTextColor(TFT_CYAN); display_obj.tft.println(text_table4[20]); - display_obj.tft.println(text_table4[21] + display_obj.version_number + "\n"); + display_obj.tft.println(text_table4[21] + display_obj.version_number); display_obj.tft.println(text_table4[22] + (String)esp_get_idf_version()); #endif diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 70bbba8..1f39d52 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -4,12 +4,12 @@ #define POLISH_POTATO - //#define MARAUDER_MINI + #define MARAUDER_MINI //#define MARAUDER_V4 //#define MARAUDER_V6 //#define MARAUDER_KIT //#define GENERIC_ESP32 - #define MARAUDER_FLIPPER + //#define MARAUDER_FLIPPER #define MARAUDER_VERSION "v0.9.11" @@ -201,6 +201,10 @@ #define TOUCH_CS 21 #define SD_CS 4 + #define SCREEN_BUFFER + + #define MAX_SCREEN_BUFFER 8 + #define BANNER_TEXT_SIZE 1 #ifndef TFT_WIDTH @@ -210,7 +214,8 @@ #ifndef TFT_HEIGHT #define TFT_HEIGHT 128 #endif - + + #define CHAR_WIDTH 6 #define SCREEN_WIDTH TFT_WIDTH // Originally 240 #define SCREEN_HEIGHT TFT_HEIGHT // Originally 320 #define HEIGHT_1 TFT_WIDTH diff --git a/esp32_marauder/lang_var.h b/esp32_marauder/lang_var.h index f0f15a0..76bccff 100644 --- a/esp32_marauder/lang_var.h +++ b/esp32_marauder/lang_var.h @@ -144,21 +144,21 @@ PROGMEM const char text4_16[] = "Shutting down WiFi..."; PROGMEM const char text4_17[] = "WiFi not currently initialized"; PROGMEM const char text4_18[] = "Shutting down BLE..."; PROGMEM const char text4_19[] = "BLE not currently initialized"; -PROGMEM const char text4_20[] = " Firmware: Marauder"; //From 20 to 35 add spaces so : is in line like it is now -PROGMEM const char text4_21[] = " Version: "; -PROGMEM const char text4_22[] = " ESP-IDF: "; -PROGMEM const char text4_23[] = " WSL Bypass: enabled\n"; -PROGMEM const char text4_24[] = " WSL Bypass: disabled\n"; -PROGMEM const char text4_25[] = " Station MAC: "; -PROGMEM const char text4_26[] = " AP MAC: "; -PROGMEM const char text4_27[] = " "; -PROGMEM const char text4_28[] = " SD Card: Connected"; -PROGMEM const char text4_29[] = " SD Card Size: "; -PROGMEM const char text4_30[] = " SD Card: Not Connected"; -PROGMEM const char text4_31[] = " SD Card Size: 0"; -PROGMEM const char text4_32[] = " IP5306 I2C: supported"; -PROGMEM const char text4_33[] = " Battery Lvl: "; -PROGMEM const char text4_34[] = " IP5306 I2C: not supported"; +PROGMEM const char text4_20[] = "Firmware: Marauder"; //From 20 to 35 add spaces so : is in line like it is now +PROGMEM const char text4_21[] = "Version: "; +PROGMEM const char text4_22[] = "ESP-IDF: "; +PROGMEM const char text4_23[] = "WSL Bypass: enabled"; +PROGMEM const char text4_24[] = "WSL Bypass: disabled"; +PROGMEM const char text4_25[] = "Station MAC: "; +PROGMEM const char text4_26[] = "AP MAC: "; +PROGMEM const char text4_27[] = ""; +PROGMEM const char text4_28[] = "SD Card: Connected"; +PROGMEM const char text4_29[] = "SD Card Size: "; +PROGMEM const char text4_30[] = "SD Card: Not Connected"; +PROGMEM const char text4_31[] = "SD Card Size: 0"; +PROGMEM const char text4_32[] = "IP5306 I2C: supported"; +PROGMEM const char text4_33[] = "Battery Lvl: "; +PROGMEM const char text4_34[] = "IP5306 I2C: not supported"; PROGMEM const char text4_35[] = "Internal temp: "; PROGMEM const char text4_36[] = " Detect Espressif "; PROGMEM const char text4_37[] = " Detect Pwnagotchi ";