Use Shared Scale For Internet Gauges

This commit is contained in:
2026-11-13 12:31:31 +01:00
parent 6105b869c2
commit e4b51b6c07
+7 -7
View File
@@ -1043,12 +1043,13 @@ display:
if (id(internet_view) == 0) { if (id(internet_view) == 0) {
draw_page_title("Internet"); draw_page_title("Internet");
const int cx = 160, cy = 188; const int cx = 160, cy = 188;
const float download_maximum = gauge_maximum(download_valid ? download : 0.0f, 0.001f); // A shared scale makes the two ring lengths directly comparable.
const float upload_maximum = gauge_maximum(upload_valid ? upload : 0.0f, 0.001f); const float maximum = gauge_maximum(fmaxf(download_valid ? download : 0.0f,
upload_valid ? upload : 0.0f), 0.001f);
const float download_fraction = download_valid const float download_fraction = download_valid
? fminf(download / download_maximum, 1.0f) : 0.0f; ? fminf(download / maximum, 1.0f) : 0.0f;
const float upload_fraction = upload_valid const float upload_fraction = upload_valid
? fminf(upload / upload_maximum, 1.0f) : 0.0f; ? fminf(upload / maximum, 1.0f) : 0.0f;
// Match the energy gauge: download outside, upload inside. // Match the energy gauge: download outside, upload inside.
it.filled_gauge(cx, cy, 140, 122, 100, muted); it.filled_gauge(cx, cy, 140, 122, 100, muted);
it.filled_gauge(cx, cy, 140, 122, static_cast<int>(download_fraction * 100), download_color); it.filled_gauge(cx, cy, 140, 122, static_cast<int>(download_fraction * 100), download_color);
@@ -1061,9 +1062,8 @@ display:
it.printf(cx, 169, id(font_internet_value), upload_color, TextAlign::TOP_CENTER, it.printf(cx, 169, id(font_internet_value), upload_color, TextAlign::TOP_CENTER,
"%s", upload_valid ? format_rate(upload).c_str() : "--"); "%s", upload_valid ? format_rate(upload).c_str() : "--");
it.printf(cx, 204, id(font_device), Color::WHITE, TextAlign::TOP_CENTER, it.printf(cx, 204, id(font_device), Color::WHITE, TextAlign::TOP_CENTER,
"Max: DL %s / UL %s", "Gemeinsame Skala: %s",
download_valid ? format_rate(download_maximum).c_str() : "--", download_valid || upload_valid ? format_rate(maximum).c_str() : "--");
upload_valid ? format_rate(upload_maximum).c_str() : "--");
} else if (id(internet_view) == 1) { } else if (id(internet_view) == 1) {
draw_page_title("Internet · 1 h"); draw_page_title("Internet · 1 h");
const int left = 28, right = 308, top = 62, zero = 122, bottom = 182; const int left = 28, right = 308, top = 62, zero = 122, bottom = 182;