Skip to content

Commit

Permalink
Fix retrieve waypoint name
Browse files Browse the repository at this point in the history
  • Loading branch information
jgauchia committed Sep 1, 2024
1 parent 12f06ca commit 9e2f3a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/gui/src/waypointListScr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void waypointListEvent(lv_event_t * event)
{
std::string wptSelected = sel.substring(6,sel.length()).c_str();
log_i("%s",wptSelected.c_str());
std::regex wptGet("<wpt\\s+lat=\"([^\"]+)\"\\s+lon=\"([^\"]+)\">\\s*<name>(.*?)</name>\\s*</wpt>");
std::regex wptGet("<wpt\\s+lat=\"([^\"]+)\"\\s+lon=\"([^\"]+)\">\\s*<name>([^<]+)</name>\\s*</wpt>");
std::smatch wptFound;
std::string::const_iterator wptSearch(wptContent.cbegin());

Expand All @@ -47,7 +47,9 @@ void waypointListEvent(lv_event_t * event)

if ( name == wptSelected )
{
addWpt.name = (char*)name.c_str();
//addWpt.name = (char*)name.c_str();
addWpt.name = new char[name.size() + 1];
std::strcpy(addWpt.name, name.c_str());
addWpt.lat = std::stod(lat);
addWpt.lon = std::stod(lon);
log_i("Waypoint: %s %f %f",addWpt.name, addWpt.lat, addWpt.lon);
Expand All @@ -73,6 +75,7 @@ void waypointListEvent(lv_event_t * event)
listWaypointScreen = lv_table_create(NULL);
lv_obj_set_size(listWaypointScreen, TFT_WIDTH, TFT_HEIGHT);
lv_table_set_cell_value(listWaypointScreen, 0, 0, "Waypoints");
lv_table_set_column_width(listWaypointScreen,0,TFT_WIDTH);
lv_obj_add_event_cb(listWaypointScreen, waypointListEvent, LV_EVENT_ALL, NULL);
lv_obj_set_style_pad_ver(listWaypointScreen, 10, LV_PART_ITEMS);
}
Expand Down
1 change: 1 addition & 0 deletions lib/navigation/src/navWpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ void updateNavScreen()
lv_label_set_text_static(latNav, latFormatString(addWpt.lat));
lv_label_set_text_static(lonNav, lonFormatString(addWpt.lon));
lv_label_set_text_fmt(nameNav, "%s",addWpt.name);
delete[] addWpt.name;
}

0 comments on commit 9e2f3a2

Please sign in to comment.