AP_Param: added get_param_by_index

useful for parameter conversion within an object
This commit is contained in:
Andrew Tridgell 2021-02-27 20:53:34 +11:00
parent 5ef31a1801
commit 7b98ab0f12
2 changed files with 22 additions and 0 deletions

View File

@ -1034,6 +1034,21 @@ bool AP_Param::find_top_level_key_by_pointer(const void *ptr, uint16_t &key)
return false;
}
/*
fetch a parameter value based on the index within a group. This
is used to find the old value of a parameter that has been
removed from an object.
*/
bool AP_Param::get_param_by_index(void *obj_ptr, uint8_t idx, ap_var_type old_ptype, void *pvalue)
{
uint16_t key;
if (!find_top_level_key_by_pointer(obj_ptr, key)) {
return false;
}
const ConversionInfo type_info = {key, idx, old_ptype, nullptr };
return AP_Param::find_old_parameter(&type_info, (AP_Param *)pvalue);
}
// Find a object by name.
//

View File

@ -440,6 +440,13 @@ public:
static void convert_parent_class(uint8_t param_key, void *object_pointer,
const struct AP_Param::GroupInfo *group_info);
/*
fetch a parameter value based on the index within a group. This
is used to find the old value of a parameter that has been
removed from an object.
*/
static bool get_param_by_index(void *obj_ptr, uint8_t idx, ap_var_type old_ptype, void *pvalue);
/// Erase all variables in EEPROM.
///
static void erase_all(void);