Move date and time to first line, add hostname, and move IP addresses down to the blue area

This commit is contained in:
2026-04-03 20:06:43 -03:00
parent d64a3e61b6
commit 0540489f58

View File

@@ -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();