[Radio] Adjust value limits for mix sources and update UI for LSs, CFs & telem. (#5445)

* [firmware][ARM] Adjust some value limits for mix sources and update editing UI for LSs, CFs, & telem. bars:
    * Increase timer limits to +/-8:59:59 when used with LSs, CFs, & bars;
    * Increase Lua script output limits to +/-30K;
    * Trim limits based on extended limit model setting;
    * Limit TX voltage to 25.5;
    * Limit TX time comparison value to 29:59m;
    * Use proper GVar limits (user-configured), display precision, & unit in LSs & telem. bars;
    * Display timer values properly with hours (instead of mmm:ss).

* [firmware] getTimerString() would fail with times >= 100min if hours weren't shown.

* Fix builds w/out GVars.
This commit is contained in:
Max Paperno
2017-12-19 12:17:12 +01:00
committed by Bertrand Songis
parent 716a91fc0c
commit b69f36afe4
11 changed files with 134 additions and 101 deletions
+12 -12
View File
@@ -195,18 +195,18 @@ void menuModelDisplay(event_t event)
if (IS_BARS_SCREEN(screenIndex)) {
FrSkyBarData & bar = g_model.frsky.screens[screenIndex].bars[lineIndex];
source_t barSource = bar.source;
drawSource(DISPLAY_COL1, y, barSource, menuHorizontalPosition==0 ? attr : 0);
int barMax = getMaximumValue(barSource);
int barMin = -barMax;
if (barSource) {
if (barSource <= MIXSRC_LAST_CH) {
drawSourceCustomValue(DISPLAY_COL2, y, barSource, calc100toRESX(bar.barMin), (menuHorizontalPosition==1 ? attr : 0) | LEFT);
drawSourceCustomValue(DISPLAY_COL3, y, barSource, calc100toRESX(bar.barMax), (menuHorizontalPosition==2 ? attr : 0) | LEFT);
drawSource(DISPLAY_COL1, y, bar.source, menuHorizontalPosition==0 ? attr : 0);
int16_t barMax, barMin;
LcdFlags lf = LEFT;
getMixSrcRange(bar.source, barMin, barMax, &lf);
if (bar.source) {
if (bar.source <= MIXSRC_LAST_CH) {
drawSourceCustomValue(DISPLAY_COL2, y, bar.source, calc100toRESX(bar.barMin), (menuHorizontalPosition==1 ? attr : 0) | lf);
drawSourceCustomValue(DISPLAY_COL3, y, bar.source, calc100toRESX(bar.barMax), (menuHorizontalPosition==2 ? attr : 0) | lf);
}
else {
drawSourceCustomValue(DISPLAY_COL2, y, barSource, bar.barMin, (menuHorizontalPosition==1 ? attr : 0) | LEFT);
drawSourceCustomValue(DISPLAY_COL3, y, barSource, bar.barMax, (menuHorizontalPosition==2 ? attr : 0) | LEFT);
drawSourceCustomValue(DISPLAY_COL2, y, bar.source, bar.barMin, (menuHorizontalPosition==1 ? attr : 0) | lf);
drawSourceCustomValue(DISPLAY_COL3, y, bar.source, bar.barMax, (menuHorizontalPosition==2 ? attr : 0) | lf);
}
}
else if (attr) {
@@ -215,9 +215,9 @@ void menuModelDisplay(event_t event)
if (attr && s_editMode>0) {
switch (menuHorizontalPosition) {
case 0:
bar.source = checkIncDec(event, barSource, 0, MIXSRC_LAST_TELEM, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable);
bar.source = checkIncDec(event, bar.source, 0, MIXSRC_LAST_TELEM, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable);
if (checkIncDec_Ret) {
if (barSource <= MIXSRC_LAST_CH) {
if (bar.source <= MIXSRC_LAST_CH) {
bar.barMin = -100;
bar.barMax = 100;
}
@@ -115,9 +115,10 @@ void menuModelLogicalSwitches(event_t event)
// CSW params
unsigned int cstate = lswFamily(cs->func);
int v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM;
int v2_min=0, v2_max=MIXSRC_LAST_TELEM;
int v3_min=-1, v3_max=100;
int v1_val = cs->v1;
int16_t v1_min = 0, v1_max = MIXSRC_LAST_TELEM;
int16_t v2_min = 0, v2_max = MIXSRC_LAST_TELEM;
int16_t v3_min =-1, v3_max = 100;
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
drawSwitch(CSW_2ND_COLUMN, y, cs->v1, attr1);
@@ -168,14 +169,9 @@ void menuModelLogicalSwitches(event_t event)
INCDEC_SET_FLAG(EE_MODEL);
INCDEC_ENABLE_CHECK(NULL);
}
v2_max = getMaximumValue(v1_val);
v2_min = - v2_max;
if (v1_val <= MIXSRC_LAST_CH) {
drawSourceCustomValue(CSW_3RD_COLUMN, y, v1_val, calc100toRESX(cs->v2), LEFT|attr2);
}
else {
drawSourceCustomValue(CSW_3RD_COLUMN, y, v1_val, cs->v2, LEFT|attr2);
}
LcdFlags lf = attr2 | LEFT;
getMixSrcRange(v1_val, v2_min, v2_max, &lf);
drawSourceCustomValue(CSW_3RD_COLUMN, y, v1_val, (v1_val <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2), lf);
}
// CSW AND switch
@@ -258,7 +258,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
#if defined(OVERRIDE_CHANNEL_FUNCTION)
else if (func == FUNC_OVERRIDE_CHANNEL) {
val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT;
getMixSrcRange(MIXSRC_FIRST_CH, val_min, val_max);
lcdDrawNumber(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
}
#endif
@@ -267,7 +267,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
lcdDrawTextAtIndex(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr);
}
else if (func == FUNC_SET_TIMER) {
val_max = 539*60+59; //8:59:59
getMixSrcRange(MIXSRC_FIRST_TIMER, val_min, val_max);
drawTimer(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT|TIMEHOUR, attr);
}
else if (func == FUNC_PLAY_SOUND) {
@@ -345,11 +345,9 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
switch (CFN_GVAR_MODE(cfn)) {
case FUNC_ADJUST_GVAR_CONSTANT:
{
uint8_t gvar_index = CFN_GVAR_INDEX(cfn);
val_displayed = (int16_t)CFN_PARAM(cfn);
val_min = max<int16_t>(CFN_GVAR_CST_MIN, MODEL_GVAR_MIN(gvar_index));
val_max = min<int16_t>(CFN_GVAR_CST_MAX, MODEL_GVAR_MAX(gvar_index));
drawGVarValue(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, gvar_index, val_displayed, attr|LEFT);
getMixSrcRange(CFN_GVAR_INDEX(cfn) + MIXSRC_FIRST_GVAR, val_min, val_max);
drawGVarValue(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, CFN_GVAR_INDEX(cfn), val_displayed, attr|LEFT);
break;
}
case FUNC_ADJUST_GVAR_SOURCE:
@@ -365,12 +363,10 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
drawStringWithIndex(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr);
break;
default: // FUNC_ADJUST_GVAR_INC
val_min = -100; val_max = +100;
if (val_displayed < 0)
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, "-= ", attr);
else
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, "+= ", attr);
getMixSrcRange(CFN_GVAR_INDEX(cfn) + MIXSRC_FIRST_GVAR, val_min, val_max);
lcdDrawText(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, (val_displayed < 0 ? "-= " : "+= "), attr);
drawGVarValue(lcdNextPos, y, CFN_GVAR_INDEX(cfn), abs(val_displayed), attr|LEFT);
break;
}
}
#endif