1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-23 16:25:12 +03:00
This commit is contained in:
Bertrand Songis 2015-08-31 21:37:41 +02:00
parent 771206e1b2
commit 6374f52585
14 changed files with 107 additions and 15 deletions

View file

@ -121,6 +121,35 @@ void onCustomFunctionsMenu(const char *result)
}
}
void onAdjustGvarSourceLongEnterPress(const char * result)
{
CustomFunctionData * cfn = &g_model.customFn[m_posVert];
if (result == STR_CONSTANT) {
CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_CONSTANT;
CFN_PARAM(cfn) = 0;
eeDirty(EE_MODEL);
}
else if (result == STR_MIXSOURCE) {
CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_SOURCE;
CFN_PARAM(cfn) = 0;
eeDirty(EE_MODEL);
}
else if (result == STR_GLOBALVAR) {
CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_GVAR;
CFN_PARAM(cfn) = 0;
eeDirty(EE_MODEL);
}
else if (result == STR_INCDEC) {
CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_INC;
CFN_PARAM(cfn) = 0;
eeDirty(EE_MODEL);
}
else {
onSourceLongEnterPress(result);
}
}
void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext)
{
int sub = m_posVert;
@ -325,8 +354,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
case FUNC_ADJUST_GVAR_SOURCE:
val_max = MIXSRC_LAST_CH;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
// TODO later, we have a conflict on [Enter Long] here ...
// INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
INCDEC_ENABLE_CHECK(isSourceAvailable);
break;
case FUNC_ADJUST_GVAR_GVAR:
@ -334,27 +362,39 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr);
break;
default: // FUNC_ADJUST_GVAR_INC
#if 0 // TODO 2.2.X
val_min = -100; val_max = +100;
if (val_displayed < 0)
lcd_putsAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "-=", attr);
else
lcd_putsAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "+=", attr);
lcd_outdezAtt(lcdNextPos, y, abs(val_displayed), attr|LEFT);
#endif
val_max = 1;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr);
break;
}
if (attr && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
s_editMode = !s_editMode;
active = true;
CFN_GVAR_MODE(cfn) += 1;
CFN_GVAR_MODE(cfn) &= 0x03;
val_displayed = 0;
}
}
#endif
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
}
if (active) {
if (active || event==EVT_KEY_LONG(KEY_ENTER)) {
CFN_PARAM(cfn) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max);
if (attr && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_CONSTANT)
MENU_ADD_ITEM(STR_CONSTANT);
if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_SOURCE)
MENU_ADD_ITEM(STR_MIXSOURCE);
if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_GVAR)
MENU_ADD_ITEM(STR_GLOBALVAR);
if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_INC)
MENU_ADD_ITEM(STR_INCDEC);
menuHandler = onAdjustGvarSourceLongEnterPress;
s_editMode = EDIT_MODIFY_FIELD;
}
}
break;
}