Skip to content

Commit

Permalink
Fix rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Oct 28, 2023
1 parent 11ac949 commit 16e00b5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 39 deletions.
11 changes: 1 addition & 10 deletions companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -235,7 +226,7 @@ Node convert<CustomFunctionData>::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";
Expand Down
2 changes: 1 addition & 1 deletion radio/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions radio/src/gui/128x64/model_special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions radio/src/gui/212x64/model_special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
42 changes: 19 additions & 23 deletions radio/src/gui/colorlcd/special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)));

}

Expand All @@ -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);
Expand Down Expand Up @@ -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();
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion radio/src/myeeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 16e00b5

Please sign in to comment.