Fixed lcd messages and gps triggering bugs
This commit is contained in:
@@ -19,6 +19,7 @@ enum task_type : uint8_t {
|
|||||||
TASK_DISPLAY_GPS_DEBUG,
|
TASK_DISPLAY_GPS_DEBUG,
|
||||||
TASK_DISPLAY_MSG_GPS_FIX,
|
TASK_DISPLAY_MSG_GPS_FIX,
|
||||||
TASK_DISPLAY_MSG_TRACK_DETECT_OK,
|
TASK_DISPLAY_MSG_TRACK_DETECT_OK,
|
||||||
|
TASK_DISPLAY_MSG_CONFIG_NO_TRACKS,
|
||||||
TASK_CONFIG_TRACK_DETECT,
|
TASK_CONFIG_TRACK_DETECT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,6 @@
|
|||||||
copy_from_volatile(out, config_global);
|
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);
|
copy_to_volatile(config_global, in);
|
||||||
}
|
}
|
||||||
@@ -25,16 +25,19 @@ config::~config() {}
|
|||||||
|
|
||||||
int config::read_cfg() {
|
int config::read_cfg() {
|
||||||
EEPROM.get(0, _config);
|
EEPROM.get(0, _config);
|
||||||
|
config_global_write(_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config::write_cfg() {
|
int config::write_cfg() {
|
||||||
EEPROM.put(0, _config);
|
EEPROM.put(0, _config);
|
||||||
|
config_global_write(_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config::write_cfg(const vehicle_config &new_config) {
|
int config::write_cfg(const vehicle_config &new_config) {
|
||||||
EEPROM.put(0, new_config);
|
EEPROM.put(0, new_config);
|
||||||
|
config_global_write(new_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +53,10 @@ int config::task_config_detect_track(unsigned long timeout_ms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!min_one) {
|
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();
|
this->task_complete();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -83,10 +90,23 @@ int config::task_config_detect_track(unsigned long timeout_ms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (task_data.last_checked >= 8) {
|
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();
|
this->task_complete();
|
||||||
router::send(MOD_LCD, TASK_DISPLAY_MSG_TRACK_DETECT_OK, 4000);
|
if (load_res == 0) {
|
||||||
return 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) {
|
if ((unsigned long)(millis() - start) >= timeout_ms) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ private:
|
|||||||
Task _active_task = {};
|
Task _active_task = {};
|
||||||
uint8_t _task_memory[64] = {};
|
uint8_t _task_memory[64] = {};
|
||||||
bool _task_memory_stale = true;
|
bool _task_memory_stale = true;
|
||||||
|
bool _no_tracks_notice_shown = false;
|
||||||
|
|
||||||
int read_cfg();
|
int read_cfg();
|
||||||
int write_cfg();
|
int write_cfg();
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ bool lcd::is_message_task(task_type type) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case TASK_DISPLAY_MSG_GPS_FIX:
|
case TASK_DISPLAY_MSG_GPS_FIX:
|
||||||
case TASK_DISPLAY_MSG_TRACK_DETECT_OK:
|
case TASK_DISPLAY_MSG_TRACK_DETECT_OK:
|
||||||
|
case TASK_DISPLAY_MSG_CONFIG_NO_TRACKS:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -165,6 +166,15 @@ int lcd::render_msg_track_detect_ok() {
|
|||||||
return 0;
|
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) {
|
int lcd::push(const Task &task) {
|
||||||
return _queue.push(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);
|
activate_message(screen::msg_track_detect_ok, next_task.data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TASK_DISPLAY_MSG_CONFIG_NO_TRACKS:
|
||||||
|
activate_message(screen::msg_config_no_tracks, next_task.data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -392,6 +406,10 @@ int lcd::loop(unsigned long timeout_ms) {
|
|||||||
this->render_msg_track_detect_ok();
|
this->render_msg_track_detect_ok();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case screen::msg_config_no_tracks:
|
||||||
|
this->render_msg_config_no_tracks();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ typedef enum lcd_screen {
|
|||||||
gps_debug,
|
gps_debug,
|
||||||
msg_gps_fix,
|
msg_gps_fix,
|
||||||
msg_track_detect_ok,
|
msg_track_detect_ok,
|
||||||
|
msg_config_no_tracks,
|
||||||
} lcd_screen;
|
} lcd_screen;
|
||||||
|
|
||||||
} // namespace screen
|
} // namespace screen
|
||||||
@@ -61,6 +62,7 @@ private:
|
|||||||
int render_gps_debug();
|
int render_gps_debug();
|
||||||
int render_msg_gps_fix();
|
int render_msg_gps_fix();
|
||||||
int render_msg_track_detect_ok();
|
int render_msg_track_detect_ok();
|
||||||
|
int render_msg_config_no_tracks();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int push(const Task &task) override;
|
int push(const Task &task) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user