Respect Metric/Imperial unit setting in radar range button, ring labels, aircraft list, nearest airport, and stats
Five places ignored the Units setting (Menu > Units) and always showed fixed metric values even when Imperial was selected: the radar range button (now km/nm), the radar's ring distance labels (now km/nm), the aircraft list's altitude/distance columns (now m+km or ft+nm), the Location Presets screen's nearest-airport distance (now km/nm), and the Stats screen's highest-altitude-today line (now m or ft). The range button had already been touched previously but used "mi" instead of "nm" - aligned to nm here for consistency with the other distance displays, which all pair with km rather than miles. The radar detail panel's simultaneous multi-unit display and the climb/descent rate (always ft/min, aviation convention) are intentionally left unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
#include "menu_stars.h"
|
#include "menu_stars.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
#include "units.h"
|
||||||
|
#include "location_manager.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@@ -124,6 +126,11 @@ bool run(TFT_eSPI& tft) {
|
|||||||
Rect rowRects[ROWS_VISIBLE];
|
Rect rowRects[ROWS_VISIBLE];
|
||||||
uint8_t visibleRowCount = 0;
|
uint8_t visibleRowCount = 0;
|
||||||
|
|
||||||
|
// Einheiten-Einstellung (Menue > Einheiten) einmal vor der Schleife
|
||||||
|
// lesen statt pro Zeile - vorher zeigten Hoehe/Distanz hier immer
|
||||||
|
// fest ft/km, auch bei Imperial eingestellt.
|
||||||
|
bool listMetric = LocationManager::useMetricUnits();
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK);
|
tft.setTextColor(TFT_DARKGREY, TFT_BLACK);
|
||||||
tft.setCursor(10, LIST_TOP + 14);
|
tft.setCursor(10, LIST_TOP + 14);
|
||||||
@@ -154,12 +161,20 @@ bool run(TFT_eSPI& tft) {
|
|||||||
tft.drawString(label, r.x + 6, midY);
|
tft.drawString(label, r.x + 6, midY);
|
||||||
|
|
||||||
char buf[24];
|
char buf[24];
|
||||||
|
if (listMetric) {
|
||||||
|
snprintf(buf, sizeof(buf), "%.0fm", Units::feetToMeters((float)a.altBaroFt));
|
||||||
|
} else {
|
||||||
snprintf(buf, sizeof(buf), "%.0fft", (float)a.altBaroFt);
|
snprintf(buf, sizeof(buf), "%.0fft", (float)a.altBaroFt);
|
||||||
|
}
|
||||||
tft.setTextColor(colorForAltitude(a.altBaroFt), TFT_BLACK);
|
tft.setTextColor(colorForAltitude(a.altBaroFt), TFT_BLACK);
|
||||||
tft.setTextDatum(MR_DATUM);
|
tft.setTextDatum(MR_DATUM);
|
||||||
tft.drawString(buf, r.x + r.w - 62, midY);
|
tft.drawString(buf, r.x + r.w - 62, midY);
|
||||||
|
|
||||||
|
if (listMetric) {
|
||||||
snprintf(buf, sizeof(buf), "%.0fkm", a.distanceKm);
|
snprintf(buf, sizeof(buf), "%.0fkm", a.distanceKm);
|
||||||
|
} else {
|
||||||
|
snprintf(buf, sizeof(buf), "%.0fnm", Units::kmToNm(a.distanceKm));
|
||||||
|
}
|
||||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||||
tft.setTextDatum(MR_DATUM);
|
tft.setTextDatum(MR_DATUM);
|
||||||
tft.drawString(buf, r.x + r.w - 6, midY);
|
tft.drawString(buf, r.x + r.w - 6, midY);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "menu_stars.h"
|
#include "menu_stars.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
namespace LocationPresetsScreen {
|
namespace LocationPresetsScreen {
|
||||||
|
|
||||||
@@ -602,8 +603,14 @@ void run(TFT_eSPI& tft) {
|
|||||||
}
|
}
|
||||||
nearest = AirportLookup::findNearest(activeLat, activeLon);
|
nearest = AirportLookup::findNearest(activeLat, activeLon);
|
||||||
if (nearest.found) {
|
if (nearest.found) {
|
||||||
|
// Respektiert jetzt die Einheiten-Einstellung (Menue >
|
||||||
|
// Einheiten) - vorher immer "(XX km)", auch bei Imperial.
|
||||||
char buf[48];
|
char buf[48];
|
||||||
|
if (LocationManager::useMetricUnits()) {
|
||||||
snprintf(buf, sizeof(buf), "%s %s (%.0f km)", nearest.icao, nearest.name, nearest.distanceKm);
|
snprintf(buf, sizeof(buf), "%s %s (%.0f km)", nearest.icao, nearest.name, nearest.distanceKm);
|
||||||
|
} else {
|
||||||
|
snprintf(buf, sizeof(buf), "%s %s (%.0f nm)", nearest.icao, nearest.name, Units::kmToNm(nearest.distanceKm));
|
||||||
|
}
|
||||||
String line = String(I18n::t(StringId::LOCATION_NEAREST_AIRPORT_PREFIX)) + buf;
|
String line = String(I18n::t(StringId::LOCATION_NEAREST_AIRPORT_PREFIX)) + buf;
|
||||||
setupMarquee(tft, line, AIRPORT_LINE_W);
|
setupMarquee(tft, line, AIRPORT_LINE_W);
|
||||||
drawMarquee(tft, AIRPORT_LINE_X, airportLineY, AIRPORT_LINE_W, 20);
|
drawMarquee(tft, AIRPORT_LINE_X, airportLineY, AIRPORT_LINE_W, 20);
|
||||||
|
|||||||
@@ -471,10 +471,16 @@ namespace {
|
|||||||
gfx.drawString("S", L.cx, L.cy + L.radius - 10);
|
gfx.drawString("S", L.cx, L.cy + L.radius - 10);
|
||||||
gfx.drawString("E", L.cx + L.radius - 10, L.cy);
|
gfx.drawString("E", L.cx + L.radius - 10, L.cy);
|
||||||
gfx.drawString("W", L.cx - L.radius + 10, L.cy);
|
gfx.drawString("W", L.cx - L.radius + 10, L.cy);
|
||||||
|
// Ring-Beschriftungen (Zwischenabstaende) respektieren jetzt die
|
||||||
|
// Einheiten-Einstellung (Menue > Einheiten) - vorher immer in km,
|
||||||
|
// auch wenn Imperial (nm) eingestellt war. Gleiches Umrechnungs-
|
||||||
|
// Muster wie beim Range-Button unten und der Legende oben.
|
||||||
|
bool metric = LocationManager::useMetricUnits();
|
||||||
|
float displayRange = metric ? rangeKm : Units::kmToNm(rangeKm);
|
||||||
char ringLabel[8];
|
char ringLabel[8];
|
||||||
snprintf(ringLabel, sizeof(ringLabel), "%.0f", rangeKm / 3);
|
snprintf(ringLabel, sizeof(ringLabel), "%.0f", displayRange / 3);
|
||||||
gfx.drawString(ringLabel, L.cx, L.cy - L.radius / 3);
|
gfx.drawString(ringLabel, L.cx, L.cy - L.radius / 3);
|
||||||
snprintf(ringLabel, sizeof(ringLabel), "%.0f", rangeKm * 2 / 3);
|
snprintf(ringLabel, sizeof(ringLabel), "%.0f", displayRange * 2 / 3);
|
||||||
gfx.drawString(ringLabel, L.cx, L.cy - L.radius * 2 / 3);
|
gfx.drawString(ringLabel, L.cx, L.cy - L.radius * 2 / 3);
|
||||||
gfx.setTextDatum(TL_DATUM);
|
gfx.setTextDatum(TL_DATUM);
|
||||||
}
|
}
|
||||||
@@ -779,14 +785,14 @@ void render(TFT_eSPI& tft, int16_t top) {
|
|||||||
int16_t infoTextW = L.rangeBtn.x - INFO_TEXT_X - INFO_TEXT_GAP;
|
int16_t infoTextW = L.rangeBtn.x - INFO_TEXT_X - INFO_TEXT_GAP;
|
||||||
drawInfoMarquee(tft, INFO_TEXT_X, infoTextY, infoTextW);
|
drawInfoMarquee(tft, INFO_TEXT_X, infoTextY, infoTextW);
|
||||||
|
|
||||||
|
// Respektiert jetzt die Einheiten-Einstellung (Menue > Einheiten) -
|
||||||
|
// vorher immer "XXkm", auch bei Imperial (dort jetzt "XXnm").
|
||||||
char rangeLabel[8];
|
char rangeLabel[8];
|
||||||
// Zeigt km bei Metrisch, mi bei Imperial (Menue > Einheiten) -
|
bool rangeMetric = LocationManager::useMetricUnits();
|
||||||
// gleiches Muster wie drawLegend() weiter oben, statt fest immer
|
if (rangeMetric) {
|
||||||
// km anzuzeigen.
|
|
||||||
if (LocationManager::useMetricUnits()) {
|
|
||||||
snprintf(rangeLabel, sizeof(rangeLabel), "%.0fkm", rangeKm);
|
snprintf(rangeLabel, sizeof(rangeLabel), "%.0fkm", rangeKm);
|
||||||
} else {
|
} else {
|
||||||
snprintf(rangeLabel, sizeof(rangeLabel), "%.0fmi", Units::kmToMi(rangeKm));
|
snprintf(rangeLabel, sizeof(rangeLabel), "%.0fnm", Units::kmToNm(rangeKm));
|
||||||
}
|
}
|
||||||
drawButton(tft, L.rangeBtn, rangeLabel);
|
drawButton(tft, L.rangeBtn, rangeLabel);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "menu_stars.h"
|
#include "menu_stars.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
#include "units.h"
|
||||||
|
#include "location_manager.h"
|
||||||
|
|
||||||
namespace StatsScreen {
|
namespace StatsScreen {
|
||||||
|
|
||||||
@@ -98,8 +100,14 @@ void run(TFT_eSPI& tft) {
|
|||||||
|
|
||||||
if (topAlt.found) {
|
if (topAlt.found) {
|
||||||
String csign = topAlt.callsign[0] ? String(topAlt.callsign) : "?";
|
String csign = topAlt.callsign[0] ? String(topAlt.callsign) : "?";
|
||||||
|
// Respektiert jetzt die Einheiten-Einstellung (Menue > Einheiten)
|
||||||
|
// - vorher immer "(XXXX ft)", auch bei Metrisch eingestellt.
|
||||||
char altBuf[24];
|
char altBuf[24];
|
||||||
|
if (LocationManager::useMetricUnits()) {
|
||||||
|
snprintf(altBuf, sizeof(altBuf), "%s (%ldm)", csign.c_str(), (long)Units::feetToMeters((float)topAlt.altitudeFt));
|
||||||
|
} else {
|
||||||
snprintf(altBuf, sizeof(altBuf), "%s (%ld ft)", csign.c_str(), (long)topAlt.altitudeFt);
|
snprintf(altBuf, sizeof(altBuf), "%s (%ld ft)", csign.c_str(), (long)topAlt.altitudeFt);
|
||||||
|
}
|
||||||
drawStatRow(tft, TOP_ALT_Y, I18n::t(StringId::STATS_TOP_ALTITUDE_PREFIX), String(altBuf));
|
drawStatRow(tft, TOP_ALT_Y, I18n::t(StringId::STATS_TOP_ALTITUDE_PREFIX), String(altBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user