DovesLapTimer 4.3.0
GPS-based lap timing Arduino library — go-karts to race cars
Loading...
Searching...
No Matches
CourseManager.h
Go to the documentation of this file.
1
12#ifndef _COURSE_MANAGER_H
13#define _COURSE_MANAGER_H
14
15#include <Arduino.h>
16#include "DovesLapTimer.h"
17#include "WaypointLapTimer.h"
18#include "CourseDetector.h"
19
29
36
39 const char* name;
40 float lengthFt;
41 bool active;
42};
43
45public:
46 CourseManager(TrackConfig& config, double crossingThreshold = 7.0, Stream *debugSerial = NULL);
47
48 void updateCurrentTime(unsigned long ms);
49 int loop(double lat, double lng, float altMeters, float speedKnots);
50 void reset();
66 bool selectCourse(int index);
67
68 // Detection state
69 bool isDetectionComplete() const;
70 int getActiveCourseIndex() const;
71 const char* getActiveCourseName() const;
72 int getCourseCount() const;
74 // True while the given course's timer is still being fed GPS data.
75 // Courses are deactivated by pruneInactiveCourses() after detection, or
76 // automatically when the Lap Anything fallback activates.
77 bool isCourseTimerActive(int index) const;
78
79 // Timer access
82 bool isLapAnythingActive() const;
83
84 // Track metadata
85 const char* getTrackName() const;
86 const char* getShortName() const;
87
88 // Detector access
90
91 // Threshold setters
92 void setSpeedThresholdMph(float mph);
93 void setWaypointProximityMeters(float meters);
94 void setDetectionProximityMeters(float meters);
95
96private:
97#ifdef DOVES_DISABLE_DEBUG
98 // Compile-time debug kill switch: the runtime _serial null-check still
99 // keeps every debug string and print call-site in flash on production
100 // builds that never attach a debug Stream. Defining DOVES_DISABLE_DEBUG
101 // (e.g. -DDOVES_DISABLE_DEBUG in build flags) replaces the debug
102 // templates with empty inlines so the compiler drops it all — several
103 // KB on a fully-featured firmware. Debug behavior is unchanged when
104 // the macro is not defined.
105 template<typename... Args> void debug_print(Args&&...) {}
106 template<typename... Args> void debug_println(Args&&...) {}
107#else
108 template<typename... Args>
109 void debug_print(Args&&... args) {
110 if(_serial) { _serial->print(std::forward<Args>(args)...); }
111 }
112 template<typename... Args>
113 void debug_println(Args&&... args) {
114 if(_serial) { _serial->println(std::forward<Args>(args)...); }
115 }
116#endif
117
118 void _initCourses(TrackConfig& config);
119 void _handleCandidatesReady(float currentOdometer);
120 void _activateLapAnything();
121
122 Stream *_serial;
123 double _crossingThreshold;
124
125 CourseTimerEntry _courseTimers[MAX_COURSES];
126 int _courseCount;
127
128 CourseDetector _detector;
129 WaypointLapTimer _lapAnythingTimer;
130
131 int _activeCourseIndex;
132 bool _detectionComplete;
133 bool _lapAnythingActive;
134 int _detectionRejectionCount;
135 // Odometer reading beyond which incomplete detection falls back to Lap
136 // Anything (factor x longest configured course, floored — see
137 // COURSE_DETECT_FALLBACK_* in DovesLapTimer.h).
138 float _fallbackDistanceMeters;
139
140 const char* _trackLongName;
141 const char* _trackShortName;
142};
143
144#endif
#define MAX_COURSES
Definition DovesLapTimer.h:67
void loop()
Definition basic_oled_example.ino:116
Definition CourseDetector.h:30
Definition CourseManager.h:44
void setSpeedThresholdMph(float mph)
Definition CourseManager.cpp:308
const char * getShortName() const
Definition CourseManager.cpp:300
void setDetectionProximityMeters(float meters)
Definition CourseManager.cpp:317
int getActiveCourseIndex() const
Definition CourseManager.cpp:259
void updateCurrentTime(unsigned long ms)
Definition CourseManager.cpp:102
WaypointLapTimer * getLapAnythingTimer()
Definition CourseManager.cpp:288
void reset()
Definition CourseManager.cpp:233
const char * getActiveCourseName() const
Definition CourseManager.cpp:263
DovesLapTimer * getActiveTimer()
Definition CourseManager.cpp:282
CourseDetector * getDetector()
Definition CourseManager.cpp:304
void setWaypointProximityMeters(float meters)
Definition CourseManager.cpp:313
void pruneInactiveCourses()
Definition CourseManager.cpp:223
bool isDetectionComplete() const
Definition CourseManager.cpp:255
bool selectCourse(int index)
Selects a course directly, bypassing CourseDetector entirely.
Definition CourseManager.cpp:208
const char * getTrackName() const
Definition CourseManager.cpp:296
int getDetectionRejectionCount() const
Definition CourseManager.cpp:273
int getCourseCount() const
Definition CourseManager.cpp:269
bool isCourseTimerActive(int index) const
Definition CourseManager.cpp:277
bool isLapAnythingActive() const
Definition CourseManager.cpp:292
Definition DovesLapTimer.h:103
Definition WaypointLapTimer.h:29
Definition CourseManager.h:20
double startALat
Definition CourseManager.h:23
double startBLat
Definition CourseManager.h:23
double sector3BLat
Definition CourseManager.h:25
bool hasSector3
Definition CourseManager.h:27
double sector3ALat
Definition CourseManager.h:25
double startBLng
Definition CourseManager.h:23
const char * name
Definition CourseManager.h:21
double sector3ALng
Definition CourseManager.h:25
double sector3BLng
Definition CourseManager.h:25
double sector2ALat
Definition CourseManager.h:24
double sector2ALng
Definition CourseManager.h:24
double sector2BLng
Definition CourseManager.h:24
bool hasSector2
Definition CourseManager.h:26
double startALng
Definition CourseManager.h:23
double sector2BLat
Definition CourseManager.h:24
float lengthFt
Definition CourseManager.h:22
Definition CourseManager.h:37
const char * name
Definition CourseManager.h:39
float lengthFt
Definition CourseManager.h:40
bool active
Definition CourseManager.h:41
DovesLapTimer timer
Definition CourseManager.h:38
Definition CourseManager.h:30
int courseCount
Definition CourseManager.h:34
const char * shortName
Definition CourseManager.h:32
const char * longName
Definition CourseManager.h:31
CourseConfig courses[MAX_COURSES]
Definition CourseManager.h:33