From 0540489f5874d0b2f4f036d7c55627c6ef781190 Mon Sep 17 00:00:00 2001 From: Gabriel Lima Date: Fri, 3 Apr 2026 20:06:43 -0300 Subject: [PATCH] Move date and time to first line, add hostname, and move IP addresses down to the blue area --- main.cpp | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/main.cpp b/main.cpp index 8c4c1e9..bf648e8 100644 --- a/main.cpp +++ b/main.cpp @@ -93,32 +93,36 @@ int main(int argc, char* argv[]) { while (g_running) { display.fillScreen(gfx::colors::black); - // --- Network info --- - std::string eth_ip = get_ip(ETH_IFACE); - std::string wlan_ip = get_ip(WLAN_IFACE); - - std::snprintf(line_buf, sizeof(line_buf), "ETH: %s", eth_ip.c_str()); - display.setCursor(0, 0); - display.print(line_buf); - - std::snprintf(line_buf, sizeof(line_buf), "WLAN: %s", wlan_ip.c_str()); - display.setCursor(0, 8); - display.print(line_buf); - - // --- Separator --- - display.drawHLine(0, 17, SCREEN_W, gfx::colors::white); - // --- Date and time --- std::time_t now = std::time(nullptr); std::tm* tm = std::localtime(&now); - std::snprintf(line_buf, sizeof(line_buf), "%04d-%02d-%02d", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); - draw_centered(display, 29, line_buf); - - std::snprintf(line_buf, sizeof(line_buf), "%02d:%02d:%02d", + std::snprintf(line_buf, sizeof(line_buf), "%04d-%02d-%02d %02d:%02d:%02d", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); - draw_centered(display, 41, line_buf); + //draw_centered(display, 0, line_buf); + display.setCursor(0, 0); + display.print(line_buf); + + // --- Separator --- + // display.drawHLine(0, 16, SCREEN_W, gfx::colors::white); + + // --- Hostname --- + gethostname(line_buf, sizeof(line_buf) - 1); + display.setCursor(0, 8); + display.print(line_buf); + + // --- Network info --- + std::string eth_ip = get_ip(ETH_IFACE); + std::string wlan_ip = get_ip(WLAN_IFACE); + + std::snprintf(line_buf, sizeof(line_buf), "eth0: %s", eth_ip.c_str()); + display.setCursor(0, 16); + display.print(line_buf); + + std::snprintf(line_buf, sizeof(line_buf), "wlan0: %s", wlan_ip.c_str()); + display.setCursor(0, 24); + display.print(line_buf); display.update();