What problem are you trying to solve?
The current sector timing API (getBestSector1/2/3Time, getCurrentLapSector1/2/3Time)
tells you what the times WERE. What it doesn't tell you is:
- "Was that sector better or worse than my best?" (signed delta, seconds)
- "Was that sector better or worse than my optimal?" (independently best sectors)
- "Based on my sector splits so far this lap, am I ahead or behind my best lap?"
These three questions are what racing engineers look at lap-by-lap. Without them,
the user has to compute (currentLapSector1Time - bestSector1Time) / 1000 in their
sketch and track it separately. This math belongs in the library.
Note: this is complementary to Issue #29 (GPS delta) — sector deltas update at
each line crossing, GPS delta updates every fix. Both are useful simultaneously:
sector delta = authoritative split result; GPS delta = live in-corner feedback.
Proposed solution
Extend sector timing with per-sector delta fields and a lap-level running delta.
NEW SECTOR FIELDS (extend current sector timing storage):
// For each completed sector, after crossing:
float deltaBest; // (sectorTime - bestSectorTime) / 1000.0f — signed seconds
float deltaOptimal; // (sectorTime - optimalSectorTime) / 1000.0f — signed seconds
unsigned long optimal; // rolling best individual sector time across ALL laps
// (updates independently of whether the lap is a best lap)
The distinction between "best" and "optimal" matters:
- bestSectorN = sector N time from the best COMPLETE LAP
- optimal = best sector N time ever, regardless of what the rest of that lap was
These can differ significantly in karting where one great sector often coincides
with a poor sector elsewhere.
NEW LAP-LEVEL ACCUMULATOR:
float microsectorLapDelta; // running sum: Σ deltaBest for sectors completed
// this lap; gives "where am I vs best lap?"
// before the lap ends
float previousLapDelta; // microsectorLapDelta preserved at lap completion
// for display (so it doesn't reset to 0 on crossing)
DELTA CALCULATION (at each sector crossing):
long deltaMs = (long)currentSectorTime - (long)bestSectorTime;
deltaBest = deltaMs / 1000.0f;
long deltaMsOpt = (long)currentSectorTime - (long)optimalSectorTime;
deltaOptimal = deltaMsOpt / 1000.0f;
// Rolling optimal: update regardless of lap result
if (optimalSectorTime == 0 || currentSectorTime < optimalSectorTime) {
optimalSectorTime = currentSectorTime;
}
// Accumulate lap progress delta
microsectorLapDelta += deltaBest;
// On finish line crossing: preserve and reset
previousLapDelta = microsectorLapDelta;
microsectorLapDelta = 0.0f;
PROPOSED PUBLIC API:
float getSectorDeltaBest(int sectorNumber) const; // signed seconds vs best
float getSectorDeltaOptimal(int sectorNumber) const; // signed seconds vs optimal
unsigned long getOptimalSectorTime(int sectorNumber) const; // rolling optimal ms
float getLapProgressDelta() const; // microsectorLapDelta (running this lap)
float getPreviousLapDelta() const; // delta at end of last lap
Alternatives considered
-
User computes (getBestSector1Time() - getCurrentLapSector1Time()) themselves —
current workaround. Two calls, user math, no optimal tracking. Every karting
display project reinvents this.
-
getOptimalLapTime() (already exists) — sums best sectors after the fact but
doesn't give per-sector signed deltas or the live accumulated lap delta.
-
Include only deltaBest, not deltaOptimal — simpler, but misses the "theoretical
best lap" concept that is standard in professional timing systems.
What problem are you trying to solve?
The current sector timing API (getBestSector1/2/3Time, getCurrentLapSector1/2/3Time)
tells you what the times WERE. What it doesn't tell you is:
These three questions are what racing engineers look at lap-by-lap. Without them,
the user has to compute (currentLapSector1Time - bestSector1Time) / 1000 in their
sketch and track it separately. This math belongs in the library.
Note: this is complementary to Issue #29 (GPS delta) — sector deltas update at
each line crossing, GPS delta updates every fix. Both are useful simultaneously:
sector delta = authoritative split result; GPS delta = live in-corner feedback.
Proposed solution
Extend sector timing with per-sector delta fields and a lap-level running delta.
NEW SECTOR FIELDS (extend current sector timing storage):
The distinction between "best" and "optimal" matters:
These can differ significantly in karting where one great sector often coincides
with a poor sector elsewhere.
NEW LAP-LEVEL ACCUMULATOR:
DELTA CALCULATION (at each sector crossing):
PROPOSED PUBLIC API:
Alternatives considered
User computes (getBestSector1Time() - getCurrentLapSector1Time()) themselves —
current workaround. Two calls, user math, no optimal tracking. Every karting
display project reinvents this.
getOptimalLapTime() (already exists) — sums best sectors after the fact but
doesn't give per-sector signed deltas or the live accumulated lap delta.
Include only deltaBest, not deltaOptimal — simpler, but misses the "theoretical
best lap" concept that is standard in professional timing systems.