Use symbolic indexes for calibration data

Resolves #1083
This commit is contained in:
Raphael Coeffic
2021-11-26 17:31:57 +01:00
parent 5d5ceb4d88
commit 06c04c852a
32 changed files with 67 additions and 29 deletions
@@ -451,6 +451,26 @@ static uint8_t select_sensor_cfg(void* user, uint8_t* data, uint32_t bitoffs)
return yaml_conv_220::select_sensor_cfg(user, data, bitoffs);
}
static uint32_t r_calib(void* user, const char* val, uint8_t val_len)
{
(void)user;
uint32_t sw = yaml_parse_enum(enum_MixSources, val, val_len);
if (sw >= MIXSRC_Rud) return sw - MIXSRC_Rud;
return (uint32_t)yaml_str2int(val, val_len);
}
static bool w_calib(void* user, yaml_writer_func wf, void* opaque)
{
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
uint16_t idx = tw->getElmts();
const char* str =
yaml_output_enum(idx + MIXSRC_Rud, enum_MixSources);
return str ? wf(opaque, str, strlen(str)) : true;
}
static uint32_t sw_read(void* user, const char* val, uint8_t val_len)
{
(void)user;