Added member variables to GPS for lap detection

This commit is contained in:
2026-03-30 23:43:43 +02:00
parent 22b7f82496
commit 5e19e7daa8
4 changed files with 40 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ enum Type : uint8_t {
ConfigTengSetHigh,
BatteryCal,
AllConfigUpdated,
AllTrackLoaded,
};
} // namespace task

View File

@@ -375,5 +375,6 @@ int Config::loadTrack(unsigned int idx) {
loaded_track_ = track_data;
trackGlobalWrite(loaded_track_);
is_track_loaded_ = true;
router::send(module::All, task::AllTrackLoaded);
return 0;
}

View File

@@ -50,6 +50,29 @@ int Gps::loop(unsigned long timeout_ms) {
}
}
Task active;
int res = queue_.pop(active);
if (res == 0) {
if (active.target_ == module::Gps) {
} else if (active.target_ == module::All) {
switch (active.type_)
{
case task::AllTrackLoaded:
#ifdef DEBUG
if (logger_ != nullptr) {
logger_->debug("GPS received track loaded sig");
}
#endif
lap_active_ = true;
break;
default:
break;
}
}
}
return 0;
}

View File

@@ -13,6 +13,15 @@
#include "data/gps_store.h"
#include "base/router.h"
namespace trigger_status {
enum TriggerStatus {
Idle,
Armed,
Trigd,
};
}
class Gps : public ModuleBase {
private:
TinyGPSPlus *gps_;
@@ -20,6 +29,12 @@ private:
SystemLogger *logger_;
RingBuffer<Task, 16> queue_;
uint32_t last_fix_value_ = 0;
trigger_status::TriggerStatus start_line_trigger_ = trigger_status::Idle;
bool lap_active_ = false;
unsigned long last_check_ = 0;
unsigned long check_interval_ = 250;
unsigned long last_arm_ = 0;
int arm_sign_ = 0;
public:
int push(const Task &task) override;