mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-12 15:50:36 -08:00
Add exit function to draw app
This commit is contained in:
@@ -58,14 +58,14 @@ void Display::RunSetup()
|
||||
|
||||
|
||||
// Draw the title screen
|
||||
drawJpeg("/marauder3L.jpg", 0 , 0); // 240 x 320 image
|
||||
//drawJpeg("/marauder3L.jpg", 0 , 0); // 240 x 320 image
|
||||
|
||||
//showCenterText(version_number, 250);
|
||||
tft.drawCentreString(version_number, 120, 250, 2);
|
||||
//tft.drawCentreString(version_number, 120, 250, 2);
|
||||
|
||||
digitalWrite(TFT_BL, HIGH);
|
||||
//digitalWrite(TFT_BL, HIGH);
|
||||
|
||||
delay(5000);
|
||||
//delay(5000);
|
||||
}
|
||||
|
||||
/* Interrupt driven periodic handler */
|
||||
@@ -462,6 +462,12 @@ void Display::drawJpeg(const char *filename, int xpos, int ypos) {
|
||||
}
|
||||
}
|
||||
|
||||
void Display::setupDraw() {
|
||||
this->tft.drawLine(0, 0, 10, 0, TFT_MAGENTA);
|
||||
this->tft.drawLine(0, 0, 0, 10, TFT_GREEN);
|
||||
this->tft.drawLine(0, 0, 0, 0, TFT_CYAN);
|
||||
}
|
||||
|
||||
uint16_t xlast;
|
||||
uint16_t ylast;
|
||||
uint32_t AH;
|
||||
@@ -472,6 +478,13 @@ void Display::drawStylus()
|
||||
// Pressed will be set true is there is a valid touch on the screen
|
||||
boolean pressed = tft.getTouch(&x, &y);
|
||||
|
||||
if ((x <= 10) && (y <= 10) && (pressed)) {
|
||||
Serial.println("Exit draw function");
|
||||
this->draw_tft = false;
|
||||
this->exit_draw = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw a white spot at the detected coordinates
|
||||
if (pressed) {
|
||||
// tft.fillCircle(x, y, 2, TFT_WHITE);
|
||||
|
||||
@@ -81,6 +81,7 @@ class Display
|
||||
bool loading = false;
|
||||
bool tteBar = false;
|
||||
bool draw_tft = false;
|
||||
bool exit_draw = false;
|
||||
|
||||
int TOP_FIXED_AREA_2 = 48;
|
||||
int print_delay_1, print_delay_2 = 10;
|
||||
@@ -124,6 +125,7 @@ class Display
|
||||
void clearScreen();
|
||||
void displayBuffer(bool do_clear = false);
|
||||
void drawJpeg(const char *filename, int xpos, int ypos);
|
||||
void setupDraw();
|
||||
void drawStylus();
|
||||
void getTouchWhileFunction(bool pressed);
|
||||
void initScrollValues(bool tte = false);
|
||||
|
||||
@@ -10,6 +10,10 @@ MenuFunctions::MenuFunctions()
|
||||
// Function to check menu input
|
||||
void MenuFunctions::main(uint32_t currentTime)
|
||||
{
|
||||
if (display_obj.exit_draw) {
|
||||
display_obj.exit_draw = false;
|
||||
changeMenu(current_menu);
|
||||
}
|
||||
if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_OFF) ||
|
||||
(wifi_scan_obj.currentScanMode == OTA_UPDATE) ||
|
||||
(wifi_scan_obj.currentScanMode == SHOW_INFO)) {
|
||||
@@ -578,6 +582,7 @@ void MenuFunctions::RunSetup()
|
||||
});
|
||||
addNodes(&generalMenu, "Draw", TFT_WHITE, NULL, DRAW, [this]() {
|
||||
display_obj.clearScreen();
|
||||
display_obj.setupDraw();
|
||||
display_obj.draw_tft = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -70,6 +70,15 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
display_obj.RunSetup();
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
digitalWrite(TFT_BL, HIGH);
|
||||
|
||||
display_obj.tft.println("Marauder " + display_obj.version_number + "\n");
|
||||
|
||||
display_obj.tft.println("Started Serial");
|
||||
|
||||
Serial.println("\n\n--------------------------------\n");
|
||||
Serial.println(" ESP32 Marauder \n");
|
||||
Serial.println(" " + display_obj.version_number + "\n");
|
||||
@@ -80,28 +89,42 @@ void setup()
|
||||
|
||||
Serial.println(wifi_scan_obj.freeRAM());
|
||||
|
||||
display_obj.tft.println("Checked RAM");
|
||||
|
||||
// Do some SD stuff
|
||||
if(sd_obj.initSD())
|
||||
if(sd_obj.initSD()) {
|
||||
Serial.println("SD Card supported");
|
||||
else
|
||||
display_obj.tft.println("Initialized SD Card");
|
||||
}
|
||||
else {
|
||||
Serial.println("SD Card NOT Supported");
|
||||
display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
display_obj.tft.println("Failed to Initialize SD Card");
|
||||
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||
}
|
||||
|
||||
// Run display setup
|
||||
Serial.println(wifi_scan_obj.freeRAM());
|
||||
display_obj.RunSetup();
|
||||
//display_obj.RunSetup();
|
||||
|
||||
// Build menus
|
||||
Serial.println(wifi_scan_obj.freeRAM());
|
||||
menu_function_obj.RunSetup();
|
||||
//menu_function_obj.RunSetup();
|
||||
|
||||
//display_obj.tft.println("Created Menu Structure");
|
||||
|
||||
// Battery stuff
|
||||
Serial.println(wifi_scan_obj.freeRAM());
|
||||
battery_obj.RunSetup();
|
||||
|
||||
display_obj.tft.println("Checked battery configuration");
|
||||
|
||||
// Temperature stuff
|
||||
Serial.println(wifi_scan_obj.freeRAM());
|
||||
temp_obj.RunSetup();
|
||||
|
||||
display_obj.tft.println("Initialized temperature interface");
|
||||
|
||||
battery_obj.battery_level = battery_obj.getBatteryLevel();
|
||||
|
||||
if (battery_obj.i2c_supported) {
|
||||
@@ -114,6 +137,28 @@ void setup()
|
||||
|
||||
// Do some LED stuff
|
||||
led_obj.RunSetup();
|
||||
|
||||
display_obj.tft.println("Initialized LED Interface");
|
||||
|
||||
display_obj.tft.println("Starting...");
|
||||
|
||||
delay(1000);
|
||||
|
||||
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
digitalWrite(TFT_BL, LOW);
|
||||
|
||||
// Draw the title screen
|
||||
display_obj.drawJpeg("/marauder3L.jpg", 0 , 0); // 240 x 320 image
|
||||
|
||||
//showCenterText(version_number, 250);
|
||||
display_obj.tft.drawCentreString(display_obj.version_number, 120, 250, 2);
|
||||
|
||||
digitalWrite(TFT_BL, HIGH);
|
||||
|
||||
delay(5000);
|
||||
|
||||
menu_function_obj.RunSetup();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user