Updated GlobalTrackData struct to store precomputed circle radius

This commit is contained in:
2026-03-31 22:42:49 +02:00
parent 46c652181c
commit a49147215e
5 changed files with 67 additions and 26 deletions

View File

@@ -69,7 +69,7 @@ int Config::deleteTrack(unsigned short idx) {
is_track_loaded_ = false;
loaded_track_ = {};
GlobalTrackData track;
track.loaded = false;
track.loaded_ = false;
track.root_ = loaded_track_;
trackGlobalWrite(track);
}
@@ -92,7 +92,7 @@ int Config::resetConfig() {
task_memory_stale_ = true;
no_tracks_notice_shown_ = false;
GlobalTrackData track;
track.loaded = false;
track.loaded_ = false;
track.root_ = loaded_track_;
trackGlobalWrite(track);
@@ -380,7 +380,16 @@ int Config::loadTrack(unsigned int idx) {
loaded_track_ = track_data;
GlobalTrackData track;
track.loaded = true;
track.loaded_ = true;
Vec2 point_b =eqRectProjection(track_data.point_b_, track_data.point_a_);
track.center_ = abMidpoint(point_b, (Vec2){0.0f,0.0f});
track.circle_radius_ = max(10.0f, vecMod(point_b) * 1.25f);
#ifdef DEBUG
if (logger_ != nullptr) {
logger_->debug("Radius: " + String(track.circle_radius_));
logger_->debug("Line Length: " + String(vecMod(point_b)));
}
#endif
track.root_ = track_data;
trackGlobalWrite(track);
is_track_loaded_ = true;

View File

@@ -4,11 +4,11 @@
#include "gps.h"
#include "data/track_store.h"
#define MOD "modules/gps/gps.h"
int Gps::push(const Task &task) {
return queue_.push(task);
}
int Gps::push(const Task &task) { return queue_.push(task); }
Gps::Gps(HardwareSerial *data_stream)
: gps_(nullptr), data_stream_(data_stream), logger_(nullptr) {
@@ -49,31 +49,28 @@ int Gps::loop(unsigned long timeout_ms) {
return 1;
}
}
if (lap_active_) {
if (start_line_trigger_ == trigger_status::Idle) {
float current_lat = gps_->location.lat();
float current_lng = gps_->location.lat();
}
}
Task active;
Task active;
int res = queue_.pop(active);
if (res == 0) {
if (active.target_ == module::Gps) {
} else if (active.target_ == module::All) {
switch (active.type_)
{
switch (active.type_) {
case task::AllTrackLoaded:
#ifdef DEBUG
#ifdef DEBUG
if (logger_ != nullptr) {
logger_->debug("GPS received track loaded sig");
}
#endif
#endif
lap_active_ = true;
break;
default:
break;
}