Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 108 additions & 71 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,48 +774,17 @@ void drawSubmenu(int index, std::vector<Option> &options, const char *title) {
}

void drawStatusBar() {
int i = 0;
uint8_t bat = getBattery();
uint8_t bat_margin = 85;
if (bat > 0) {
drawBatteryStatus(bat);
} else bat_margin = 26;
if (sdcardMounted) {
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
tft.setTextSize(FP);
tft.drawString("SD", tftWidth - (bat_margin), 12);
i++;
} // Indication for SD card on screen
if (gpsConnected) {
drawGpsSmall(tftWidth - (bat_margin + 23 * i), 7);
i++;
}
if (WiFi.getMode()) {
drawWifiSmall(tftWidth - (bat_margin + 23 * i), 7);
i++;
} // Draw Wifi Symbol beside battery
if (isWebUIActive) {
drawWebUISmall(tftWidth - (bat_margin + 23 * i), 7);
i++;
} // Draw Wifi Symbol beside battery
if (BLEConnected) {
drawBLESmall(tftWidth - (bat_margin + 23 * i), 7);
i++;
} // Draw BLE beside Wifi
if (isConnectedWireguard) {
drawWireguardStatus(tftWidth - (bat_margin + 24 * i), 7);
i++;
} // Draw Wg bedide BLE, if the others exist, if not, beside battery
if (bat > 0) drawBatteryStatus(bat);

if (bruceConfig.theme.border) {
tft.drawRoundRect(5, 5, tftWidth - 10, tftHeight - 10, 5, bruceConfig.priColor);
tft.drawLine(5, 25, tftWidth - 6, 25, bruceConfig.priColor);
}

if (clock_set) {
int clock_fontsize = 1; // Font size of the clock / BRUCE + BRUCE_VERSION
setTftDisplay(12, 12, bruceConfig.priColor, clock_fontsize, bruceConfig.bgColor);
tft.fillRect(12, 12, 100, clock_fontsize * LH, bruceConfig.bgColor);
setTftDisplay(12, 12, bruceConfig.priColor, 1, bruceConfig.bgColor);
tft.fillRect(12, 12, 60, LH, bruceConfig.bgColor);
#if defined(HAS_RTC)
updateTimeStr(_rtc.getTimeStruct());
#else
Expand All @@ -826,6 +795,67 @@ void drawStatusBar() {
setTftDisplay(12, 12, bruceConfig.priColor, 1, bruceConfig.bgColor);
tft.print("BRUCE " + String(BRUCE_VERSION));
}

int iconCount = 0;
bool showSD = sdcardMounted;
bool showGPS = gpsConnected;
bool showWifi = (WiFi.getMode() != 0);
bool showWeb = isWebUIActive;
bool showBLE = BLEConnected;
bool showWG = isConnectedWireguard;
if (showSD) iconCount++;
if (showGPS) iconCount++;
if (showWifi) iconCount++;
if (showWeb) iconCount++;
if (showBLE) iconCount++;
if (showWG) iconCount++;

if (iconCount > 0) {
const int IW = 16;
const int IH = 16;
const int GAP = 6;
int totalW = iconCount * IW + (iconCount - 1) * GAP;
int sx = (tftWidth - totalW) / 2;
int iy = 7;
int idx = 0;

if (showSD) {
int x = sx + idx * (IW + GAP);
tft.fillRect(x, iy, IW, IH, bruceConfig.bgColor);
drawSdSmall(x, iy);
idx++;
}
if (showGPS) {
int x = sx + idx * (IW + GAP);
tft.fillRect(x, iy, IW, IH, bruceConfig.bgColor);
drawGpsSmall(x, iy);
idx++;
}
if (showWifi) {
int x = sx + idx * (IW + GAP);
tft.fillRect(x, iy, IW, IH, bruceConfig.bgColor);
drawWifiSmall(x, iy);
idx++;
}
if (showWeb) {
int x = sx + idx * (IW + GAP);
tft.fillRect(x, iy, IW, IH, bruceConfig.bgColor);
drawWebUISmall(x, iy);
idx++;
}
if (showBLE) {
int x = sx + idx * (IW + GAP);
tft.fillRect(x, iy, IW, IH, bruceConfig.bgColor);
drawBLESmall(x, iy);
idx++;
}
if (showWG) {
int x = sx + idx * (IW + GAP);
tft.fillRect(x, iy, IW, IH, bruceConfig.bgColor);
drawWireguardStatus(x, iy);
idx++;
}
}
}

void drawMainBorder(bool clear) {
Expand Down Expand Up @@ -889,10 +919,6 @@ void printCenterFootnote(String text) {
tft.drawCentreString(text, tftWidth / 2, tftHeight - BORDER_PAD_X - FP * LH, SMOOTH_FONT);
}

/***************************************************************************************
** Function name: drawBatteryStatus()
** Description: Draws battery info into the Status bar
***************************************************************************************/
void drawBatteryStatus(uint8_t bat) {
if (bat == 0) return;

Expand All @@ -901,31 +927,30 @@ void drawBatteryStatus(uint8_t bat) {
uint16_t color = bruceConfig.priColor;
uint16_t barcolor = bruceConfig.priColor;
if (bat < 16) barcolor = color = TFT_RED;
else if (bat < 34) barcolor = color = TFT_YELLOW;
if (charging) color = TFT_GREEN;

tft.drawRoundRect(tftWidth - 43, 6, 36, 19, 2, charging ? color : bruceConfig.bgColor); // (bolder border)
tft.drawRoundRect(tftWidth - 42, 7, 34, 17, 2, color);
tft.setTextSize(FP);
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
tft.drawRightString((bat == 100 ? "" : " ") + String(bat) + "%", tftWidth - 45, 12, 1);
tft.fillRect(tftWidth - 85, 7, 42, 18, bruceConfig.bgColor);
if (charging) {
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
tft.drawRightString("CHG", tftWidth - 44, 12, 1);
} else {
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
tft.drawRightString((bat == 100 ? "" : " ") + String(bat) + "%", tftWidth - 44, 12, 1);
}
tft.fillRoundRect(tftWidth - 40, 9, 30 * bat / 100, 13, 2, barcolor);
tft.drawLine(tftWidth - 30, 9, tftWidth - 30, 9 + 13, bruceConfig.bgColor);
tft.drawLine(tftWidth - 20, 9, tftWidth - 20, 9 + 13, bruceConfig.bgColor);
}
/***************************************************************************************
** Function name: drawWireguardStatus()
** Description: Draws a padlock when connected
***************************************************************************************/

void drawWireguardStatus(int x, int y) {
tft.fillRect(x, y, 20, 17, bruceConfig.bgColor);
tft.fillRect(x, y, 16, 16, bruceConfig.bgColor);
if (isConnectedWireguard) {
tft.drawRoundRect(11 + x, 0 + y, 8, 12, 5, TFT_GREEN);
tft.fillRoundRect(10 + x, 8 + y, 10, 8, 0, TFT_GREEN);
tft.drawRoundRect(x + 4, y + 2, 8, 8, 3, bruceConfig.priColor);
tft.fillRoundRect(x + 3, y + 7, 10, 7, 1, bruceConfig.priColor);
} else {
tft.drawRoundRect(1 + x, 0 + y, 8, 12, 5, bruceConfig.priColor);
tft.fillRoundRect(0 + x, 8 + y, 10, 8, 0, bruceConfig.bgColor);
tft.fillRoundRect(6 + x, 8 + y, 10, 10, 0, bruceConfig.priColor);
tft.drawRoundRect(x + 4, y + 2, 8, 8, 3, bruceConfig.priColor);
tft.drawRoundRect(x + 3, y + 7, 10, 7, 1, bruceConfig.priColor);
}
}

Expand Down Expand Up @@ -980,29 +1005,41 @@ Opt_Coord listFiles(int index, std::vector<FileList> fileList) {

// desenhos do menu principal, sprite "draw" com 80x80 pixels

void drawSdSmall(int x, int y) {
tft.fillRect(x, y, 16, 16, bruceConfig.bgColor);
tft.drawLine(x + 3, y + 2, x + 3, y + 14, bruceConfig.priColor);
tft.drawLine(x + 3, y + 14, x + 13, y + 14, bruceConfig.priColor);
tft.drawLine(x + 13, y + 14, x + 13, y + 5, bruceConfig.priColor);
tft.drawLine(x + 13, y + 5, x + 10, y + 2, bruceConfig.priColor);
tft.drawLine(x + 10, y + 2, x + 3, y + 2, bruceConfig.priColor);

tft.drawLine(x + 5, y + 4, x + 5, y + 6, bruceConfig.priColor);
tft.drawLine(x + 7, y + 4, x + 7, y + 6, bruceConfig.priColor);
tft.drawLine(x + 9, y + 4, x + 9, y + 6, bruceConfig.priColor);
tft.drawLine(x + 11, y + 5, x + 11, y + 6, bruceConfig.priColor);
}

void drawWifiSmall(int x, int y) {
tft.fillRect(x, y, 16, 16, bruceConfig.bgColor);
tft.fillCircle(9 + x, 14 + y, 1, bruceConfig.priColor);
tft.drawArc(9 + x, 14 + y, 4, 6, 130, 230, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawArc(9 + x, 14 + y, 10, 12, 130, 230, bruceConfig.priColor, bruceConfig.bgColor);
tft.fillCircle(x + 8, y + 13, 1, bruceConfig.priColor);
tft.drawArc(x + 8, y + 13, 4, 6, 135, 225, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawArc(x + 8, y + 13, 9, 11, 135, 225, bruceConfig.priColor, bruceConfig.bgColor);
}

void drawWebUISmall(int x, int y) {
tft.fillRect(x, y, 16, 16, bruceConfig.bgColor);

tft.drawCircle(8 + x, 8 + y, 7, bruceConfig.priColor);

tft.drawLine(3 + x, 4 + y, 14 + x, 4 + y, bruceConfig.priColor);
tft.drawLine(2 + x, 8 + y, 15 + x, 8 + y, bruceConfig.priColor);
tft.drawLine(3 + x, 12 + y, 14 + x, 12 + y, bruceConfig.priColor);
tft.drawCircle(x + 8, y + 8, 6, bruceConfig.priColor);
tft.drawLine(x + 3, y + 4, x + 13, y + 4, bruceConfig.priColor);
tft.drawLine(x + 2, y + 8, x + 14, y + 8, bruceConfig.priColor);
tft.drawLine(x + 3, y + 12, x + 13, y + 12, bruceConfig.priColor);
}

void drawBLESmall(int x, int y) {
tft.fillRect(x, 2 + y, 17, 13, bruceConfig.bgColor);
tft.drawWideLine(8 + x, 8 + y, 4 + x, 5 + y, 2, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawWideLine(8 + x, 8 + y, 4 + x, 13 + y, 2, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawTriangle(8 + x, 8 + y, 8 + x, 2 + y, 13 + x, 5 + y, bruceConfig.priColor);
tft.drawTriangle(8 + x, 8 + y, 8 + x, 14 + y, 13 + x, 11 + y, bruceConfig.priColor);
tft.fillRect(x, y, 16, 16, bruceConfig.bgColor);
tft.drawWideLine(x + 8, y + 8, x + 4, y + 4, 2, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawWideLine(x + 8, y + 8, x + 4, y + 12, 2, bruceConfig.priColor, bruceConfig.bgColor);
tft.drawTriangle(x + 8, y + 8, x + 8, y + 2, x + 12, y + 5, bruceConfig.priColor);
tft.drawTriangle(x + 8, y + 8, x + 8, y + 14, x + 12, y + 11, bruceConfig.priColor);
}

void drawBLE_beacon(int x, int y, uint16_t color) {
Expand All @@ -1024,10 +1061,10 @@ void drawGPS(int x, int y) {
}

void drawGpsSmall(int x, int y) {
tft.fillRect(x, y, 17, 17, bruceConfig.bgColor);
tft.drawEllipse(9 + x, 14 + y, 4, 3, bruceConfig.priColor);
tft.drawArc(9 + x, 6 + y, 5, 2, 0, 340, bruceConfig.priColor, bruceConfig.bgColor);
tft.fillTriangle(9 + x, 15 + y, 5 + x, 9 + y, 13 + x, 9 + y, bruceConfig.priColor);
tft.fillRect(x, y, 16, 16, bruceConfig.bgColor);
tft.drawEllipse(x + 8, y + 13, 4, 3, bruceConfig.priColor);
tft.drawArc(x + 8, y + 5, 5, 2, 0, 360, bruceConfig.priColor, bruceConfig.bgColor);
tft.fillTriangle(x + 8, y + 14, x + 4, y + 8, x + 12, y + 8, bruceConfig.priColor);
}

void drawCreditCard(int x, int y) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ void drawGPS(int x, int y);

void drawGpsSmall(int x, int y);

void drawSdSmall(int x, int y);

void drawCreditCard(int x, int y);

void drawMfkey32Icon(int x, int y);
Expand Down
27 changes: 13 additions & 14 deletions src/core/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,28 @@ MainMenu::MainMenu() {
_menuItems = {
&wifiMenu,
&bleMenu,
&rfMenu,
&nrf24Menu,
#if !defined(LITE_VERSION)
&ethernetMenu,
&loraMenu,
#endif
&rfMenu,
&rfidMenu,
&irMenu,
#if defined(FM_SI4713) && !defined(LITE_VERSION)
&fmMenu,
#endif
&fileMenu,
&gpsMenu,
&nrf24Menu,
&irMenu,
#if !defined(LITE_VERSION)
#if !defined(DISABLE_INTERPRETER)
&scriptsMenu,
&appsMenu,
&ethernetMenu,
#endif
&loraMenu,
&gpsMenu,
&rfidMenu,
&fileMenu,
#if !defined(LITE_VERSION) && !defined(DISABLE_INTERPRETER)
&scriptsMenu,
#endif
&othersMenu,
&clockMenu,
#if !defined(LITE_VERSION)
&connectMenu,
&othersMenu,
#if !defined(LITE_VERSION) && !defined(DISABLE_INTERPRETER)
&appsMenu,
#endif
&configMenu,
};
Expand Down
37 changes: 25 additions & 12 deletions src/core/menu_items/AppsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,29 @@ void AppsMenu::optionsMenu() {
void AppsMenu::drawIcon(float scale) {
clearIconArea();

int size = scale * 14;
int gap = scale * 4;
int totalW = size * 2 + gap;

int startX = iconCenterX - totalW / 2;
int startY = iconCenterY - totalW / 2;

// Draw a 2x2 grid of rounded squares (app grid icon)
tft.drawRoundRect(startX, startY, size, size, 2, bruceConfig.priColor);
tft.drawRoundRect(startX + size + gap, startY, size, size, 2, bruceConfig.priColor);
tft.drawRoundRect(startX, startY + size + gap, size, size, 2, bruceConfig.priColor);
tft.drawRoundRect(startX + size + gap, startY + size + gap, size, size, 2, bruceConfig.priColor);
int iconW = scale * 60;
int iconH = scale * 60;
if (iconW % 2 != 0) iconW++;
if (iconH % 2 != 0) iconH++;

int cx = iconCenterX;
int cy = iconCenterY;
int half = iconW / 2;

tft.drawRoundRect(cx - half, cy - half, iconW, iconH, half / 4, bruceConfig.priColor);
tft.drawLine(cx - half, cy - half + iconH / 4, cx + half, cy - half + iconH / 4, bruceConfig.priColor);

int gridW = iconW / 5;
int gridGap = iconW / 8;

int gridCenterY = cy + iconH / 8;
int gx1 = cx - gridW - gridGap / 2;
int gy1 = gridCenterY - gridW - gridGap / 2;
int gx2 = cx + gridGap / 2;
int gy2 = gridCenterY + gridGap / 2;

tft.fillRect(gx1, gy1, gridW, gridW, bruceConfig.priColor);
tft.drawRect(gx2, gy1, gridW, gridW, bruceConfig.priColor);
tft.drawRect(gx1, gy2, gridW, gridW, bruceConfig.priColor);
tft.fillRect(gx2, gy2, gridW, gridW, bruceConfig.priColor);
}
5 changes: 0 additions & 5 deletions src/core/menu_items/ConfigMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ void ConfigMenu::optionsMenu() {
{"System Config", [this]() { systemMenu(); } },
{"Power", [this]() { powerMenu(); } },
};
#if !defined(LITE_VERSION)
if (!appStoreInstalled()) {
localOptions.push_back({"Install App Store", []() { installAppStoreJS(); }});
}
#endif

if (bruceConfig.devMode) {
localOptions.push_back({"Dev Mode", [this]() { devMenu(); }});
Expand Down
Loading