Use full custom to cope with the strange trainer mode defs

This commit is contained in:
Raphael Coeffic
2021-11-10 11:07:01 +01:00
parent 61e837f0b7
commit bcc1f55b37
16 changed files with 64 additions and 177 deletions
@@ -689,3 +689,39 @@ static bool w_vPitch(const YamlNode* node, uint32_t val, yaml_writer_func wf, vo
return wf(opaque, s, strlen(s));
}
const struct YamlIdStr enum_TrainerMode[] = {
#if defined(PCBNV14)
{ TRAINER_MODE_OFF, "OFF" },
#endif
{ TRAINER_MODE_MASTER_TRAINER_JACK, "MASTER_TRAINER_JACK" },
{ TRAINER_MODE_SLAVE, "SLAVE" },
#if defined(PCBTARANIS) || defined(PCBNV14)
{ TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE, "MASTER_SBUS_EXT" },
{ TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, "MASTER_CPPM_EXT" },
#endif
#if defined(PCBTARANIS) || defined(AUX_SERIAL) || defined(AUX2_SERIAL)
{ TRAINER_MODE_MASTER_BATTERY_COMPARTMENT, "MASTER_BATT_COMP" },
#endif
{ TRAINER_MODE_MASTER_BLUETOOTH, "MASTER_BT" },
{ TRAINER_MODE_SLAVE_BLUETOOTH, "SLAVE_BT" },
{ TRAINER_MODE_MULTI, "MASTER_MULTI" },
{ 0, NULL }
};
static uint32_t r_trainerMode(const YamlNode* node, const char* val, uint8_t val_len)
{
return yaml_parse_enum(enum_TrainerMode, val, val_len);
}
static bool w_trainerMode(const YamlNode* node, uint32_t val,
yaml_writer_func wf, void* opaque)
{
const char* str = nullptr;
str = yaml_output_enum(val, enum_TrainerMode);
if (str) {
return wf(opaque, str, strlen(str));
}
return true;
}