Merge pull request #1160 from EdgeTX/fix-yaml-gvars
Fix YAML for all GVAR adjustements custom functions
This commit is contained in:
@@ -749,6 +749,7 @@ PACK(struct StepsCalibData {
|
||||
#endif
|
||||
|
||||
PACK(struct CalibData {
|
||||
CUST_IDX(calib, r_calib, w_calib);
|
||||
int16_t mid;
|
||||
int16_t spanNeg;
|
||||
int16_t spanPos;
|
||||
@@ -837,7 +838,7 @@ PACK(struct RadioData {
|
||||
// Real attributes
|
||||
NOBACKUP(uint8_t version);
|
||||
NOBACKUP(uint16_t variant SKIP);
|
||||
CalibData calib[NUM_STICKS + STORAGE_NUM_POTS + STORAGE_NUM_SLIDERS + STORAGE_NUM_MOUSE_ANALOGS];
|
||||
CalibData calib[NUM_STICKS + STORAGE_NUM_POTS + STORAGE_NUM_SLIDERS + STORAGE_NUM_MOUSE_ANALOGS] NO_IDX;
|
||||
NOBACKUP(uint16_t chkSum SKIP);
|
||||
N_HORUS_FIELD(int8_t currModel);
|
||||
N_HORUS_FIELD(uint8_t contrast);
|
||||
|
||||
@@ -262,6 +262,18 @@ uint8_t select_sensor_cfg(void* user, uint8_t* data, uint32_t bitoffs)
|
||||
return 5;
|
||||
}
|
||||
|
||||
#define r_calib nullptr
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool sw_write(void* user, yaml_writer_func wf, void* opaque)
|
||||
{
|
||||
auto tw = reinterpret_cast<YamlTreeWalker*>(user);
|
||||
@@ -724,21 +736,20 @@ const char* _func_failsafe_lookup[] = {
|
||||
};
|
||||
|
||||
// used in read routine as well
|
||||
extern const char* _func_sound_lookup[];
|
||||
const char* _func_sound_lookup[] = {
|
||||
"Bp1","Bp2","Bp3","Wrn1","Wrn2",
|
||||
"Chee","Rata","Tick","Sirn","Ring",
|
||||
"SciF","Robt","Chrp","Tada","Crck","Alrm"
|
||||
};
|
||||
extern const uint8_t _func_sound_lookup_size = 16;
|
||||
|
||||
// force external linkage
|
||||
extern const uint8_t _func_sound_lookup_size = sizeof(_func_sound_lookup);
|
||||
|
||||
extern const char* _adjust_gvar_mode_lookup[];
|
||||
const char* _adjust_gvar_mode_lookup[] = {
|
||||
"Cst", "Src", "GVar", "IncDec"
|
||||
};
|
||||
|
||||
extern const uint8_t _adjust_gvar_mode_lookup_size = sizeof(_adjust_gvar_mode_lookup);
|
||||
extern const uint8_t _adjust_gvar_mode_lookup_size = 4;
|
||||
|
||||
bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
yaml_writer_func wf, void* opaque)
|
||||
@@ -812,6 +823,9 @@ bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
// Tmr1,Tmr2,Tmr3
|
||||
str = _func_reset_param_lookup[CFN_TIMER_INDEX(cfn)];
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
str = yaml_unsigned2str(CFN_PARAM(cfn));
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
break;
|
||||
|
||||
case FUNC_SET_FAILSAFE:
|
||||
@@ -827,10 +841,15 @@ bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
|
||||
case FUNC_ADJUST_GVAR:
|
||||
str = yaml_unsigned2str(CFN_GVAR_INDEX(cfn)); // GVAR index
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
|
||||
// output CFN_GVAR_MODE
|
||||
str = _adjust_gvar_mode_lookup[CFN_GVAR_MODE(cfn)];
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
|
||||
// output param
|
||||
switch(CFN_GVAR_MODE(cfn)) {
|
||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||
|
||||
@@ -286,7 +286,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -307,7 +307,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -307,7 +307,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -283,7 +283,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -322,7 +322,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -263,7 +263,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -271,7 +271,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -268,7 +268,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -270,7 +270,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -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;
|
||||
@@ -1150,7 +1170,20 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
&& val[2] == 'r'
|
||||
&& val[3] >= '1'
|
||||
&& val[3] <= '3') {
|
||||
|
||||
CFN_TIMER_INDEX(cfn) = val[3] - '1';
|
||||
|
||||
val += 4; val_len -= 4;
|
||||
if (val_len == 0 || val[0] != ',') return;
|
||||
val++; val_len--;
|
||||
|
||||
CFN_PARAM(cfn) = yaml_str2uint_ref(val, val_len);
|
||||
if (val_len == 0 || val[0] != ',') return;
|
||||
val++; val_len--;
|
||||
|
||||
eat_comma = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1174,7 +1207,16 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
CFN_PARAM(cfn) = yaml_str2uint(val, l_sep);
|
||||
break;
|
||||
|
||||
case FUNC_ADJUST_GVAR:
|
||||
case FUNC_ADJUST_GVAR: {
|
||||
|
||||
CFN_GVAR_INDEX(cfn) = yaml_str2int_ref(val, l_sep);
|
||||
if (val_len == 0 || val[0] != ',') return;
|
||||
val++; val_len--;
|
||||
|
||||
// find "," and cut val_len
|
||||
sep = (const char *)memchr(val, ',', val_len);
|
||||
l_sep = sep ? sep - val : val_len;
|
||||
|
||||
// parse CFN_GVAR_MODE
|
||||
for (int i=0; i < yaml_conv_220::_adjust_gvar_mode_lookup_size; i++) {
|
||||
if (!strncmp(yaml_conv_220::_adjust_gvar_mode_lookup[i],val,l_sep)) {
|
||||
@@ -1182,12 +1224,14 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
val += l_sep; val_len -= l_sep;
|
||||
if (val_len == 0 || val[0] != ',') return;
|
||||
val++; val_len--;
|
||||
// find "," and cut val_len
|
||||
sep = (const char *)memchr(val, ',', val_len);
|
||||
l_sep = sep ? sep - val : val_len;
|
||||
|
||||
// output param
|
||||
switch(CFN_GVAR_MODE(cfn)) {
|
||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||
@@ -1203,7 +1247,9 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
CFN_PARAM(cfn) = gvar - MIXSRC_FIRST_GVAR;
|
||||
}
|
||||
} break;
|
||||
} break;
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
default:
|
||||
eat_comma = false;
|
||||
@@ -1318,6 +1364,9 @@ static bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
// Tmr1,Tmr2,Tmr3
|
||||
str = yaml_conv_220::_func_reset_param_lookup[CFN_TIMER_INDEX(cfn)];
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
str = yaml_unsigned2str(CFN_PARAM(cfn));
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
break;
|
||||
|
||||
case FUNC_SET_FAILSAFE:
|
||||
@@ -1333,10 +1382,15 @@ static bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
|
||||
case FUNC_ADJUST_GVAR:
|
||||
str = yaml_unsigned2str(CFN_GVAR_INDEX(cfn)); // GVAR index
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
|
||||
// output CFN_GVAR_MODE
|
||||
str = yaml_conv_220::_adjust_gvar_mode_lookup[CFN_GVAR_MODE(cfn)];
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
|
||||
// output param
|
||||
switch(CFN_GVAR_MODE(cfn)) {
|
||||
case FUNC_ADJUST_GVAR_CONSTANT:
|
||||
@@ -1351,6 +1405,7 @@ static bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
if (!w_mixSrcRaw(nullptr, CFN_PARAM(cfn) + MIXSRC_FIRST_GVAR, wf, opaque)) return false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
add_comma = false;
|
||||
|
||||
@@ -286,7 +286,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -309,7 +309,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -307,7 +307,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -276,7 +276,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -283,7 +283,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -322,7 +322,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -263,7 +263,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -271,7 +271,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -268,7 +268,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -270,7 +270,7 @@ const struct YamlIdStr enum_TelemetrySensorType[] = {
|
||||
//
|
||||
|
||||
static const struct YamlNode struct_CalibData[] = {
|
||||
YAML_IDX,
|
||||
YAML_IDX_CUST("calib",r_calib,w_calib),
|
||||
YAML_SIGNED( "mid", 16 ),
|
||||
YAML_SIGNED( "spanNeg", 16 ),
|
||||
YAML_SIGNED( "spanPos", 16 ),
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
int _dummy_##tag[0] _yaml_attribute("raw:YAML_ARRAY(" _yaml_note( \
|
||||
#tag) ", 0, 4, " _yaml_note(elmt_type) ", " _yaml_note(fcn) ")")
|
||||
|
||||
#define CUST_IDX(tag, read, write) \
|
||||
int _dummy_##tag[0] _yaml_attribute("raw:YAML_IDX_CUST(" _yaml_note( \
|
||||
#tag) "," _yaml_note(read) "," _yaml_note(write) ")")
|
||||
|
||||
#else
|
||||
|
||||
#define ENUM(label)
|
||||
@@ -64,6 +68,7 @@
|
||||
#define ARRAY(elmt_size, elmt_type, fcn)
|
||||
#define CUST_ATTR(tag, read, write)
|
||||
#define CUST_ARRAY(tag, elmt_type, fcn)
|
||||
#define CUST_IDX(tag, read, write)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -289,13 +289,13 @@ TEST(Conversions, ConversionX10From23)
|
||||
|
||||
EXPECT_EQ(221, g_eeGeneral.version);
|
||||
|
||||
EXPECT_EQ(100, g_eeGeneral.calib[9].spanNeg);
|
||||
EXPECT_EQ(500, g_eeGeneral.calib[9].mid);
|
||||
EXPECT_EQ(900, g_eeGeneral.calib[9].spanPos);
|
||||
EXPECT_EQ(100, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_LEFT].spanNeg);
|
||||
EXPECT_EQ(500, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_LEFT].mid);
|
||||
EXPECT_EQ(900, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_LEFT].spanPos);
|
||||
|
||||
EXPECT_EQ(200, g_eeGeneral.calib[10].spanNeg);
|
||||
EXPECT_EQ(400, g_eeGeneral.calib[10].mid);
|
||||
EXPECT_EQ(600, g_eeGeneral.calib[10].spanPos);
|
||||
EXPECT_EQ(200, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_RIGHT].spanNeg);
|
||||
EXPECT_EQ(400, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_RIGHT].mid);
|
||||
EXPECT_EQ(600, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_RIGHT].spanPos);
|
||||
|
||||
EXPECT_EQ(-23, g_eeGeneral.vBatMin);
|
||||
EXPECT_EQ(8, g_eeGeneral.speakerVolume);
|
||||
|
||||
Reference in New Issue
Block a user