From 13f2f02e4205056cd7bfeb4e0f427f6b7d530d5b Mon Sep 17 00:00:00 2001 From: acidburns Date: Sun, 1 Feb 2026 23:38:43 +0100 Subject: [PATCH] Tidy sender page layout and use SF12 --- include/config.h | 2 +- src/display_ui.cpp | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/config.h b/include/config.h index 4f5b724..250e727 100644 --- a/include/config.h +++ b/include/config.h @@ -49,7 +49,7 @@ constexpr uint8_t PIN_METER_RX = 34; #define LORA_FREQUENCY_HZ 433E6 #endif constexpr long LORA_FREQUENCY = LORA_FREQUENCY_HZ; -constexpr uint8_t LORA_SPREADING_FACTOR = 11; +constexpr uint8_t LORA_SPREADING_FACTOR = 12; constexpr long LORA_BANDWIDTH = 125E3; constexpr uint8_t LORA_CODING_RATE = 5; constexpr uint8_t LORA_SYNC_WORD = 0x34; diff --git a/src/display_ui.cpp b/src/display_ui.cpp index ac5a013..1327004 100644 --- a/src/display_ui.cpp +++ b/src/display_ui.cpp @@ -268,16 +268,10 @@ static void render_receiver_status() { display.printf("Time: %s", time_buf); uint32_t latest = 0; - bool link_valid = false; - int16_t link_rssi = 0; - float link_snr = 0.0f; if (g_statuses) { for (uint8_t i = 0; i < g_status_count; ++i) { if (g_statuses[i].has_data && g_statuses[i].last_update_ts_utc > latest) { latest = g_statuses[i].last_update_ts_utc; - link_valid = g_statuses[i].last_data.link_valid; - link_rssi = g_statuses[i].last_data.link_rssi_dbm; - link_snr = g_statuses[i].last_data.link_snr_db; } } } @@ -291,9 +285,6 @@ static void render_receiver_status() { localtime_r(&t, &timeinfo); display.printf("Upd %02d:%02d", timeinfo.tm_hour, timeinfo.tm_min); } - if (link_valid) { - display.printf(" R:%d S:%.1f", link_rssi, link_snr); - } render_last_error_line(56); display.display(); @@ -343,14 +334,27 @@ static void render_receiver_sender(uint8_t index) { display.setCursor(0, 12); display.printf("E %.1f kWh", status.last_data.energy_total_kwh); - display.setCursor(0, 24); - display.printf("P %.0fW", status.last_data.total_power_w); - display.setCursor(0, 36); + display.setCursor(0, 22); display.printf("L1 %.0fW", status.last_data.phase_power_w[0]); - display.setCursor(0, 48); + display.setCursor(0, 32); display.printf("L2 %.0fW", status.last_data.phase_power_w[1]); - display.setCursor(0, 56); + display.setCursor(0, 42); display.printf("L3 %.0fW", status.last_data.phase_power_w[2]); + display.setCursor(0, 52); + display.print("P"); + char p_buf[16]; + snprintf(p_buf, sizeof(p_buf), "%.0fW", status.last_data.total_power_w); + int16_t x1 = 0; + int16_t y1 = 0; + uint16_t w = 0; + uint16_t h = 0; + display.getTextBounds(p_buf, 0, 0, &x1, &y1, &w, &h); + int16_t x = static_cast(display.width() - w); + if (x < 0) { + x = 0; + } + display.setCursor(x, 52); + display.print(p_buf); display.display(); }