diff --git a/clean.sh b/clean.sh old mode 100644 new mode 100755 diff --git a/src/display.cpp b/src/display.cpp index dca06750..511bd122 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -1,5 +1,6 @@ #include "display.h" #include "mykeyboard.h" +#include "wg.h" //for is_connected to print wireguard lock #if defined(CARDPUTER) || defined(STICK_C_PLUS2) //Battery Calculation #include @@ -370,6 +371,7 @@ void drawMainMenu(int index) { tft.drawRoundRect(5, 5, WIDTH - 10, HEIGHT - 10, 5, FGCOLOR); tft.drawLine(5, 25, WIDTH - 6, 25, FGCOLOR); drawBatteryStatus(); + drawWireguardStatus(); } @@ -427,6 +429,20 @@ void drawBatteryStatus() { tft.drawLine(WIDTH - 20, 9, WIDTH - 20, 9 + 13, BGCOLOR); } +void drawWireguardStatus() { + + if(is_connected){ + tft.setTextColor(TFT_GREEN, BGCOLOR); + tft.drawRoundRect(WIDTH - 85, 15, 10, 5, 0, TFT_GREEN); + tft.fillRoundRect(WIDTH - 85, 15, 10, 5, 0, TFT_GREEN); + } else { + tft.setTextColor(TFT_RED, BGCOLOR); + tft.drawRoundRect(WIDTH - 85, 15, 10, 5, 0, TFT_RED); + tft.setTextSize(FP); + tft.fillRoundRect(WIDTH - 85, 15, 10, 5, 0, TFT_RED); + } + +} /*************************************************************************************** ** Function name: listFiles diff --git a/src/display.h b/src/display.h index 3e206fe3..3940f812 100644 --- a/src/display.h +++ b/src/display.h @@ -27,6 +27,8 @@ void listFiles(int index, String fileList[][3]); void displayScanning(); +void drawWireguardStatus(); + void progressHandler(int progress, size_t total); int getBattery(); diff --git a/src/wg.cpp b/src/wg.cpp index 7871bd61..3438e678 100644 --- a/src/wg.cpp +++ b/src/wg.cpp @@ -11,7 +11,8 @@ char private_key[45]; IPAddress local_ip; char public_key[45]; char endpoint_address[16]; -int endpoint_port = 31337; +int endpoint_port = 31337; +bool is_connected = false; static constexpr const uint32_t UPDATE_INTERVAL_MS = 5000; @@ -116,7 +117,7 @@ void wg_setup() tft.setCursor(0, 0); Serial.println("Connected. Initializing WireGuard..."); - tft.println("Connecting to\nwireguard..."); + //tft.println("Connecting to\nwireguard..."); wg.begin( local_ip, private_key, @@ -129,9 +130,9 @@ void wg_setup() Serial.println(public_key); Serial.println(endpoint_port); - //tft.clear(); tft.fillScreen(BGCOLOR); tft.setCursor(0, 0); + tft.setTextSize(3); tft.setTextColor(TFT_GREEN, BGCOLOR); tft.println("Connected!"); @@ -141,5 +142,7 @@ void wg_setup() tft.println(local_ip); tft.setTextColor(FGCOLOR, BGCOLOR); Serial.println(local_ip); + delay(7000); + is_connected = true; tft.fillScreen(BGCOLOR); } \ No newline at end of file diff --git a/src/wg.h b/src/wg.h index c055e452..55abf7cc 100644 --- a/src/wg.h +++ b/src/wg.h @@ -1,5 +1,7 @@ #include +extern bool is_connected; + void parse_config_file(fs::File configFile); void read_and_parse_file();