1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 17:55:28 +03:00

final fixes ...

This commit is contained in:
breadoven 2022-09-18 11:41:14 +01:00
parent 19918ee261
commit 7aa646da51
5 changed files with 15 additions and 23 deletions

View file

@ -3944,7 +3944,7 @@ Sets restart behaviour for a WP mission when interrupted mid mission. START from
### nav_wp_multi_mission_index
Index of mission selected from multi mission WP entry loaded in flight controller. Limited to a maximum of 9 missions.
Index of active mission selected from multi mission WP entry loaded in flight controller. Limited to a maximum of 9 missions.
| Default | Min | Max |
| --- | --- | --- |

View file

@ -2441,7 +2441,7 @@ groups:
field: general.flags.waypoint_mission_restart
table: nav_wp_mission_restart
- name: nav_wp_multi_mission_index
description: "Index of mission selected from multi mission WP entry loaded in flight controller. Limited to a maximum of 9 missions."
description: "Index of active mission selected from multi mission WP entry loaded in flight controller. Limited to a maximum of 9 missions."
default_value: 1
field: general.waypoint_multi_mission_index
condition: USE_MULTI_MISSION

View file

@ -3182,9 +3182,8 @@ static bool osdDrawSingleElement(uint8_t item)
if (navConfig()->general.waypoint_multi_mission_index != posControl.loadedMultiMissionIndex) {
tfp_sprintf(buff, "M%u/%u>LOAD", navConfig()->general.waypoint_multi_mission_index, posControl.multiMissionCount);
} else {
int8_t wpCount = posControl.loadedMissionWpCount;
if (posControl.waypointListValid && wpCount > 0) {
tfp_sprintf(buff, "M%u/%u>%2uWP", posControl.loadedMultiMissionIndex, posControl.multiMissionCount, wpCount);
if (posControl.waypointListValid && posControl.waypointCount > 0) {
tfp_sprintf(buff, "M%u/%u>%2uWP", posControl.loadedMultiMissionIndex, posControl.multiMissionCount, posControl.waypointCount);
} else {
tfp_sprintf(buff, "M0/%u> 0WP", posControl.multiMissionCount);
}

View file

@ -3158,7 +3158,6 @@ void resetWaypointList(void)
posControl.waypointListValid = false;
posControl.geoWaypointCount = 0;
posControl.startWpIndex = 0;
posControl.loadedMissionWpCount = 0;
#ifdef USE_MULTI_MISSION
posControl.totalMultiMissionWpCount = 0;
posControl.loadedMultiMissionIndex = 0;
@ -3181,6 +3180,7 @@ int getWaypointCount(void)
#endif
return waypointCount;
}
#ifdef USE_MULTI_MISSION
void selectMultiMissionIndex(int8_t increment)
{
@ -3192,7 +3192,7 @@ void selectMultiMissionIndex(int8_t increment)
void loadSelectedMultiMission(uint8_t missionIndex)
{
uint8_t missionCount = 1;
posControl.loadedMissionWpCount = 0;
posControl.waypointCount = 0;
posControl.geoWaypointCount = 0;
for (int i = 0; i < NAV_MAX_WAYPOINTS; i++) {
@ -3204,13 +3204,13 @@ void loadSelectedMultiMission(uint8_t missionIndex)
posControl.geoWaypointCount++;
}
// mission start WP
if (posControl.loadedMissionWpCount == 0) {
posControl.loadedMissionWpCount = 1; // start marker only, value unimportant (but not 0)
if (posControl.waypointCount == 0) {
posControl.waypointCount = 1; // start marker only, value unimportant (but not 0)
posControl.startWpIndex = i;
}
// mission end WP
if (posControl.waypointList[i].flag == NAV_WP_FLAG_LAST) {
posControl.loadedMissionWpCount = i - posControl.startWpIndex + 1;
posControl.waypointCount = i - posControl.startWpIndex + 1;
break;
}
} else if (posControl.waypointList[i].flag == NAV_WP_FLAG_LAST) {
@ -3226,7 +3226,7 @@ bool updateWpMissionChange(void)
{
/* Function only called when ARMED */
if (posControl.multiMissionCount <= 1 || posControl.wpPlannerActiveWPIndex || FLIGHT_MODE(NAV_WP_MODE)) {
if (posControl.multiMissionCount < 2 || posControl.wpPlannerActiveWPIndex || FLIGHT_MODE(NAV_WP_MODE)) {
return true;
}
@ -3236,10 +3236,6 @@ bool updateWpMissionChange(void)
if (posControl.loadedMultiMissionIndex != setMissionIndex) {
loadSelectedMultiMission(setMissionIndex);
}
/* align waypointCount with loadedMissionWpCount on arming */
if (posControl.waypointCount != posControl.loadedMissionWpCount) {
posControl.waypointCount = posControl.loadedMissionWpCount;
}
return true;
}
@ -3302,14 +3298,13 @@ bool loadNonVolatileWaypointList(bool clearIfLoaded)
/* Mission sanity check failed - reset the list
* Also reset if no selected mission loaded (shouldn't happen) */
if (!posControl.waypointListValid || !posControl.loadedMissionWpCount) {
if (!posControl.waypointListValid || !posControl.waypointCount) {
#else
// check this is the last waypoint
if (nonVolatileWaypointList(i)->flag == NAV_WP_FLAG_LAST) {
break;
}
}
posControl.loadedMissionWpCount = posControl.waypointCount;
// Mission sanity check failed - reset the list
if (!posControl.waypointListValid) {
@ -3869,11 +3864,10 @@ navArmingBlocker_e navigationIsBlockingArming(bool *usedBypass)
* Can't jump beyond WP list
* Only jump to geo-referenced WP types
*/
uint8_t wpCount = posControl.loadedMissionWpCount;
if (wpCount) {
for (uint8_t wp = posControl.startWpIndex; wp < wpCount + posControl.startWpIndex; wp++){
if (posControl.waypointCount) {
for (uint8_t wp = posControl.startWpIndex; wp < posControl.waypointCount + posControl.startWpIndex; wp++){
if (posControl.waypointList[wp].action == NAV_WP_ACTION_JUMP){
if (wp == posControl.startWpIndex || posControl.waypointList[wp].p1 >= wpCount ||
if (wp == posControl.startWpIndex || posControl.waypointList[wp].p1 >= posControl.waypointCount ||
(posControl.waypointList[wp].p1 > (wp - posControl.startWpIndex - 2) && posControl.waypointList[wp].p1 < (wp - posControl.startWpIndex + 2)) || posControl.waypointList[wp].p2 < -1) {
return NAV_ARMING_BLOCKER_JUMP_WAYPOINT_ERROR;
}

View file

@ -382,9 +382,8 @@ typedef struct {
/* Waypoint list */
navWaypoint_t waypointList[NAV_MAX_WAYPOINTS];
bool waypointListValid;
int8_t waypointCount; // number of WPs loaded from WP source
int8_t waypointCount; // number of WPs in loaded mission
int8_t startWpIndex; // index of first waypoint in mission
int8_t loadedMissionWpCount; // number of WPs in loaded mission
int8_t geoWaypointCount; // total geospatial WPs in mission
bool wpMissionRestart; // mission restart from first waypoint