Curve names used instead of CV<X> when available

This commit is contained in:
Bertrand Songis
2016-01-14 23:13:26 +01:00
parent 0dd15ebbab
commit a1883db889
37 changed files with 114 additions and 108 deletions
+16 -13
View File
@@ -442,7 +442,7 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
putsVolts(x, y, g_vbat100mV, att);
}
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att, const char *prefix)
void drawStringWithIndex(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att, const char *prefix)
{
// TODO quick & dirty, dangerous
char s[32];
@@ -503,9 +503,9 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH)
putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
else if (idx < MIXSRC_CH1)
putsStrIdx(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
drawStringWithIndex(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
else if (idx <= MIXSRC_LAST_CH) {
putsStrIdx(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
drawStringWithIndex(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
#if 0
if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) {
lcdDrawChar(lcdNextPos, y, ' ', att);
@@ -514,7 +514,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
#endif
}
else if (idx <= MIXSRC_LAST_GVAR)
putsStrIdx(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att);
drawStringWithIndex(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att);
else if (idx < MIXSRC_FIRST_TELEM) {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att);
}
@@ -540,7 +540,7 @@ void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att)
uint8_t len = sizeof(g_model.header.name);
while (len>0 && !name[len-1]) --len;
if (len==0) {
putsStrIdx(x, y, STR_MODEL, id+1, att|LEADING0);
drawStringWithIndex(x, y, STR_MODEL, id+1, att|LEADING0);
}
else {
lcdDrawSizedText(x, y, name, sizeof(g_model.header.name), ZCHAR|att);
@@ -629,7 +629,7 @@ void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att);
}
else {
putsStrIdx(x, y, STR_FP, abs(idx)-1, att);
drawStringWithIndex(x, y, STR_FP, abs(idx)-1, att);
}
}
@@ -652,27 +652,30 @@ void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att)
break;
case CURVE_REF_CUSTOM:
putsCurve(x, y, curve.value, att);
drawCurveName(x, y, curve.value, att);
break;
}
}
}
void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att)
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags flags)
{
if (idx == 0) {
return lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att);
return lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, flags);
}
bool neg = false;
if (idx < 0) {
idx = -idx;
neg = true;
}
putsStrIdx(x, y, STR_CV, idx, att);
if (ZEXIST(g_model.curves[idx-1].name))
lcdDrawSizedText(x, y, g_model.curves[idx-1].name, LEN_CURVE_NAME, ZCHAR|flags);
else
drawStringWithIndex(x, y, STR_CV, idx, flags);
if (neg) {
if ((att&INVERS) && ((~att&BLINK) || BLINK_ON_PHASE))
att &= ~(INVERS|BLINK);
lcdDrawChar(x-3, y, '!', att);
if ((flags&INVERS) && ((~flags&BLINK) || BLINK_ON_PHASE))
flags &= ~(INVERS|BLINK);
lcdDrawChar(x-3, y, '!', flags);
}
}
+2 -2
View File
@@ -179,14 +179,14 @@ void lcd_putsCenter(coord_t y, const pm_char * s, LcdFlags attr=0);
void lcdDrawHexNumber(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL);
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att=0, const char *prefix="");
void drawStringWithIndex(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att=0, const char *prefix="");
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void putsSwitches(coord_t x, coord_t y, swsrc_t swtch, LcdFlags flags=0);
void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att=0);
void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att=0);
void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
+2 -2
View File
@@ -314,7 +314,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t a
if (attr && menuHorizontalPosition==1) CHECK_INCDEC_MODELVAR_ZERO(event, curve.value, CURVE_BASE-1);
break;
case CURVE_REF_CUSTOM:
putsCurve(lcdNextPos+10, y, curve.value, (menuHorizontalPosition==1 ? attr : 0));
drawCurveName(lcdNextPos+10, y, curve.value, (menuHorizontalPosition==1 ? attr : 0));
if (attr && menuHorizontalPosition==1) {
if (event==EVT_KEY_LONG(KEY_ENTER) && curve.value!=0) {
s_curveChan = (curve.value<0 ? -curve.value-1 : curve.value-1);
@@ -351,7 +351,7 @@ bool menuModelCurvesAll(evt_t event)
uint8_t k = i + menuVerticalOffset;
LcdFlags attr = (sub == k ? INVERS : 0);
{
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_CV, k+1, attr);
drawStringWithIndex(MENUS_MARGIN_LEFT, y, STR_CV, k+1, attr);
CurveData & crv = g_model.curves[k];
editName(CURVES_NAME_POS, y, crv.name, sizeof(crv.name), 0, 0);
lcdDrawNumber(CURVES_POINTS_POS, y, 5+crv.points, LEFT, 0, NULL, STR_PTS);
@@ -125,7 +125,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
coord_t y = MENU_CONTENT_TOP + i*FH;
unsigned int k = i+menuVerticalOffset;
putsStrIdx(MENUS_MARGIN_LEFT, y, functions == g_model.customFn ? STR_SF : STR_GF, k+1, (sub==k && menuHorizontalPosition<0) ? INVERS : 0);
drawStringWithIndex(MENUS_MARGIN_LEFT, y, functions == g_model.customFn ? STR_SF : STR_GF, k+1, (sub==k && menuHorizontalPosition<0) ? INVERS : 0);
CustomFunctionData *cfn = &functions[k];
unsigned int func = CFN_FUNC(cfn);
@@ -170,14 +170,14 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
maxParam = MAX_GVARS-1;
putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr);
drawStringWithIndex(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr);
if (active) CFN_GVAR_INDEX(cfn) = checkIncDec(event, CFN_GVAR_INDEX(cfn), 0, maxParam, eeFlags);
break;
}
#endif
else if (func == FUNC_SET_TIMER) {
maxParam = MAX_TIMERS-1;
putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr);
drawStringWithIndex(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr);
if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags);
break;
}
@@ -294,7 +294,7 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
break;
case FUNC_ADJUST_GVAR_GVAR:
val_max = MAX_GVARS-1;
putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr);
drawStringWithIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr);
break;
default: // FUNC_ADJUST_GVAR_INC
val_max = 1;
@@ -51,7 +51,7 @@ bool menuModelCustomScriptOne(evt_t event)
{
ScriptData &sd = g_model.scriptsData[s_currIdx];
// putsStrIdx(lcdLastPos+FW, 0, "LUA", s_currIdx+1, 0);
// drawStringWithIndex(lcdLastPos+FW, 0, "LUA", s_currIdx+1, 0);
SUBMENU(STR_MENUCUSTOMSCRIPTS, 3+scriptInputsOutputs[s_currIdx].inputsCount, 0, { 0, 0, LABEL(inputs), 0/*repeated*/ });
@@ -141,7 +141,7 @@ bool menuModelCustomScripts(evt_t event)
ScriptData &sd = g_model.scriptsData[i];
// LUAx header
putsStrIdx(MENUS_MARGIN_LEFT, y, "LUA", i+1, sub==i ? INVERS : 0);
drawStringWithIndex(MENUS_MARGIN_LEFT, y, "LUA", i+1, sub==i ? INVERS : 0);
// LUA script
if (ZEXIST(sd.file)) {
+1 -1
View File
@@ -52,7 +52,7 @@ bool menuModelGVars(evt_t event)
int i = l+menuVerticalOffset;
coord_t y = MENU_CONTENT_TOP + l*FH;
if (g_model.gvars[i].popup) lcdDrawText(MENUS_MARGIN_LEFT+25, y, "!");
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_GV, i+1, ((sub==i && menuHorizontalPosition<0) ? INVERS : 0));
drawStringWithIndex(MENUS_MARGIN_LEFT, y, STR_GV, i+1, ((sub==i && menuHorizontalPosition<0) ? INVERS : 0));
for (int j=0; j<1+MAX_FLIGHT_MODES; j++) {
LcdFlags attr = ((sub==i && menuHorizontalPosition==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
+1 -1
View File
@@ -226,7 +226,7 @@ bool menuModelLimits(evt_t event)
#if defined(CURVES)
case ITEM_LIMITS_CURVE:
putsCurve(LIMITS_CURVE_POS, y, ld->curve, attr);
drawCurveName(LIMITS_CURVE_POS, y, ld->curve, attr);
if (attr && event==EVT_KEY_LONG(KEY_ENTER) && ld->curve>0) {
s_curveChan = (ld->curve<0 ? -ld->curve-1 : ld->curve-1);
pushMenu(menuModelCurveOne);
+3 -3
View File
@@ -105,7 +105,7 @@ void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, evt_t event)
if (attr && menuHorizontalPosition < 0) {
lcdDrawSolidFilledRect(MODEL_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN+1, 90+2*INVERT_HORZ_MARGIN, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
}
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_TIMER, timerIdx+1);
drawStringWithIndex(MENUS_MARGIN_LEFT, y, STR_TIMER, timerIdx+1);
putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, (menuHorizontalPosition<=0 ? attr : 0));
putsTimer(MODEL_SETUP_2ND_COLUMN+50, y, timer->start, (menuHorizontalPosition!=0 ? attr : 0));
if (attr && s_editMode>0) {
@@ -583,9 +583,9 @@ bool menuModelSetup(evt_t event)
ModuleData & moduleData = g_model.moduleData[moduleIdx];
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CHANNELRANGE);
if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) {
putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_CH, moduleData.channelsStart+1, menuHorizontalPosition==0 ? attr : 0);
drawStringWithIndex(MODEL_SETUP_2ND_COLUMN, y, STR_CH, moduleData.channelsStart+1, menuHorizontalPosition==0 ? attr : 0);
lcdDrawText(MODEL_SETUP_2ND_COLUMN+30, y, "-");
putsStrIdx(MODEL_SETUP_2ND_COLUMN+40, y, STR_CH, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), menuHorizontalPosition==1 ? attr : 0);
drawStringWithIndex(MODEL_SETUP_2ND_COLUMN+40, y, STR_CH, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), menuHorizontalPosition==1 ? attr : 0);
if (attr && s_editMode>0) {
switch (menuHorizontalPosition) {
case 0:
+2 -2
View File
@@ -392,7 +392,7 @@ bool menuModelSensor(evt_t event)
case SENSOR_FIELD_PARAM4:
{
putsStrIdx(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE), k-SENSOR_FIELD_PARAM1+1);
drawStringWithIndex(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE), k-SENSOR_FIELD_PARAM1+1);
int8_t & source = sensor->calc.sources[k-SENSOR_FIELD_PARAM1];
if (attr) {
source = checkIncDec(event, source, -MAX_SENSORS, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable);
@@ -695,7 +695,7 @@ bool menuModelTelemetry(evt_t event)
case ITEM_TELEMETRY_SCREEN_LABEL4:
{
uint8_t screenIndex = TELEMETRY_CURRENT_SCREEN(k);
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_SCREEN, screenIndex+1);
drawStringWithIndex(MENUS_MARGIN_LEFT, y, STR_SCREEN, screenIndex+1);
TelemetryScreenType oldScreenType = TELEMETRY_SCREEN_TYPE(screenIndex);
TelemetryScreenType newScreenType = (TelemetryScreenType)selectMenuItem(TELEM_COL2, y, STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (menuHorizontalPosition==0 ? attr : 0), event);
if (newScreenType != oldScreenType) {
+2 -2
View File
@@ -164,7 +164,7 @@ void drawTimer(coord_t x, coord_t y, int index)
if (ZLEN(timerData.name) > 0) {
lcdDrawSizedText(x+78, y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR);
}
putsStrIdx(x+137, y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR);
drawStringWithIndex(x+137, y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR);
}
@@ -391,7 +391,7 @@ bool menuMainView(evt_t event)
if (gvarDisplayTimer > 0) {
gvarDisplayTimer--;
displayMessageBox();
putsStrIdx(WARNING_LINE_X, WARNING_LINE_Y, STR_GV, gvarLastChanged+1, DBLSIZE|YELLOW);
drawStringWithIndex(WARNING_LINE_X, WARNING_LINE_Y, STR_GV, gvarLastChanged+1, DBLSIZE|YELLOW);
lcdDrawSizedText(WARNING_LINE_X+45, WARNING_LINE_Y, g_model.gvars[gvarLastChanged].name, LEN_GVAR_NAME, DBLSIZE|YELLOW|ZCHAR);
lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y, GVAR_VALUE(gvarLastChanged, getGVarFlightMode(mixerCurrentFlightMode, gvarLastChanged)), DBLSIZE|LEFT);
}
+2 -2
View File
@@ -302,10 +302,10 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
if (idx < 0) {
value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta);
idx = -idx;
putsStrIdx(x, y, STR_GV, idx, attr, "-");
drawStringWithIndex(x, y, STR_GV, idx, attr, "-");
}
else {
putsStrIdx(x, y, STR_GV, idx, attr);
drawStringWithIndex(x, y, STR_GV, idx, attr);
value = (int16_t) GV_CALC_VALUE_IDX_POS(idx-1, delta);
}
}