Sfoglia il codice sorgente

Added "Touch screen to exit"

Just Call Me Koko 6 anni fa
parent
commit
60715eda42

+ 38 - 8
esp32_marauder/Display.cpp

@@ -57,6 +57,13 @@ void Display::RunSetup()
   delay(5000);
 }
 
+void Display::touchToExit()
+{
+  tft.setTextColor(TFT_BLACK, TFT_LIGHTGREY);
+  tft.fillRect(0,16,240,16, TFT_LIGHTGREY);
+  tft.drawCentreString("Touch screen to exit",120,16,2);
+}
+
 
 // Function to just draw the screen black
 void Display::clearScreen()
@@ -98,16 +105,25 @@ void Display::showCenterText(String text, int y)
 }
 
 
-void Display::initScrollValues()
+void Display::initScrollValues(bool tte)
 {
   Serial.println("initScrollValues()");
   yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
 
   xPos = 0;
 
-  yStart = TOP_FIXED_AREA;
+  if (!tte)
+  {
+    yStart = TOP_FIXED_AREA;
+
+    yArea = YMAX - TOP_FIXED_AREA - BOT_FIXED_AREA;
+  }
+  else
+  {
+    yStart = TOP_FIXED_AREA_2;
 
-  yArea = YMAX - TOP_FIXED_AREA - BOT_FIXED_AREA;
+    yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
+  }
 
   for(int i = 0; i < 18; i++) blank[i] = 0;
 }
@@ -119,12 +135,26 @@ int Display::scroll_line(uint32_t color) {
   //Serial.println("scroll_line()");
   int yTemp = yStart; // Store the old yStart, this is where we draw the next line
   // Use the record of line lengths to optimise the rectangle size we need to erase the top line
-  tft.fillRect(0,yStart,blank[(yStart-TOP_FIXED_AREA)/TEXT_HEIGHT],TEXT_HEIGHT, color);
 
-  // Change the top of the scroll area
-  yStart+=TEXT_HEIGHT;
-  // The value must wrap around as the screen memory is a circular buffer
-  if (yStart >= YMAX - BOT_FIXED_AREA) yStart = TOP_FIXED_AREA + (yStart - YMAX + BOT_FIXED_AREA);
+  // Check if we have the "touch to exit bar"
+  if (!tteBar)
+  {
+    tft.fillRect(0,yStart,blank[(yStart-TOP_FIXED_AREA)/TEXT_HEIGHT],TEXT_HEIGHT, color);
+  
+    // Change the top of the scroll area
+    yStart+=TEXT_HEIGHT;
+    // The value must wrap around as the screen memory is a circular buffer
+    if (yStart >= YMAX - BOT_FIXED_AREA) yStart = TOP_FIXED_AREA + (yStart - YMAX + BOT_FIXED_AREA);
+  }
+  else
+  {
+    tft.fillRect(0,yStart,blank[(yStart-TOP_FIXED_AREA_2)/TEXT_HEIGHT],TEXT_HEIGHT, color);
+  
+    // Change the top of the scroll area
+    yStart+=TEXT_HEIGHT;
+    // The value must wrap around as the screen memory is a circular buffer
+    if (yStart >= YMAX - BOT_FIXED_AREA) yStart = TOP_FIXED_AREA_2 + (yStart - YMAX + BOT_FIXED_AREA);
+  }
   // Now we can scroll the display
   scrollAddress(yStart);
   return  yTemp;

+ 4 - 2
esp32_marauder/Display.h

@@ -17,6 +17,7 @@
 #define TEXT_HEIGHT 16 // 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 16 // Number of lines in top fixed area (lines counted from top of screen)
+#define TOP_FIXED_AREA_2 32 // If we have the "touch to exit" bar
 #define YMAX 320 // Bottom of screen area
 #define minimum(a,b)     (((a) < (b)) ? (a) : (b))
 //#define MENU_FONT NULL
@@ -49,8 +50,8 @@ class Display
     String version_number = "v0.1";
 
     bool printing = false;
-
     bool loading = false;
+    bool tteBar = false;
 
     int print_delay_1, print_delay_2 = 10;
 
@@ -82,7 +83,7 @@ class Display
     void displayBuffer(bool do_clear = false);
     void drawJpeg(const char *filename, int xpos, int ypos);
     void getTouchWhileFunction(bool pressed);
-    void initScrollValues();
+    void initScrollValues(bool tte = false);
     void jpegInfo();
     void jpegRender(int xpos, int ypos);
     void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
@@ -93,5 +94,6 @@ class Display
     int scroll_line(uint32_t color);
     void setupScrollArea(uint16_t tfa, uint16_t bfa);
     void showCenterText(String text, int y);
+    void touchToExit();
 };
 #endif

+ 7 - 2
esp32_marauder/MenuFunctions.cpp

