Skip to content

Commit

Permalink
added wireguard icon on menu
Browse files Browse the repository at this point in the history
  • Loading branch information
pr3y committed May 7, 2024
1 parent bfdd904 commit 6ad0d2c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
Empty file modified clean.sh
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions src/display.cpp
Original file line number Diff line number Diff line change
@@ -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 <driver/adc.h>
Expand Down Expand Up @@ -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();
}


Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void listFiles(int index, String fileList[][3]);

void displayScanning();

void drawWireguardStatus();

void progressHandler(int progress, size_t total);

int getBattery();
Expand Down
9 changes: 6 additions & 3 deletions src/wg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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!");
Expand All @@ -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);
}
2 changes: 2 additions & 0 deletions src/wg.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <SPIFFS.h>

extern bool is_connected;

void parse_config_file(fs::File configFile);

void read_and_parse_file();
Expand Down

0 comments on commit 6ad0d2c

Please sign in to comment.