Fix GVar adjust mode

This commit is contained in:
Raphael Coeffic
2021-11-10 11:07:04 +01:00
parent ca31c275bd
commit 26c5c2b3d4
3 changed files with 40 additions and 1 deletions
@@ -733,6 +733,13 @@ const char* _func_sound_lookup[] = {
// 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);
bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
yaml_writer_func wf, void* opaque)
{
@@ -818,6 +825,11 @@ bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
break;
case FUNC_ADJUST_GVAR:
// 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:
case FUNC_ADJUST_GVAR_INCDEC:
@@ -77,6 +77,9 @@ namespace yaml_conv_220 {
extern const char* _func_reset_param_lookup[];
extern const char* _func_failsafe_lookup[];
extern const char* _adjust_gvar_mode_lookup[];
extern const uint8_t _adjust_gvar_mode_lookup_size;
bool w_zov_source(void* user, uint8_t* data, uint32_t bitoffs,
yaml_writer_func wf, void* opaque);
@@ -1171,6 +1174,20 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
break;
case FUNC_ADJUST_GVAR:
// 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)) {
CFN_GVAR_MODE(cfn) = i;
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:
case FUNC_ADJUST_GVAR_INCDEC:
@@ -1306,6 +1323,11 @@ static bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
break;
case FUNC_ADJUST_GVAR:
// 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:
case FUNC_ADJUST_GVAR_INCDEC:
+6 -1
View File
@@ -445,7 +445,12 @@ TEST(Conversions, ConversionTX16SFrom25)
EXPECT_EQ(-SWSRC_SE0, g_model.customFn[0].swtch);
EXPECT_EQ(FUNC_OVERRIDE_CHANNEL, g_model.customFn[0].func);
EXPECT_EQ(-100, CFN_PARAM(&(g_model.customFn[0])));
EXPECT_EQ(SWSRC_TrimThrUp, g_model.customFn[1].swtch);
EXPECT_EQ(FUNC_ADJUST_GVAR, g_model.customFn[1].func);
EXPECT_EQ(FUNC_ADJUST_GVAR_INCDEC, CFN_GVAR_MODE(&(g_model.customFn[1])));
EXPECT_EQ(5, CFN_PARAM(&(g_model.customFn[1])));
const auto& top_widget = g_model.topbarData.zones[3];
EXPECT_STRNEQ("Value", top_widget.widgetName);