From 16e00b5dd935335e46818822d8de8b8d394104a1 Mon Sep 17 00:00:00 2001 From: philmoz Date: Sat, 28 Oct 2023 18:19:08 +1100 Subject: [PATCH] Fix rebase. --- .../edgetx/yaml_customfunctiondata.cpp | 11 +---- radio/src/functions.cpp | 2 +- .../gui/128x64/model_special_functions.cpp | 3 +- .../gui/212x64/model_special_functions.cpp | 3 +- radio/src/gui/colorlcd/special_functions.cpp | 42 +++++++++---------- radio/src/myeeprom.h | 2 +- 6 files changed, 24 insertions(+), 39 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp index 64491429607..e35ba46fd6b 100644 --- a/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp +++ b/companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp @@ -23,15 +23,6 @@ #include "yaml_rawsource.h" #include "eeprominterface.h" -static bool fnHasEnable(AssignFunc fn) -{ - return (fn <= FuncInstantTrim) - || (fn >= FuncReset && fn <= FuncSetTimerLast) - || (fn >= FuncAdjustGV1 && fn <= FuncBindExternalModule) - || (fn == FuncVolume) - || (fn == FuncBacklight); -} - static bool fnHasRepeat(AssignFunc fn) { return (fn == FuncPlayPrompt) @@ -235,7 +226,7 @@ Node convert::encode(const CustomFunctionData& rhs) if(fnHasRepeat(rhs.func)) { def += ","; - if (rhs.func == FuncPlayScript || rhs.func == FuncRGBLed)) { + if (rhs.func == FuncPlayScript || rhs.func == FuncRGBLed) { def += ((rhs.repeatParam == 0) ? "On" : "1x"); } else if (rhs.repeatParam == 0) { def += "1x"; diff --git a/radio/src/functions.cpp b/radio/src/functions.cpp index 4e3b1753ca5..812945b04f8 100644 --- a/radio/src/functions.cpp +++ b/radio/src/functions.cpp @@ -114,7 +114,7 @@ bool isRepeatDelayElapsed(const CustomFunctionData * functions, CustomFunctionsC { const CustomFunctionData * cfn = &functions[index]; tmr10ms_t tmr10ms = get_tmr10ms(); - uint8_t repeatParam = CFN_PLAY_REPEAT(cfn); + int8_t repeatParam = CFN_PLAY_REPEAT(cfn); if (!IS_SILENCE_PERIOD_ELAPSED() && repeatParam == CFN_PLAY_REPEAT_NOSTART) { functionsContext.lastFunctionTime[index] = tmr10ms; } diff --git a/radio/src/gui/128x64/model_special_functions.cpp b/radio/src/gui/128x64/model_special_functions.cpp index de1ea3ee7b1..4a41615c279 100644 --- a/radio/src/gui/128x64/model_special_functions.cpp +++ b/radio/src/gui/128x64/model_special_functions.cpp @@ -195,7 +195,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF switch (j) { case 0: if (sub==k && menuHorizontalPosition < 1 && CFN_SWITCH(cfn) == SWSRC_NONE) { - CFN_ACTIVE(cfn) = 1; + CFN_ACTIVE(cfn) = 0; // Default is disabled drawSwitch(MODEL_SPECIAL_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | INVERS | ((functionsContext->activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); if (active) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); } @@ -214,7 +214,6 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF if (active) { CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); if (checkIncDec_Ret) CFN_RESET(cfn); - CFN_ACTIVE(cfn) = 1; // Enable if function is being changed } } else { diff --git a/radio/src/gui/212x64/model_special_functions.cpp b/radio/src/gui/212x64/model_special_functions.cpp index dc12e1ff894..7baedbc6075 100644 --- a/radio/src/gui/212x64/model_special_functions.cpp +++ b/radio/src/gui/212x64/model_special_functions.cpp @@ -187,7 +187,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF uint8_t active = (attr && s_editMode>0); switch (j) { case ITEM_CUSTOM_FUNCTIONS_SWITCH: - if(CFN_SWITCH(cfn) == SWSRC_NONE) CFN_ACTIVE(cfn) = 1; // Enable new function by default + if(CFN_SWITCH(cfn) == SWSRC_NONE) CFN_ACTIVE(cfn) = 0; // Disable new function by default drawSwitch(MODEL_SPECIAL_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext->activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); if (func == FUNC_OVERRIDE_CHANNEL && functions != g_model.customFn) { @@ -201,7 +201,6 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF if (active) { func = CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); if (checkIncDec_Ret) CFN_RESET(cfn); - CFN_ACTIVE(cfn) = 1; // Enable if function is being changed } } else { diff --git a/radio/src/gui/colorlcd/special_functions.cpp b/radio/src/gui/colorlcd/special_functions.cpp index 5a98ae7ea0e..20b2056ce45 100644 --- a/radio/src/gui/colorlcd/special_functions.cpp +++ b/radio/src/gui/colorlcd/special_functions.cpp @@ -328,7 +328,6 @@ class SpecialFunctionEditPage : public Page } } - if (HAS_REPEAT_PARAM(func)) { // !1x 1x 1s 2s 3s ... line = specialFunctionOneWindow->newLine(&grid); new StaticText(line, rect_t{}, STR_REPEAT, @@ -359,7 +358,7 @@ class SpecialFunctionEditPage : public Page line = specialFunctionOneWindow->newLine(&grid); new StaticText(line, rect_t{}, STR_ENABLE, 0, COLOR_THEME_PRIMARY1); - new CheckBox(line, rect_t{}, GET_SET_DEFAULT(CFN_ACTIVE(cfn))); + new ToggleSwitch(line, rect_t{}, GET_SET_DEFAULT(CFN_ACTIVE(cfn))); } @@ -376,9 +375,9 @@ class SpecialFunctionEditPage : public Page CustomFunctionData *cfn = &functions[index]; - // Set new function to "enabled" by default - if (!CFN_SWITCH(cfn)) - CFN_ACTIVE(cfn) = true; + // Set new function to "disabled" by default + if (!CFN_SWITCH(cfn)) + CFN_ACTIVE(cfn) = false; // Switch auto line = form->newLine(&grid); @@ -416,7 +415,6 @@ class SpecialFunctionEditPage : public Page functionChoice->setSetValueHandler([=](int32_t newValue) { CFN_FUNC(cfn) = newValue; CFN_RESET(cfn); - CFN_ACTIVE(cfn) = 1; SET_DIRTY(); updateSpecialFunctionOneWindow(); }); @@ -521,9 +519,9 @@ class SpecialFunctionButton : public Button lv_obj_set_grid_cell(sfRepeat, LV_GRID_ALIGN_CENTER, FUNC_COL+1, 1, LV_GRID_ALIGN_CENTER, 0, NM_ROW_CNT); sfEnable = lv_obj_create(lvobj); - lv_obj_set_size(sfEnable, 16, 16); - lv_obj_set_style_border_width(sfEnable, 2, 0); - lv_obj_set_style_border_color(sfEnable, makeLvColor(COLOR_THEME_SECONDARY1), 0); + lv_obj_set_size(sfEnable, 22, 22); + lv_obj_set_style_border_width(sfEnable, 3, 0); + lv_obj_set_style_border_color(sfEnable, makeLvColor(COLOR_THEME_PRIMARY2), 0); lv_obj_set_style_border_opa(sfEnable, LV_OPA_100, 0); lv_obj_set_style_bg_color(sfEnable, makeLvColor(COLOR_THEME_ACTIVE), LV_STATE_CHECKED); lv_obj_set_style_bg_opa(sfEnable, LV_OPA_100, 0); @@ -870,20 +868,18 @@ void SpecialFunctionsPage::build(FormWindow *window) } CustomFunctionData *cfn = &functions[i]; uint8_t func = CFN_FUNC(cfn); - if (HAS_ENABLE_PARAM(func)) { - if (CFN_ACTIVE(cfn)) { - menu->addLine(STR_DISABLE, [=]() { - CFN_ACTIVE(cfn) = 0; - SET_DIRTY(); - rebuild(window); - }); - } else { - menu->addLine(STR_ENABLE, [=]() { - CFN_ACTIVE(cfn) = 1; - SET_DIRTY(); - rebuild(window); - }); - } + if (CFN_ACTIVE(cfn)) { + menu->addLine(STR_DISABLE, [=]() { + CFN_ACTIVE(cfn) = 0; + SET_DIRTY(); + rebuild(window); + }); + } else { + menu->addLine(STR_ENABLE, [=]() { + CFN_ACTIVE(cfn) = 1; + SET_DIRTY(); + rebuild(window); + }); } if (functions[MAX_SPECIAL_FUNCTIONS - 1].isEmpty()) { for (int j = i; j < MAX_SPECIAL_FUNCTIONS; j++) { diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 10899c99205..85d2c999618 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -75,7 +75,7 @@ #define CFN_TIMER_INDEX(p) ((p)->all.param) #define CFN_PLAY_REPEAT(p) ((p)->repeat) #define CFN_PLAY_REPEAT_MUL 1 -#define CFN_PLAY_REPEAT_NOSTART 0xFF +#define CFN_PLAY_REPEAT_NOSTART -1 #define CFN_GVAR_MODE(p) ((p)->all.mode) #define CFN_PARAM(p) ((p)->all.val) #define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)