Tidy sender page layout and use SF12
This commit is contained in:
@@ -49,7 +49,7 @@ constexpr uint8_t PIN_METER_RX = 34;
|
|||||||
#define LORA_FREQUENCY_HZ 433E6
|
#define LORA_FREQUENCY_HZ 433E6
|
||||||
#endif
|
#endif
|
||||||
constexpr long LORA_FREQUENCY = LORA_FREQUENCY_HZ;
|
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 long LORA_BANDWIDTH = 125E3;
|
||||||
constexpr uint8_t LORA_CODING_RATE = 5;
|
constexpr uint8_t LORA_CODING_RATE = 5;
|
||||||
constexpr uint8_t LORA_SYNC_WORD = 0x34;
|
constexpr uint8_t LORA_SYNC_WORD = 0x34;
|
||||||
|
|||||||
@@ -268,16 +268,10 @@ static void render_receiver_status() {
|
|||||||
display.printf("Time: %s", time_buf);
|
display.printf("Time: %s", time_buf);
|
||||||
|
|
||||||
uint32_t latest = 0;
|
uint32_t latest = 0;
|
||||||
bool link_valid = false;
|
|
||||||
int16_t link_rssi = 0;
|
|
||||||
float link_snr = 0.0f;
|
|
||||||
if (g_statuses) {
|
if (g_statuses) {
|
||||||
for (uint8_t i = 0; i < g_status_count; ++i) {
|
for (uint8_t i = 0; i < g_status_count; ++i) {
|
||||||
if (g_statuses[i].has_data && g_statuses[i].last_update_ts_utc > latest) {
|
if (g_statuses[i].has_data && g_statuses[i].last_update_ts_utc > latest) {
|
||||||
latest = g_statuses[i].last_update_ts_utc;
|
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);
|
localtime_r(&t, &timeinfo);
|
||||||
display.printf("Upd %02d:%02d", timeinfo.tm_hour, timeinfo.tm_min);
|
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);
|
render_last_error_line(56);
|
||||||
display.display();
|
display.display();
|
||||||
@@ -343,14 +334,27 @@ static void render_receiver_sender(uint8_t index) {
|
|||||||
|
|
||||||
display.setCursor(0, 12);
|
display.setCursor(0, 12);
|
||||||
display.printf("E %.1f kWh", status.last_data.energy_total_kwh);
|
display.printf("E %.1f kWh", status.last_data.energy_total_kwh);
|
||||||
display.setCursor(0, 24);
|
display.setCursor(0, 22);
|
||||||
display.printf("P %.0fW", status.last_data.total_power_w);
|
|
||||||
display.setCursor(0, 36);
|
|
||||||
display.printf("L1 %.0fW", status.last_data.phase_power_w[0]);
|
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.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.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<int16_t>(display.width() - w);
|
||||||
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
display.setCursor(x, 52);
|
||||||
|
display.print(p_buf);
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user