1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-609 Check if Homelocation is set at start

This commit is contained in:
Laurent Lalanne 2019-05-18 18:40:32 +02:00
parent cb38db30fb
commit ff1b5bb56e

View File

@ -82,6 +82,7 @@ static bool module_enabled = false;
static bool module_enabled; static bool module_enabled;
static struct telemetrydata *telestate; static struct telemetrydata *telestate;
static HoTTBridgeStatusData status; static HoTTBridgeStatusData status;
static HomeLocationSetOptions homeSetFlash;
// Private functions // Private functions
static void uavoHoTTBridgeTask(void *parameters); static void uavoHoTTBridgeTask(void *parameters);
@ -182,6 +183,12 @@ static void uavoHoTTBridgeTask(__attribute__((unused)) void *parameters)
// data delay between transmitted bytes // data delay between transmitted bytes
uint32_t datadelay = DATA_TIME; uint32_t datadelay = DATA_TIME;
// Get stored homeSet status at start
if (HomeLocationHandle() != NULL) {
UAVObjLoad(HomeLocationHandle(), 0); // load from flash
HomeLocationSetGet(&homeSetFlash);
}
// work on hott telemetry. endless loop. // work on hott telemetry. endless loop.
while (1) { while (1) {
// clear message size on every loop before processing // clear message size on every loop before processing
@ -742,8 +749,7 @@ uint8_t build_TEXT_message(struct hott_text_message *msg, uint8_t page, uint8_t
RevoSettingsFusionAlgorithmOptions revoFusionAlgo; RevoSettingsFusionAlgorithmOptions revoFusionAlgo;
FlightBatterySettingsSensorCalibrationsData battSensorCalibration; FlightBatterySettingsSensorCalibrationsData battSensorCalibration;
uint32_t battSensorCapacity; uint32_t battSensorCapacity;
HomeLocationData home; HomeLocationSetOptions homeSet;
HomeLocationSetOptions homeSetFlash;
GPSSettingsData gpsSettings; GPSSettingsData gpsSettings;
uint8_t adcRouting[HWSETTINGS_ADCROUTING_NUMELEM]; uint8_t adcRouting[HWSETTINGS_ADCROUTING_NUMELEM];
uint8_t sensorRedirect[HOTTBRIDGESETTINGS_SENSORREDIRECT_NUMELEM]; uint8_t sensorRedirect[HOTTBRIDGESETTINGS_SENSORREDIRECT_NUMELEM];
@ -1073,10 +1079,7 @@ uint8_t build_TEXT_message(struct hott_text_message *msg, uint8_t page, uint8_t
GPSSettingsGet(&gpsSettings); GPSSettingsGet(&gpsSettings);
} }
if (HomeLocationHandle() != NULL) { if (HomeLocationHandle() != NULL) {
HomeLocationGet(&home); HomeLocationSetGet(&homeSet);
UAVObjLoad(HomeLocationHandle(), 0); // load from flash
HomeLocationSetGet(&homeSetFlash);
HomeLocationSet(&home); // Restore previous home location from RAM
} }
bool edit_savehome = (edit_mode && (current_line == 2)); bool edit_savehome = (edit_mode && (current_line == 2));
@ -1100,7 +1103,7 @@ uint8_t build_TEXT_message(struct hott_text_message *msg, uint8_t page, uint8_t
GPSSettingsSet(&gpsSettings); GPSSettingsSet(&gpsSettings);
} }
char *home_set_status = (homeSetFlash == HOMELOCATION_SET_FALSE) ? ((home.Set == HOMELOCATION_SET_TRUE) ? "ISSET" : " ?") : "FIXED"; char *home_set_status = (homeSetFlash == HOMELOCATION_SET_FALSE) ? ((homeSet == HOMELOCATION_SET_TRUE) ? "ISSET" : " ?") : "FIXED";
snprintf(msg->text[1], HOTT_TEXT_COLUMNS, " Home status %s ", home_set_status); // line 2 snprintf(msg->text[1], HOTT_TEXT_COLUMNS, " Home status %s ", home_set_status); // line 2
snprintf(msg->text[2], HOTT_TEXT_COLUMNS, " Min satellites %d ", gpsSettings.MinSatellites); // line 3 snprintf(msg->text[2], HOTT_TEXT_COLUMNS, " Min satellites %d ", gpsSettings.MinSatellites); // line 3
@ -1117,9 +1120,9 @@ uint8_t build_TEXT_message(struct hott_text_message *msg, uint8_t page, uint8_t
} }
if (edit_savehome) { if (edit_savehome) {
if (home.Set == HOMELOCATION_SET_TRUE) { if (homeSet == HOMELOCATION_SET_TRUE) {
home.Set = HOMELOCATION_SET_FALSE; homeSet = HOMELOCATION_SET_FALSE;
HomeLocationSet(&home); HomeLocationSetSet(&homeSet);
} }
// refresh fixed homelocation if any // refresh fixed homelocation if any
if (homeSetFlash == HOMELOCATION_SET_TRUE) { if (homeSetFlash == HOMELOCATION_SET_TRUE) {