Fixed lcd messages and gps triggering bugs

This commit is contained in:
Hector van der Aa
2026-03-27 13:01:49 +01:00
parent b1cb6b4234
commit 7f1494f18e
6 changed files with 52 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ enum task_type : uint8_t {
TASK_DISPLAY_GPS_DEBUG,
TASK_DISPLAY_MSG_GPS_FIX,
TASK_DISPLAY_MSG_TRACK_DETECT_OK,
TASK_DISPLAY_MSG_CONFIG_NO_TRACKS,
TASK_CONFIG_TRACK_DETECT,
};
@@ -26,4 +27,4 @@ struct Task {
module_id target;
task_type type;
uint32_t data;
};
};

View File

@@ -9,6 +9,6 @@
copy_from_volatile(out, config_global);
}
void track_global_write(const vehicle_config& in) {
void config_global_write(const vehicle_config& in) {
copy_to_volatile(config_global, in);
}
}

View File

@@ -25,16 +25,19 @@ config::~config() {}
int config::read_cfg() {
EEPROM.get(0, _config);
config_global_write(_config);
return 0;
}
int config::write_cfg() {
EEPROM.put(0, _config);
config_global_write(_config);
return 0;
}
int config::write_cfg(const vehicle_config &new_config) {
EEPROM.put(0, new_config);
config_global_write(new_config);
return 0;
}
@@ -50,6 +53,10 @@ int config::task_config_detect_track(unsigned long timeout_ms) {
}
if (!min_one) {
if (!_no_tracks_notice_shown) {
router::send(MOD_LCD, TASK_DISPLAY_MSG_CONFIG_NO_TRACKS, 3000);
_no_tracks_notice_shown = true;
}
this->task_complete();
return 1;
}
@@ -83,10 +90,23 @@ int config::task_config_detect_track(unsigned long timeout_ms) {
}
if (task_data.last_checked >= 8) {
this->load_track(task_data.smallest_idx);
int load_res = 1;
if (task_data.smallest_idx > 0) {
load_res = this->load_track(task_data.smallest_idx);
}
this->task_complete();
router::send(MOD_LCD, TASK_DISPLAY_MSG_TRACK_DETECT_OK, 4000);
return 0;
if (load_res == 0) {
_no_tracks_notice_shown = false;
router::send(MOD_LCD, TASK_DISPLAY_MSG_TRACK_DETECT_OK, 4000);
return 0;
}
if (!_no_tracks_notice_shown) {
router::send(MOD_LCD, TASK_DISPLAY_MSG_CONFIG_NO_TRACKS, 3000);
_no_tracks_notice_shown = true;
}
return 1;
}
if ((unsigned long)(millis() - start) >= timeout_ms) {
@@ -185,4 +205,4 @@ int config::load_track(unsigned int idx) {
track_global_write(_loaded_track);
_is_track_loaded = true;
return 0;
}
}

View File

@@ -34,6 +34,7 @@ private:
Task _active_task = {};
uint8_t _task_memory[64] = {};
bool _task_memory_stale = true;
bool _no_tracks_notice_shown = false;
int read_cfg();
int write_cfg();
@@ -51,4 +52,4 @@ public:
int loop(unsigned long timeout_ms = 500);
int get_track(unsigned int idx, track_data &t);
int load_track(unsigned int idx);
};
};

View File

@@ -60,6 +60,7 @@ bool lcd::is_message_task(task_type type) {
switch (type) {
case TASK_DISPLAY_MSG_GPS_FIX:
case TASK_DISPLAY_MSG_TRACK_DETECT_OK:
case TASK_DISPLAY_MSG_CONFIG_NO_TRACKS:
return true;
default:
@@ -165,6 +166,15 @@ int lcd::render_msg_track_detect_ok() {
return 0;
}
int lcd::render_msg_config_no_tracks() {
this->clear();
_display->setCursor(4, 1);
this->print("CONFIG INFO");
_display->setCursor(2, 2);
this->print("NO TRACKS LOADED");
return 0;
}
int lcd::push(const Task &task) {
return _queue.push(task);
}
@@ -350,6 +360,10 @@ int lcd::loop(unsigned long timeout_ms) {
activate_message(screen::msg_track_detect_ok, next_task.data);
break;
case TASK_DISPLAY_MSG_CONFIG_NO_TRACKS:
activate_message(screen::msg_config_no_tracks, next_task.data);
break;
default:
break;
}
@@ -392,6 +406,10 @@ int lcd::loop(unsigned long timeout_ms) {
this->render_msg_track_detect_ok();
break;
case screen::msg_config_no_tracks:
this->render_msg_config_no_tracks();
break;
default:
break;
}
@@ -401,4 +419,4 @@ int lcd::loop(unsigned long timeout_ms) {
return 1;
}
#undef MOD
#undef MOD

View File

@@ -22,6 +22,7 @@ typedef enum lcd_screen {
gps_debug,
msg_gps_fix,
msg_track_detect_ok,
msg_config_no_tracks,
} lcd_screen;
} // namespace screen
@@ -61,6 +62,7 @@ private:
int render_gps_debug();
int render_msg_gps_fix();
int render_msg_track_detect_ok();
int render_msg_config_no_tracks();
public:
int push(const Task &task) override;
@@ -70,4 +72,4 @@ public:
int init();
int print_message(String message);
int loop(unsigned long timeout_ms = 500);
};
};