mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
feat(ui): trail Units setting — km/h, mph, min/km, min/mi
Second row in the Config view: UP/DOWN moves focus between Min dist and Units, LEFT/RIGHT cycles the focused row's value. Units propagates to the Summary view, which now shows either "Avg: N km/h" / "N mph" or "Pace: M:SS /km" / "/mi" depending on the choice. Pace renders as "--:-- /unit" when distance or elapsed time is zero (avoids divide-by-zero glitches with one-point trails). mph conversion uses the 0.621371 ratio with rounding; pace works in floating point off raw metres and seconds for accuracy at low speeds. NodePrefs gains trail_units_idx as another reserved-ish byte; old saves load with 0 = km/h, no schema bump needed since the rd() lambda already defaults missing fields to zero. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,21 @@ public:
|
||||
return L[idx < MIN_DELTA_COUNT ? idx : 0];
|
||||
}
|
||||
|
||||
// Speed / pace display units. UNITS_KMH / UNITS_MPH show speed; UNITS_PACE_KM
|
||||
// / UNITS_PACE_MI show time per distance ("pace"). Index 0 = km/h default.
|
||||
enum Units : uint8_t {
|
||||
UNITS_KMH = 0,
|
||||
UNITS_MPH = 1,
|
||||
UNITS_PACE_KM = 2,
|
||||
UNITS_PACE_MI = 3,
|
||||
};
|
||||
static const uint8_t UNITS_COUNT = 4;
|
||||
static const char* unitLabel(uint8_t idx) {
|
||||
static const char* L[UNITS_COUNT] = { "km/h", "mph", "min/km", "min/mi" };
|
||||
return L[idx < UNITS_COUNT ? idx : 0];
|
||||
}
|
||||
static bool unitIsPace(uint8_t idx) { return idx == UNITS_PACE_KM || idx == UNITS_PACE_MI; }
|
||||
|
||||
bool isActive() const { return _active; }
|
||||
void setActive(bool a) {
|
||||
if (a && !_active) {
|
||||
|
||||
Reference in New Issue
Block a user