From 046b00888997576373f9928203278ccbf78ee938 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 6 Oct 2015 20:54:24 +1100 Subject: [PATCH] AP_Param: send saved param values to all GCS --- libraries/AP_Param/AP_Param.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libraries/AP_Param/AP_Param.cpp b/libraries/AP_Param/AP_Param.cpp index b008d06b0e..b366c4a96a 100644 --- a/libraries/AP_Param/AP_Param.cpp +++ b/libraries/AP_Param/AP_Param.cpp @@ -29,6 +29,7 @@ #include #include #include +#include // for send_parameter_value_all #include #include @@ -707,11 +708,16 @@ bool AP_Param::save(bool force_save) ap = (const AP_Param *)((uintptr_t)ap) - (idx*sizeof(float)); } + char name[AP_MAX_NAME_SIZE+1]; + copy_name_info(info, ginfo, idx, name, sizeof(name), true); + // scan EEPROM to find the right location uint16_t ofs; if (scan(&phdr, &ofs)) { // found an existing copy of the variable eeprom_write_check(ap, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type)); + GCS_MAVLINK::send_parameter_value_all(name, (enum ap_var_type)info->type, + cast_to_float((enum ap_var_type)phdr.type)); return true; } if (ofs == (uint16_t) ~0) { @@ -728,12 +734,14 @@ bool AP_Param::save(bool force_save) v2 = get_default_value(&info->def_value); } if (is_equal(v1,v2) && !force_save) { + GCS_MAVLINK::send_parameter_value_all(name, (enum ap_var_type)info->type, v2); return true; } if (phdr.type != AP_PARAM_INT32 && (fabsf(v1-v2) < 0.0001f*fabsf(v1))) { // for other than 32 bit integers, we accept values within // 0.01 percent of the current value as being the same + GCS_MAVLINK::send_parameter_value_all(name, (enum ap_var_type)info->type, v2); return true; } } @@ -748,6 +756,8 @@ bool AP_Param::save(bool force_save) write_sentinal(ofs + sizeof(phdr) + type_size((enum ap_var_type)phdr.type)); eeprom_write_check(ap, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type)); eeprom_write_check(&phdr, ofs, sizeof(phdr)); + GCS_MAVLINK::send_parameter_value_all(name, (enum ap_var_type)info->type, + cast_to_float((enum ap_var_type)phdr.type)); return true; }