diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index ce3b3e5..bf11dca 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -474,8 +474,55 @@ void Display::listDir(fs::FS &fs, const char * dirname, uint8_t levels) { } #endif -void Display::main() + +void Display::updateBanner(String msg) { + this->img.deleteSprite(); + + this->img.setColorDepth(8); + + this->img.createSprite(SCREEN_WIDTH, TEXT_HEIGHT); + + this->buildBanner(msg, current_banner_pos); + + this->img.pushSprite(0, 0); + + current_banner_pos--; + + if (current_banner_pos <= 0) + current_banner_pos = SCREEN_WIDTH; +} + + +void Display::buildBanner(String msg, int xpos) +{ + int h = TEXT_HEIGHT; + + // We could just use fillSprite(color) but lets be a bit more creative... + + // Fill with rainbow stripes + //while (h--) img.drawFastHLine(0, h, SCREEN_WIDTH, 255); + + // Draw some graphics, the text will apear to scroll over these + //img.fillRect (SCREEN_WIDTH / 2 - 20, TEXT_HEIGHT / 2 - 10, 40, 20, TFT_YELLOW); + //img.fillCircle(SCREEN_WIDTH / 2, TEXT_HEIGHT / 2, 10, TFT_ORANGE); + + // Now print text on top of the graphics + img.setTextSize(2); // Font size scaling is x1 + img.setTextFont(0); // Font 4 selected + img.setTextColor(TFT_WHITE); // Black text, no background colour + img.setTextWrap(false); // Turn of wrap so we can print past end of sprite + + // Need to print twice so text appears to wrap around at left and right edges + img.setCursor(xpos, 2); // Print text at xpos + img.print(msg); + + img.setCursor(xpos - SCREEN_WIDTH, 2); // Print text at xpos - sprite width + img.print(msg); +} + +void Display::main() +{ return; } // End SPIFFS_functions diff --git a/esp32_marauder/Display.h b/esp32_marauder/Display.h index 34082e8..9577b04 100644 --- a/esp32_marauder/Display.h +++ b/esp32_marauder/Display.h @@ -47,6 +47,7 @@ class Display public: Display(); TFT_eSPI tft = TFT_eSPI(); + TFT_eSprite img = TFT_eSprite(&tft); String version_number = "v0.2"; bool printing = false; @@ -56,6 +57,7 @@ class Display int TOP_FIXED_AREA_2 = 32; int print_delay_1, print_delay_2 = 10; + int current_banner_pos = SCREEN_WIDTH; //Menu* current_menu; @@ -80,7 +82,8 @@ class Display // for a full width line, meanwhile the serial buffer may be filling... and overflowing // We can speed up scrolling of short text lines by just blanking the character we drew int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking - + + void buildBanner(String msg, int xpos); void clearScreen(); void displayBuffer(bool do_clear = false); void drawJpeg(const char *filename, int xpos, int ypos); @@ -99,5 +102,6 @@ class Display void showCenterText(String text, int y); void touchToExit(); void twoPartDisplay(String center_text); + void updateBanner(String msg); }; #endif diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index 26a5de9..ac632c2 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -8,6 +8,11 @@ MenuFunctions::MenuFunctions() // Function to check menu input void MenuFunctions::main() { + if (wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) + display_obj.updateBanner(current_menu->name); + + //this->displayCurrentMenu(); + boolean pressed = false; // This is code from bodmer's keypad example uint16_t t_x = 0, t_y = 0; // To store the touch coordinates @@ -256,7 +261,7 @@ void MenuFunctions::displayCurrentMenu() Serial.println("Displaying current menu..."); display_obj.clearScreen(); display_obj.tft.setTextColor(TFT_LIGHTGREY, TFT_DARKGREY); - display_obj.tft.fillRect(0,0,240,16, TFT_DARKGREY); + //display_obj.tft.fillRect(0,0,240,16, TFT_DARKGREY); //display_obj.tft.drawCentreString(" ESP32 Marauder ",120,0,2); //Serial.println("Getting size..."); //char buf[¤t_menu->parentMenu->name.length() + 1] = {}; @@ -264,7 +269,7 @@ void MenuFunctions::displayCurrentMenu() //current_menu->parentMenu->name.toCharArray(buf, current_menu->parentMenu->name.length() + 1); //String current_name = ¤t_menu->parentMenu->name; //Serial.println("gottem"); - display_obj.tft.drawCentreString(current_menu->name,120,0,2); + //display_obj.tft.drawCentreString(current_menu->name,120,0,2); if (current_menu->list != NULL) { display_obj.tft.setFreeFont(MENU_FONT);