@@ -212,9 +212,14 @@ void MenuFunctions::displayCurrentMenu()
   display_obj.clearScreen();
   display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY);
   display_obj.tft.fillRect(0,0,240,16, TFT_DARKGREY);
-  display_obj.tft.drawCentreString(" ESP32 Marauder ",120,0,2);
+  //display_obj.tft.drawCentreString(" ESP32 Marauder ",120,0,2);
+  //Serial.println("Getting size...");
+  //char buf[&current_menu->parentMenu->name.length() + 1] = {};
+  //Serial.println("Got size...");
+  //current_menu->parentMenu->name.toCharArray(buf, current_menu->parentMenu->name.length() + 1);
   //String current_name = &current_menu->parentMenu->name;
-  //display_obj.tft.drawCentreString(current_name,120,0,2);
+  //Serial.println("gottem");
+  display_obj.tft.drawCentreString(current_menu->name,120,0,2);
   if (current_menu->list != NULL)
   {
     display_obj.tft.setFreeFont(MENU_FONT);

+ 18 - 8
esp32_marauder/WiFiScan.cpp

@@ -109,6 +109,8 @@ void WiFiScan::StopScan(uint8_t scan_mode)
   display_obj.display_buffer->clear();
   Serial.print("display_buffer->size(): ");
   Serial.println(display_obj.display_buffer->size());
+
+  display_obj.tteBar = false;
 }
 
 // Function for updating scan status
@@ -131,16 +133,18 @@ void WiFiScan::main(uint32_t currentTime)
 // Function to start running a beacon scan
 void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
 {
+  display_obj.tteBar = true;
   display_obj.print_delay_1 = 15;
   display_obj.print_delay_2 = 10;
   display_obj.clearScreen();
-  display_obj.initScrollValues();
+  display_obj.initScrollValues(true);
   display_obj.tft.setTextWrap(false);
   display_obj.tft.setTextColor(TFT_WHITE, color);
   display_obj.tft.fillRect(0,0,240,16, color);
   display_obj.tft.drawCentreString(" Beacon Sniffer ",120,0,2);
+  display_obj.touchToExit();
   display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
-  display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
+  display_obj.setupScrollArea(TOP_FIXED_AREA_2, BOT_FIXED_AREA);
   wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
   esp_wifi_init(&cfg);
   esp_wifi_set_storage(WIFI_STORAGE_RAM);
@@ -156,16 +160,18 @@ void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
 // Function for running probe request scan
 void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
 {
+  display_obj.tteBar = true;
   display_obj.print_delay_1 = 15;
   display_obj.print_delay_2 = 10;
   display_obj.clearScreen();
-  display_obj.initScrollValues();
+  display_obj.initScrollValues(true);
   display_obj.tft.setTextWrap(false);
   display_obj.tft.setTextColor(TFT_BLACK, color);
   display_obj.tft.fillRect(0,0,240,16, color);
   display_obj.tft.drawCentreString(" Probe Request Sniffer ",120,0,2);
+  display_obj.touchToExit();
   display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
-  display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
+  display_obj.setupScrollArea(TOP_FIXED_AREA_2, BOT_FIXED_AREA);
   wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
   esp_wifi_init(&cfg);
   esp_wifi_set_storage(WIFI_STORAGE_RAM);
@@ -186,26 +192,30 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
   pBLEScan = BLEDevice::getScan(); //create new scan
   if (scan_mode == BT_SCAN_ALL)
   {
+    display_obj.tteBar = true;
     display_obj.clearScreen();
-    display_obj.initScrollValues();
+    display_obj.initScrollValues(true);
     display_obj.tft.setTextWrap(false);
     display_obj.tft.setTextColor(TFT_BLACK, color);
     display_obj.tft.fillRect(0,0,240,16, color);
     display_obj.tft.drawCentreString(" Bluetooth Sniff ",120,0,2);
+    display_obj.touchToExit();
     display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
-    display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
+    display_obj.setupScrollArea(TOP_FIXED_AREA_2, BOT_FIXED_AREA);
     pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback());
   }
   else if (scan_mode == BT_SCAN_SKIMMERS)
   {
+    display_obj.tteBar = true;
     display_obj.clearScreen();
-    display_obj.initScrollValues();
+    display_obj.initScrollValues(true);
     display_obj.tft.setTextWrap(false);
     display_obj.tft.setTextColor(TFT_BLACK, color);
     display_obj.tft.fillRect(0,0,240,16, color);
     display_obj.tft.drawCentreString(" Detect Card Skimmers ",120,0,2);
+    display_obj.touchToExit();
     display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK);
-    display_obj.setupScrollArea(TOP_FIXED_AREA, BOT_FIXED_AREA);
+    display_obj.setupScrollArea(TOP_FIXED_AREA_2, BOT_FIXED_AREA);
     pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanSkimmersCallback());
   }
   pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster