DovesLapTimer 4.3.0
GPS-based lap timing Arduino library — go-karts to race cars
Loading...
Searching...
No Matches
CrossingEngine.h File Reference
#include <Arduino.h>
#include "ArxTypeTraits.h"
#include "GeoMath.h"
+ Include dependency graph for CrossingEngine.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CrossingEngine
 
struct  crossingPointBufferEntry
 

Macros

#define CROSSING_LINE_SIDE_A   -1
 
#define CROSSING_LINE_SIDE_B   1
 
#define CROSSING_LINE_SIDE_EXACT   0
 
#define CROSSING_MAX_FIX_GAP_MS   10000UL
 
#define CROSSING_PAIR_SPACING_FACTOR   1.25
 
#define DOVES_MILLIS_PER_DAY   86400000UL
 

Enumerations

enum  LineDetectResult { LINE_DETECT_NONE , LINE_DETECT_IN_ZONE , LINE_DETECT_COMPLETED }
 

Functions

static unsigned long timeSinceMidnightDelta (unsigned long startMs, unsigned long endMs)
 Elapsed milliseconds between two milliseconds-since-midnight timestamps.
 

Macro Definition Documentation

◆ CROSSING_LINE_SIDE_A

#define CROSSING_LINE_SIDE_A   -1

CrossingEngine - the reusable line-crossing detection core.

Owns the in-zone GPS ring buffer and the crossing interpolation math that previously lived inside DovesLapTimer (_detectLineCrossing + interpolateCrossingPoint). Extracted so point-to-point timers (SprintTimer) can reuse the exact same battle-tested pipeline — including with independent per-line buffers — without duplicating the math.

The engine is deliberately stateless about which line it is checking: line endpoints and the per-line in-zone flag are passed per call, exactly like the old private helper. One engine can therefore be shared across several lines (DovesLapTimer shares one across S/F + S2 + S3, with the caller enforcing only-one-line-crossing-at-a-time), or dedicated to a single line (SprintTimer gives every line its own engine, so start and finish zones may overlap without contention).

See DETECTION.md for the algorithm itself.

◆ CROSSING_LINE_SIDE_B

#define CROSSING_LINE_SIDE_B   1

◆ CROSSING_LINE_SIDE_EXACT

#define CROSSING_LINE_SIDE_EXACT   0

◆ CROSSING_MAX_FIX_GAP_MS

#define CROSSING_MAX_FIX_GAP_MS   10000UL

◆ CROSSING_PAIR_SPACING_FACTOR

#define CROSSING_PAIR_SPACING_FACTOR   1.25

◆ DOVES_MILLIS_PER_DAY

#define DOVES_MILLIS_PER_DAY   86400000UL

Enumeration Type Documentation

◆ LineDetectResult

Enumerator
LINE_DETECT_NONE 
LINE_DETECT_IN_ZONE 
LINE_DETECT_COMPLETED 

Function Documentation

◆ timeSinceMidnightDelta()

static unsigned long timeSinceMidnightDelta ( unsigned long  startMs,
unsigned long  endMs 
)
inlinestatic

Elapsed milliseconds between two milliseconds-since-midnight timestamps.

Normalizes across the UTC midnight wrap (86,399,999 -> 0), which happens mid-evening across the Americas. Without this, a lap straddling midnight underflows unsigned subtraction into a ~4.29-billion-ms "lap time".

Parameters
startMsEarlier timestamp, in ms since midnight.
endMsLater timestamp, in ms since midnight.
Returns
Elapsed time in ms, wrap-normalized.