DovesLapTimer 4.3.0
GPS-based lap timing Arduino library — go-karts to race cars
Loading...
Searching...
No Matches
sprint_timing_example.ino File Reference
#include <DovesLapTimer.h>
#include <SprintTimer.h>

Functions

void feedFix ()
 
double latAt (double yMeters)
 
double lngAt (double xMeters)
 
void loop ()
 
void printRun ()
 
void setup ()
 

Variables

const double BASE_LAT = 28.40000
 
const double BASE_LNG = -81.40000
 
const double COURSE_END_X = 500.0
 
bool done = false
 
const double FINISH_X = 450.0
 
const double LINE_HALF_WIDTH = 10.0
 
const double M_PER_DEG_LAT = 111194.9266
 
const double M_PER_DEG_LNG = 111194.9266 * 0.879649
 
const double RETURN_Y = 40.0
 
const unsigned int RUNS_TO_DO = 3
 
unsigned int runsSeen = 0
 
const double S2_X = 150.0
 
const double S3_X = 300.0
 
const float SIM_ALT_METERS = 50.0f
 
const unsigned long SIM_MS_PER_STEP = 200
 
const float SIM_SPEED_KNOTS = 48.0f
 
int simPhase = 0
 
unsigned long simTimeMs = 0
 
double simX = 0
 
double simY = 0
 
SprintTimer sprintTimer (7.0)
 
const double START_X = 50.0
 
const double STEP_METERS = 5.0
 

Function Documentation

◆ feedFix()

void feedFix ( )

◆ latAt()

double latAt ( double  yMeters)

◆ lngAt()

double lngAt ( double  xMeters)

◆ loop()

void loop ( )

◆ printRun()

void printRun ( )

◆ setup()

void setup ( )

Variable Documentation

◆ BASE_LAT

const double BASE_LAT = 28.40000

Sprint (Point-to-Point) Timing Example for DovesLapTimer's SprintTimer

Demonstrates sprint-mode run timing — autocross / hillclimb style: a START line and a SEPARATE FINISH line, no laps — using a SYNTHETIC GPS course, no GPS hardware required. The timer is driven through three simulated runs down a 500 m straight (loop back on a parallel return leg between runs) so you can watch run times, split segments, best-run and optimal tracking light up on Serial.

Course layout (x = meters along the course):

0m ── START(50m) ── S2(150m) ── S3(300m) ── FINISH(450m) ── 500m |----------— timed run: 400m -----------—| return leg 40m north of the course, outside every crossing zone

Sprint semantics demonstrated:

  • a start-line crossing begins a run; a finish-line crossing ends it
  • crossing the start again MID-RUN cancels and restarts (botched course)
  • finish crossings with no active run are ignored (the return loop)
  • splits are optional: zero, one, or two lines are all legal

To adapt for a real course:

  1. Replace the line coordinates below with your own (Google Maps right-click -> copy lat,lng).
  2. Delete the synthetic-drive block in loop().
  3. Feed real GPS: lat, lng, altitude (m), speed (knots) into sprintTimer.loop(), and ms-since-midnight into sprintTimer.updateCurrentTime().

RAM note: each configured line owns an independent crossing buffer (~2.9 KB each on 32-bit targets). SprintTimer targets modern MCUs (nRF52840, ESP32, ...) — it does not fit small AVRs.

◆ BASE_LNG

const double BASE_LNG = -81.40000

◆ COURSE_END_X

const double COURSE_END_X = 500.0

◆ done

bool done = false

◆ FINISH_X

const double FINISH_X = 450.0

◆ LINE_HALF_WIDTH

const double LINE_HALF_WIDTH = 10.0

◆ M_PER_DEG_LAT

const double M_PER_DEG_LAT = 111194.9266

◆ M_PER_DEG_LNG

const double M_PER_DEG_LNG = 111194.9266 * 0.879649

◆ RETURN_Y

const double RETURN_Y = 40.0

◆ RUNS_TO_DO

const unsigned int RUNS_TO_DO = 3

◆ runsSeen

unsigned int runsSeen = 0

◆ S2_X

const double S2_X = 150.0

◆ S3_X

const double S3_X = 300.0

◆ SIM_ALT_METERS

const float SIM_ALT_METERS = 50.0f

◆ SIM_MS_PER_STEP

const unsigned long SIM_MS_PER_STEP = 200

◆ SIM_SPEED_KNOTS

const float SIM_SPEED_KNOTS = 48.0f

◆ simPhase

int simPhase = 0

◆ simTimeMs

unsigned long simTimeMs = 0

◆ simX

double simX = 0

◆ simY

double simY = 0

◆ sprintTimer

SprintTimer sprintTimer(7.0) ( 7.  0)

◆ START_X

const double START_X = 50.0

◆ STEP_METERS

const double STEP_METERS = 5.0