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
+19 -16
View File
@@ -601,7 +601,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, uint8_t idx, LcdFlags att)
void drawStringWithIndex(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att)
{
lcdDrawText(x, y, str, att & ~LEADING0);
lcdDrawNumber(lcdNextPos, y, idx, att|LEFT, 2);
@@ -638,7 +638,7 @@ void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
else
#endif
{
putsStrIdx(x, y, "LUA", qr.quot+1, att);
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
lcdDrawChar(lcdLastPos, y, 'a'+qr.rem, att);
}
}
@@ -671,16 +671,16 @@ void putsMixerSource(coord_t x, coord_t y, uint32_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 (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) {
lcdDrawChar(lcdLastPos, y, ' ', att|SMLSIZE);
lcdDrawSizedText(lcdLastPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, ZCHAR|att|SMLSIZE);
}
}
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);
@@ -703,7 +703,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);
@@ -738,25 +738,25 @@ void putsSwitches(coord_t x, coord_t y, int32_t idx, LcdFlags att)
}
else if (idx <= SWSRC_LAST_MULTIPOS_SWITCH) {
div_t swinfo = div(idx - SWSRC_FIRST_MULTIPOS_SWITCH, XPOTS_MULTIPOS_COUNT);
putsStrIdx(x, y, "S", swinfo.quot*10+swinfo.rem+11, att);
drawStringWithIndex(x, y, "S", swinfo.quot*10+swinfo.rem+11, att);
}
else if (idx <= SWSRC_LAST_TRIM) {
lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx-SWSRC_FIRST_TRIM+1, att);
}
else if (idx <= SWSRC_LAST_LOGICAL_SWITCH) {
putsStrIdx(x, y, "L", idx-SWSRC_FIRST_LOGICAL_SWITCH+1, att);
drawStringWithIndex(x, y, "L", idx-SWSRC_FIRST_LOGICAL_SWITCH+1, att);
}
else if (idx <= SWSRC_ONE) {
lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx-SWSRC_ON+1+(2*NUM_STICKS), att);
}
else if (idx <= SWSRC_LAST_FLIGHT_MODE) {
putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
drawStringWithIndex(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
}
else if (idx == SWSRC_TELEMETRY_STREAMING) {
lcdDrawText(x, y, "Tele", att);
}
else if (idx <= SWSRC_LAST_FLIGHT_MODE) {
putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
drawStringWithIndex(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att);
}
else if (idx == SWSRC_TELEMETRY_STREAMING) {
lcdDrawText(x, y, "Tele", att);
@@ -774,7 +774,7 @@ void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
if (att & CONDENSED)
lcdDrawNumber(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
else
putsStrIdx(x, y, STR_FP, idx-1, att);
drawStringWithIndex(x, y, STR_FP, idx-1, att);
}
#endif
@@ -797,24 +797,27 @@ 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);
}
if (idx < 0) {
lcdDrawChar(x-3, y, '!', att);
lcdDrawChar(x-3, y, '!', flags);
idx = -idx;
}
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);
}
void putsTimerMode(coord_t x, coord_t y, int32_t mode, LcdFlags att)
+2 -2
View File
@@ -142,7 +142,7 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode, uint8_t len
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val);
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0);
void drawStringWithIndex(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0);
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void putsSwitches(coord_t x, coord_t y, int32_t swtch, LcdFlags att=0);
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
@@ -151,7 +151,7 @@ void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
#if !defined(BOOT)
void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att);
#endif
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, int32_t mode, LcdFlags att=0);
void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
@@ -36,7 +36,7 @@ void menuGeneralDiagAna(uint8_t event)
#else
coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH;
uint8_t x = i&1 ? 64+5 : 0;
putsStrIdx(x, y, PSTR("A"), i+1);
drawStringWithIndex(x, y, PSTR("A"), i+1);
lcdDrawChar(lcdNextPos, y, ':');
#endif
lcdDrawHexNumber(x+3*FW-1, y, anaIn(i));
+3 -3
View File
@@ -129,7 +129,7 @@ void menuModelCurveOne(uint8_t event)
int8_t * points = curveAddress(s_curveChan);
lcdDrawText(11*FW+FW/2, 0, TR_PT "\002X\006Y");
putsStrIdx(PSIZE(TR_MENUCURVES)*FW+FW, 0, "CV", s_curveChan+1);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, "CV", s_curveChan+1);
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
SIMPLE_SUBMENU(STR_MENUCURVES, 4 + 5+crv.points + (crv.type==CURVE_TYPE_CUSTOM ? 5+crv.points-2 : 0));
@@ -260,7 +260,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, uint8_t
if (attr && menuHorizontalPosition==1) CHECK_INCDEC_MODELVAR_ZERO(event, curve.value, CURVE_BASE-1);
break;
case CURVE_REF_CUSTOM:
putsCurve(x+5*FW+2, y, curve.value, menuHorizontalPosition==1 ? attr : 0);
drawCurveName(x+5*FW+2, 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);
@@ -294,7 +294,7 @@ void menuModelCurvesAll(uint8_t event)
int k = i + menuVerticalOffset;
LcdFlags attr = (sub == k ? INVERS : 0);
{
putsStrIdx(0, y, STR_CV, k+1, attr);
drawStringWithIndex(0, y, STR_CV, k+1, attr);
CurveData & crv = g_model.curves[k];
editName(4*FW, y, crv.name, sizeof(crv.name), 0, 0);
lcdDrawNumber(11*FW, y, 5+crv.points, LEFT);
@@ -172,7 +172,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
int k = i+menuVerticalOffset;
putsStrIdx(0, y, functions == g_model.customFn ? STR_SF : STR_GF, k+1, (sub==k && menuHorizontalPosition<0) ? INVERS : 0);
drawStringWithIndex(0, y, functions == g_model.customFn ? STR_SF : STR_GF, k+1, (sub==k && menuHorizontalPosition<0) ? INVERS : 0);
CustomFunctionData *cfn = &functions[k];
uint8_t func = CFN_FUNC(cfn);
@@ -220,14 +220,14 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
maxParam = MAX_GVARS-1;
putsStrIdx(lcdNextPos, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr);
drawStringWithIndex(lcdNextPos, 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 = TIMERS-1;
putsStrIdx(lcdNextPos, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr);
drawStringWithIndex(lcdNextPos, 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;
}
@@ -358,7 +358,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
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_min = -100; val_max = +100;
@@ -51,7 +51,7 @@ void menuModelCustomScriptOne(uint8_t event)
{
ScriptData & sd = g_model.scriptsData[s_currIdx];
putsStrIdx(PSIZE(TR_MENUCUSTOMSCRIPTS)*FW+FW, 0, "LUA", s_currIdx+1, 0);
drawStringWithIndex(PSIZE(TR_MENUCUSTOMSCRIPTS)*FW+FW, 0, "LUA", s_currIdx+1, 0);
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
SUBMENU(STR_MENUCUSTOMSCRIPTS, 3+scriptInputsOutputs[s_currIdx].inputsCount, { 0, 0, LABEL(inputs), 0/*repeated*/ });
@@ -137,7 +137,7 @@ void menuModelCustomScripts(uint8_t event)
ScriptData &sd = g_model.scriptsData[i];
// LUAx header
putsStrIdx(0, y, "LUA", i+1, sub==i ? INVERS : 0);
drawStringWithIndex(0, y, "LUA", i+1, sub==i ? INVERS : 0);
// LUA script
if (ZEXIST(sd.file)) {
+3 -3
View File
@@ -66,7 +66,7 @@ void menuModelGVarOne(uint8_t event)
{
GVarData * gvar = &g_model.gvars[s_currIdx];
putsStrIdx(PSIZE(TR_GVARS)*FW+FW, 0, STR_GV, s_currIdx+1, 0);
drawStringWithIndex(PSIZE(TR_GVARS)*FW+FW, 0, STR_GV, s_currIdx+1, 0);
drawGVarValue(32*FW, 0, s_currIdx, getGVarValue(s_currIdx, getFlightMode()));
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
@@ -107,7 +107,7 @@ void menuModelGVarOne(uint8_t event)
break;
default:
putsStrIdx(0, y, STR_FP, k-GVAR_FIELD_FM0);
drawStringWithIndex(0, y, STR_FP, k-GVAR_FIELD_FM0);
editGVarValue(GVAR_2ND_COLUMN, y, event, s_currIdx, k-GVAR_FIELD_FM0, LEFT|attr);
break;
}
@@ -142,7 +142,7 @@ void menuModelGVars(uint8_t event)
if (after2seconds) {
menuTitle = STR_GVARS;
for (int i=0; i<MAX_GVARS; i++) {
putsStrIdx(GVARS_FM_COLUMN(i)-16, 1, STR_FP, i, SMLSIZE|(getFlightMode()==i ? INVERS : 0));
drawStringWithIndex(GVARS_FM_COLUMN(i)-16, 1, STR_FP, i, SMLSIZE|(getFlightMode()==i ? INVERS : 0));
}
}
else {
+1 -1
View File
@@ -232,7 +232,7 @@ void menuModelLimits(uint8_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);
+2 -2
View File
@@ -120,7 +120,7 @@ void onModelSetupBitmapMenu(const char *result)
void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
{
TimerData * timer = &g_model.timers[timerIdx];
putsStrIdx(0*FW, y, STR_TIMER, timerIdx+1);
drawStringWithIndex(0*FW, y, STR_TIMER, timerIdx+1);
putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, menuHorizontalPosition==0 ? attr : 0);
putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, menuHorizontalPosition==1 ? attr : 0, menuHorizontalPosition==2 ? attr : 0);
@@ -357,7 +357,7 @@ void menuModelSetup(uint8_t event)
#if defined(REV9E)
case ITEM_MODEL_TOP_LCD_TIMER:
lcd_putsLeft(y, STR_TOPLCDTIMER);
putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.toplcdTimer+1, attr);
drawStringWithIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.toplcdTimer+1, attr);
if (attr) {
g_model.toplcdTimer = checkIncDec(event, g_model.toplcdTimer, 0, TIMERS-1, EE_MODEL);
}
@@ -204,7 +204,7 @@ void menuModelSensor(uint8_t event)
{
TelemetrySensor * sensor = &g_model.telemetrySensors[s_currIdx];
putsStrIdx(PSIZE(TR_MENUSENSOR)*FW+FW, 0, STR_SENSOR, s_currIdx+1);
drawStringWithIndex(PSIZE(TR_MENUSENSOR)*FW+FW, 0, STR_SENSOR, s_currIdx+1);
putsTelemetryChannelValue(32*FW, 0, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx));
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
@@ -389,7 +389,7 @@ void menuModelSensor(uint8_t event)
case SENSOR_FIELD_PARAM4:
{
putsStrIdx(0, y, NO_INDENT(STR_SOURCE), k-SENSOR_FIELD_PARAM1+1);
drawStringWithIndex(0, 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);
@@ -688,7 +688,7 @@ void menuModelTelemetry(uint8_t event)
case ITEM_TELEMETRY_SCREEN_LABEL4:
{
uint8_t screenIndex = TELEMETRY_CURRENT_SCREEN(k);
putsStrIdx(0*FW, y, STR_SCREEN, screenIndex+1);
drawStringWithIndex(0*FW, y, STR_SCREEN, screenIndex+1);
TelemetryScreenType oldScreenType = TELEMETRY_SCREEN_TYPE(screenIndex);
TelemetryScreenType newScreenType = (TelemetryScreenType)selectMenuItem(TELEM_SCRTYPE_COL, y, PSTR(""), STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (menuHorizontalPosition==0 ? attr : 0), event);
if (newScreenType != oldScreenType) {
+1 -1
View File
@@ -576,7 +576,7 @@ void menuMainView(uint8_t event)
gvarDisplayTimer--;
lcdDrawFilledRect(BITMAP_X, BITMAP_Y, 64, 32, SOLID, ERASE);
lcdDrawRect(BITMAP_X, BITMAP_Y, 64, 32);
putsStrIdx(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, gvarLastChanged+1);
drawStringWithIndex(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, gvarLastChanged+1);
lcdDrawSizedText(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[gvarLastChanged].name, LEN_GVAR_NAME, ZCHAR);
lcdDrawText(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("["), BOLD);
drawGVarValue(BITMAP_X+2*FW, BITMAP_Y+2*FH+3, gvarLastChanged, GVAR_VALUE(gvarLastChanged, getGVarFlightMode(mixerCurrentFlightMode, gvarLastChanged)), LEFT|BOLD);
+1 -1
View File
@@ -61,7 +61,7 @@ void menuStatisticsView(uint8_t event)
// Timers
for (int i=0; i<TIMERS; i++) {
putsStrIdx(STATS_3RD_COLUMN, FH*i+1, "TM", i+1, BOLD);
drawStringWithIndex(STATS_3RD_COLUMN, FH*i+1, "TM", i+1, BOLD);
if (timersStates[i].val > 3600)
putsTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0);
else
+1 -1
View File
@@ -127,7 +127,7 @@ bool displayNumbersTelemetryScreen(FrSkyScreenData & screen)
LcdFlags att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT);
if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER && i!=3) {
// there is not enough space on LCD for displaying "Tmr1" or "Tmr2" and still see the - sign, we write "T1" or "T2" instead
putsStrIdx(pos[j], 1+FH+2*FH*i, "T", field-MIXSRC_FIRST_TIMER+1, 0);
drawStringWithIndex(pos[j], 1+FH+2*FH*i, "T", field-MIXSRC_FIRST_TIMER+1, 0);
if (timersStates[field-MIXSRC_FIRST_TIMER].val > 3600) {
att += TIMEHOUR - DBLSIZE;
x -= 3*FW;
+1 -1
View File
@@ -165,7 +165,7 @@ void drawGVarName(coord_t x, coord_t y, int8_t index, LcdFlags flags)
if (ZEXIST(g_model.gvars[index].name))
lcdDrawSizedText(x, y, g_model.gvars[index].name, LEN_GVAR_NAME, ZCHAR|flags);
else
putsStrIdx(x, y, STR_GV, index+1, flags);
drawStringWithIndex(x, y, STR_GV, index+1, flags);
}
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags)