From fda4cac1edb16b9fc668143616e22ded87a14b2c Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 1 Feb 2016 20:30:52 +0100 Subject: [PATCH] [Horus] --- radio/src/gui/horus/lcd.cpp | 6 ++-- radio/src/gui/horus/menu_general_calib.cpp | 2 +- radio/src/gui/horus/menu_model_curves.cpp | 38 ++++++++++---------- radio/src/gui/horus/menu_model_inputs.cpp | 14 ++++---- radio/src/gui/horus/menu_model_mixes.cpp | 13 ++++--- radio/src/gui/horus/menu_model_setup.cpp | 18 +++++----- radio/src/gui/horus/menu_model_telemetry.cpp | 10 +++--- radio/src/gui/horus/menus.h | 7 +++- radio/src/gui/horus/navigation.cpp | 14 ++++---- radio/src/gui/horus/widgets.cpp | 35 +++++++++--------- radio/src/gui/horus/widgets.h | 5 +-- radio/src/sdcard.cpp | 2 +- radio/src/strhelpers.cpp | 11 +++++- radio/src/strhelpers.h | 3 +- radio/src/targets/horus/board_horus.cpp | 6 ++-- radio/src/targets/taranis/board_taranis.cpp | 6 ++-- 16 files changed, 106 insertions(+), 84 deletions(-) diff --git a/radio/src/gui/horus/lcd.cpp b/radio/src/gui/horus/lcd.cpp index 4607879b37..1d1407c05a 100644 --- a/radio/src/gui/horus/lcd.cpp +++ b/radio/src/gui/horus/lcd.cpp @@ -434,7 +434,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att) void drawStringWithIndex(coord_t x, coord_t y, const pm_char * str, int idx, LcdFlags att, const char * prefix) { char s[64]; - strAppendNumber(strAppend(strAppend(s, prefix), str), abs(idx)); + strAppendUnsigned(strAppend(strAppend(s, prefix), str), abs(idx)); lcdDrawText(x, y, s, att); } @@ -456,7 +456,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att) s[1+LEN_INPUT_NAME] = '\0'; } else { - strAppendNumber(s+1, idx, 2); + strAppendUnsigned(s+1, idx, 2); } lcdDrawText(x, y, s, att); } @@ -545,7 +545,7 @@ char * getStringAtIndex(char * dest, const char * s, int idx) char * getStringWithIndex(char * dest, const char * s, int idx) { - strAppendNumber(strAppend(dest, s), abs(idx)); + strAppendUnsigned(strAppend(dest, s), abs(idx)); return dest; } diff --git a/radio/src/gui/horus/menu_general_calib.cpp b/radio/src/gui/horus/menu_general_calib.cpp index a92b5e09e7..91c62e7fe9 100644 --- a/radio/src/gui/horus/menu_general_calib.cpp +++ b/radio/src/gui/horus/menu_general_calib.cpp @@ -57,7 +57,7 @@ void drawPots() bool menuCommonCalib(evt_t event) { - drawMenuTemplate(NULL, 0, OPTION_MENU_NO_FOOTER); + drawSubmenuTemplate(NULL, 0, OPTION_MENU_NO_FOOTER); for (uint8_t i=0; i> 1; diff --git a/radio/src/gui/horus/menu_model_curves.cpp b/radio/src/gui/horus/menu_model_curves.cpp index fc12703f6d..6f79c6c7a0 100644 --- a/radio/src/gui/horus/menu_model_curves.cpp +++ b/radio/src/gui/horus/menu_model_curves.cpp @@ -138,18 +138,18 @@ bool menuModelCurveOne(evt_t event) CurveData & crv = g_model.curves[s_curveChan]; int8_t * points = curveAddress(s_curveChan); - SUBMENU(STR_MENUCURVE, crv.type==CURVE_TYPE_CUSTOM ? 6 : 5, 0, { 0, 0, 0, 0, uint8_t(5+crv.points-1), uint8_t(5+crv.points-1) }); - - lcdDrawNumber(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+1, s_curveChan+1, LEFT|TEXT_COLOR); + SUBMENU_WITH_OPTIONS(STR_MENUCURVE, crv.type==CURVE_TYPE_CUSTOM ? 6 : 5, OPTION_MENU_NO_FOOTER, 0, { 0, 0, 0, 0, uint8_t(5+crv.points-1), uint8_t(5+crv.points-1) }); + drawStringWithIndex(50, 3+FH, STR_CV, s_curveChan+1, MENU_TITLE_COLOR); + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, 250, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); // Curve name - lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, STR_NAME); - editName(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP, crv.name, sizeof(crv.name), event, menuVerticalPosition==ITEM_CURVE_NAME); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP-FH, STR_NAME); + editName(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP-FH, crv.name, sizeof(crv.name), event, menuVerticalPosition==ITEM_CURVE_NAME); // Curve type LcdFlags attr = (menuVerticalPosition==ITEM_CURVE_TYPE ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0); - lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + FH, "Type"); - lcdDrawTextAtIndex(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP + FH, STR_CURVE_TYPES, crv.type, attr); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, "Type"); + lcdDrawTextAtIndex(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP, STR_CURVE_TYPES, crv.type, attr); if (attr) { uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST); if (newType != crv.type) { @@ -166,8 +166,8 @@ bool menuModelCurveOne(evt_t event) // Curve points count attr = (menuVerticalPosition==ITEM_CURVE_POINTS ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0); - lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, STR_COUNT); - lcdDrawNumber(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP + 2*FH, 5+crv.points, LEFT|attr, 0, NULL, STR_PTS); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + FH, STR_COUNT); + lcdDrawNumber(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP + FH, 5+crv.points, LEFT|attr, 0, NULL, STR_PTS); if (attr) { int count = checkIncDecModel(event, crv.points, -3, 12); // 2pts - 17pts if (checkIncDec_Ret) { @@ -187,8 +187,8 @@ bool menuModelCurveOne(evt_t event) } // Curve smooth - lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 3*FH, STR_SMOOTH); - drawCheckBox(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP + 3*FH, crv.smooth, menuVerticalPosition==ITEM_CURVE_SMOOTH ? INVERS : 0); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, STR_SMOOTH); + drawCheckBox(MODEL_CURVE_ONE_2ND_COLUMN, MENU_CONTENT_TOP + 2*FH, crv.smooth, menuVerticalPosition==ITEM_CURVE_SMOOTH ? INVERS : 0); if (menuVerticalPosition==ITEM_CURVE_SMOOTH) crv.smooth = checkIncDecModel(event, crv.smooth, 0, 1); switch(event) { @@ -238,9 +238,9 @@ bool menuModelCurveOne(evt_t event) if (crv.type==CURVE_TYPE_CUSTOM && i>0 && i<5+crv.points-1) x = points[5+crv.points+i-1]; if (i>=pointsOfs && i= CURVE_CENTER_X) { drawCurveVerticalScale(point.x-15); @@ -271,7 +271,7 @@ bool menuModelCurveOne(evt_t event) drawCurvePoint(point.x-3, point.y-4, CURVE_CURSOR_COLOR); - strAppendNumber(text, x); + strAppendUnsigned(text, x); drawCurveCoord(limit(CURVE_CENTER_X-CURVE_SIDE_WIDTH-1, point.x-CURVE_COORD_WIDTH/2, CURVE_CENTER_X+CURVE_SIDE_WIDTH-CURVE_COORD_WIDTH+1), CURVE_CENTER_Y+CURVE_SIDE_WIDTH+2, text, selectionMode==1); if (s_editMode > 0) { @@ -290,9 +290,9 @@ bool menuModelCurveOne(evt_t event) } } - lcdDrawHorizontalLine(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 6*FH - 1, SUBMENU_LINE_WIDTH, DOTTED, CURVE_AXIS_COLOR); - lcdDrawHorizontalLine(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 7*FH + 2, SUBMENU_LINE_WIDTH, DOTTED, CURVE_AXIS_COLOR); - drawHorizontalScrollbar(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 9*FH - 1, SUBMENU_LINE_WIDTH, pointsOfs, 5+crv.points, 5); + lcdDrawHorizontalLine(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 6*FH - 13, SUBMENU_LINE_WIDTH, DOTTED, CURVE_AXIS_COLOR); + lcdDrawHorizontalLine(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 7*FH - 10, SUBMENU_LINE_WIDTH, DOTTED, CURVE_AXIS_COLOR); + drawHorizontalScrollbar(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 9*FH - 15, SUBMENU_LINE_WIDTH, pointsOfs, 5+crv.points, 5); return true; } diff --git a/radio/src/gui/horus/menu_model_inputs.cpp b/radio/src/gui/horus/menu_model_inputs.cpp index 3f2d0a8139..40bb714f75 100644 --- a/radio/src/gui/horus/menu_model_inputs.cpp +++ b/radio/src/gui/horus/menu_model_inputs.cpp @@ -175,11 +175,13 @@ bool menuModelExpoOne(evt_t event) { ExpoData * ed = expoAddress(s_currIdx); - SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, 0, { 0, 0, (ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)1 : (uint8_t)0), 0, 0, CASE_CURVES(CURVE_ROWS) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/}); + SUBMENU_WITH_OPTIONS(STR_MENUINPUTS, EXPO_FIELD_MAX, OPTION_MENU_NO_FOOTER, 0, { 0, 0, (ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)1 : (uint8_t)0), 0, 0, CASE_CURVES(CURVE_ROWS) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/}); + lcdDrawSizedText(50, 3+FH, g_model.inputNames[ed->chn], LEN_INPUT_NAME, ZCHAR|MENU_TITLE_COLOR); + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, 230, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); int sub = menuVerticalPosition; - coord_t y = MENU_CONTENT_TOP; + coord_t y = MENU_CONTENT_TOP-FH-2; drawFunction(expoFn, CURVE_CENTER_X, CURVE_CENTER_Y, CURVE_SIDE_WIDTH); drawCurveHorizontalScale(); @@ -190,17 +192,17 @@ bool menuModelExpoOne(evt_t event) char texty[5]; int x = getValue(ed->srcRaw); if (ed->srcRaw >= MIXSRC_FIRST_TELEM) { - strAppendNumber(textx, calcRESXto100(x)); + strAppendUnsigned(textx, calcRESXto100(x)); // TODO putsTelemetryChannelValue(LCD_W-8, 6*FH, ed->srcRaw - MIXSRC_FIRST_TELEM, x); if (ed->scale > 0) x = (x * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale); } else { - strAppendNumber(textx, calcRESXto100(x)); + strAppendSigned(textx, calcRESXto100(x)); } x = limit(-1024, x, 1024); int y = limit(-1024, expoFn(x), 1024); - strAppendNumber(texty, calcRESXto100(y)); + strAppendSigned(texty, calcRESXto100(y)); x = divRoundClosest(x*CURVE_SIDE_WIDTH, RESX); y = CURVE_CENTER_Y + getCurveYCoord(expoFn, x, CURVE_SIDE_WIDTH); @@ -434,7 +436,7 @@ bool menuModelExposAll(evt_t event) pushMenu(menuModelExpoOne); s_copyMode = 0; } - else { + else if (menuVerticalPosition >= 0) { event = 0; s_copyMode = 0; POPUP_MENU_ADD_ITEM(STR_EDIT); diff --git a/radio/src/gui/horus/menu_model_mixes.cpp b/radio/src/gui/horus/menu_model_mixes.cpp index dcb77c1228..d940b6c0a9 100644 --- a/radio/src/gui/horus/menu_model_mixes.cpp +++ b/radio/src/gui/horus/menu_model_mixes.cpp @@ -172,14 +172,13 @@ void gvarWeightItem(coord_t x, coord_t y, MixData *md, uint8_t attr, evt_t event bool menuModelMixOne(evt_t event) { - MixData *md2 = mixAddress(s_currIdx) ; + MixData * md2 = mixAddress(s_currIdx) ; SUBMENU(STR_MIXER, MIX_FIELD_COUNT, 0, { 0, 0, 0, 0, 0, CASE_CURVES(1) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/ }); - - putsChn(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+1, md2->destCh+1, TEXT_COLOR); + putsChn(50, 3+FH, md2->destCh+1, MENU_TITLE_COLOR); // The separation line between 2 columns - lcdDrawSolidVerticalLine(MENU_COLUMN2_X-20, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H+5, TEXT_COLOR); + lcdDrawSolidVerticalLine(MENU_COLUMN2_X-20, DEFAULT_SCROLLBAR_Y-FH, DEFAULT_SCROLLBAR_H+5, TEXT_COLOR); int8_t sub = menuVerticalPosition; int8_t editMode = s_editMode; @@ -187,10 +186,10 @@ bool menuModelMixOne(evt_t event) for (int k=0; k<2*NUM_BODY_LINES; k++) { coord_t y; if (k >= NUM_BODY_LINES) { - y = MENU_CONTENT_TOP + (k-NUM_BODY_LINES)*FH + 2; + y = MENU_CONTENT_TOP - FH + (k-NUM_BODY_LINES)*FH; } else { - y = MENU_CONTENT_TOP + k*FH + 2; + y = MENU_CONTENT_TOP - FH + k*FH; } int8_t i = k; @@ -408,7 +407,7 @@ bool menuModelMixAll(evt_t event) pushMenu(menuModelMixOne); s_copyMode = 0; } - else { + else if (menuVerticalPosition >= 0) { event = 0; s_copyMode = 0; POPUP_MENU_ADD_ITEM(STR_EDIT); diff --git a/radio/src/gui/horus/menu_model_setup.cpp b/radio/src/gui/horus/menu_model_setup.cpp index cf6c453c57..c8f988d8b1 100644 --- a/radio/src/gui/horus/menu_model_setup.cpp +++ b/radio/src/gui/horus/menu_model_setup.cpp @@ -152,19 +152,20 @@ int getSwitchWarningsCount() return count; } -#define INTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(INTERNAL_MODULE) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols +#define IF_EXTERNAL_MODULE_XJT(x) (IS_MODULE_XJT(EXTERNAL_MODULE) ? (uint8_t)x : HIDDEN_ROW) +#define IS_D8_RX(x) (g_model.moduleData[x].rfProtocol == RF_PROTO_D8) #define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x)) #define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) #define IF_TRAINER_ON(x) (g_model.trainerMode == TRAINER_MODE_SLAVE ? (uint8_t)(x) : HIDDEN_ROW) -#define IS_D8_RX(x) (g_model.moduleData[x].rfProtocol == RF_PROTO_D8) -#define IF_EXTERNAL_MODULE_XJT(x) (IS_MODULE_XJT(EXTERNAL_MODULE) ? (uint8_t)x : HIDDEN_ROW) + +#define INTERNAL_MODULE_MODE_ROWS (uint8_t)0 +#define EXTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0 #define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1) #define EXTERNAL_MODULE_CHANNELS_ROWS IF_EXTERNAL_MODULE_ON((IS_MODULE_DSM2(EXTERNAL_MODULE) || IS_MODULE_CROSSFIRE(EXTERNAL_MODULE)) ? (uint8_t)0 : (uint8_t)1) #define TRAINER_CHANNELS_ROWS() IF_TRAINER_ON(1) #define PORT_CHANNELS_ROWS(x) (x==INTERNAL_MODULE ? INTERNAL_MODULE_CHANNELS_ROWS : (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS : TRAINER_CHANNELS_ROWS())) #define FAILSAFE_ROWS(x) (HAS_RF_PROTOCOL_FAILSAFE(g_model.moduleData[x].rfProtocol) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : HIDDEN_ROW) #define TIMER_ROWS NAVIGATION_LINE_BY_LINE|1, 0, CASE_PERSISTENT_TIMERS(0) 0, 0 -#define EXTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0 #if TIMERS == 1 #define TIMERS_ROWS TIMER_ROWS #elif TIMERS == 2 @@ -174,6 +175,7 @@ int getSwitchWarningsCount() #endif #define SW_WARN_ITEMS() uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)) #define POT_WARN_ITEMS() ((g_model.potsWarnMode >> 6) ? (uint8_t)NUM_POTS : (uint8_t)0) + bool menuModelSetup(evt_t event) { horzpos_t l_posHorz = menuHorizontalPosition; @@ -584,8 +586,8 @@ bool menuModelSetup(evt_t event) lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CHANNELRANGE); if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) { drawStringWithIndex(MODEL_SETUP_2ND_COLUMN, y, STR_CH, moduleData.channelsStart+1, menuHorizontalPosition==0 ? attr : 0); - lcdDrawText(MODEL_SETUP_2ND_COLUMN+30, y, "-"); - drawStringWithIndex(MODEL_SETUP_2ND_COLUMN+40, y, STR_CH, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), menuHorizontalPosition==1 ? attr : 0); + lcdDrawText(lcdNextPos+5, y, "-"); + drawStringWithIndex(lcdNextPos+5, y, STR_CH, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), menuHorizontalPosition==1 ? attr : 0); if (attr && s_editMode>0) { switch (menuHorizontalPosition) { case 0: @@ -646,8 +648,8 @@ bool menuModelSetup(evt_t event) if (attr && l_posHorz==0 && s_editMode>0) { CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63); } - drawButton(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); - drawButton(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); + drawButton(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y-2, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); + drawButton(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y-2, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); uint8_t newFlag = 0; if (attr && l_posHorz>0 && s_editMode>0) { if (l_posHorz == 1) diff --git a/radio/src/gui/horus/menu_model_telemetry.cpp b/radio/src/gui/horus/menu_model_telemetry.cpp index 02d808f12a..b67f0658e3 100644 --- a/radio/src/gui/horus/menu_model_telemetry.cpp +++ b/radio/src/gui/horus/menu_model_telemetry.cpp @@ -127,13 +127,12 @@ bool menuModelSensor(evt_t event) { TelemetrySensor * sensor = &g_model.telemetrySensors[s_currIdx]; - SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, DEFAULT_SCROLLBAR_X, { 0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, 0, 0, 0, 0, 0 }); - - // lcdDrawNumber(MENUS_MARGIN_LEFT+getTextWidth(TR_MENUSENSOR)+5, MENU_FOOTER_TOP, s_currIdx+1, HEADER_COLOR|LEFT); - // putsTelemetryChannelValue(SENSOR_2ND_COLUMN, MENU_FOOTER_TOP, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx), HEADER_COLOR|LEFT); + SUBMENU("SENSOR", SENSOR_FIELD_MAX, DEFAULT_SCROLLBAR_X, { 0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, 0, 0, 0, 0, 0 }); + lcdDrawNumber(lcdNextPos, 3, s_currIdx+1, MENU_TITLE_COLOR|LEFT); + putsTelemetryChannelValue(50, 3+FH, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx), MENU_TITLE_COLOR|LEFT); for (unsigned int i=0; i0 ? BLINK|INVERS : INVERS) : 0); switch (k) { - case SENSOR_FIELD_NAME: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_NAME); editName(SENSOR_2ND_COLUMN, y, sensor->label, TELEM_LABEL_LEN, event, attr); diff --git a/radio/src/gui/horus/menus.h b/radio/src/gui/horus/menus.h index ac32dc626f..6b8b2265ac 100644 --- a/radio/src/gui/horus/menus.h +++ b/radio/src/gui/horus/menus.h @@ -270,7 +270,7 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow); MENU_TAB(__VA_ARGS__); \ if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \ if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \ - drawMenuTemplate(title, scrollbar_X); \ + drawSubmenuTemplate(title, scrollbar_X); \ #define MENU(title, tab, menu, lines_count, scrollbar_X, ...) \ MENU_TAB(__VA_ARGS__); \ @@ -288,6 +288,11 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow); if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \ drawSubmenuTemplate(title, scrollbar_X); +#define SUBMENU_WITH_OPTIONS(title, lines_count, options, scrollbar_X, ...) \ + MENU_TAB(__VA_ARGS__); \ + if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \ + drawSubmenuTemplate(title, scrollbar_X, options); + #define SIMPLE_SUBMENU_NOTITLE(lines_count) \ if (!check_submenu_simple(event, lines_count)) return false diff --git a/radio/src/gui/horus/navigation.cpp b/radio/src/gui/horus/navigation.cpp index f77312e7e7..291293d586 100644 --- a/radio/src/gui/horus/navigation.cpp +++ b/radio/src/gui/horus/navigation.cpp @@ -2,7 +2,7 @@ * Copyright (C) OpenTX * * Based on code named - * th9x - http://code.google.com/p/th9x + * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * @@ -507,14 +507,16 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u case EVT_KEY_FIRST(KEY_RIGHT): case EVT_KEY_REPT(KEY_RIGHT): - if (s_editMode != 0) break; - INC(menuHorizontalPosition, 0, maxcol); + if (s_editMode == 0) { + INC(menuHorizontalPosition, 0, maxcol); + } break; case EVT_KEY_FIRST(KEY_LEFT): case EVT_KEY_REPT(KEY_LEFT): - if (s_editMode != 0) break; - DEC(menuHorizontalPosition, 0, maxcol); + if (s_editMode == 0) { + DEC(menuHorizontalPosition, 0, maxcol); + } break; case EVT_ROTARY_RIGHT: @@ -570,7 +572,7 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u if (COLATTR(menuVerticalPosition) & NAVIGATION_LINE_BY_LINE) menuHorizontalPosition = -1; else - menuHorizontalPosition = min((uint8_t)menuHorizontalPosition, MAXCOL(menuVerticalPosition)); + menuHorizontalPosition = MAXCOL(menuVerticalPosition); break; case EVT_KEY_FIRST(KEY_UP): diff --git a/radio/src/gui/horus/widgets.cpp b/radio/src/gui/horus/widgets.cpp index 24cc020f7d..f9e0f9fabb 100644 --- a/radio/src/gui/horus/widgets.cpp +++ b/radio/src/gui/horus/widgets.cpp @@ -143,8 +143,13 @@ void drawMenuTemplate(const char * title, uint16_t scrollbar_X, uint32_t options if (menuPageCount > 0) { lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, MENU_TITLE_TOP - MENU_HEADER_HEIGHT, TEXT_BGCOLOR); lcdDrawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT, TITLE_BGCOLOR); - lcdDrawSolidFilledRect(0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT, TEXT_BGCOLOR); - lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); + if (options & OPTION_MENU_NO_FOOTER) { + lcdDrawSolidFilledRect(0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT+MENU_FOOTER_HEIGHT, TEXT_BGCOLOR); + } + else { + lcdDrawSolidFilledRect(0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT, TEXT_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); + } if (menuVerticalPosition < 0) { lcdDrawBitmapPattern(58+menuPageIndex*MENU_ICONS_SPACING-10, 0, LBM_CURRENT_BG, TITLE_BGCOLOR); } @@ -187,35 +192,33 @@ void drawMenuTemplate(const char * title, uint16_t scrollbar_X, uint32_t options } } -void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X) +void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X, uint32_t options) { // clear the screen lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); - lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, MENU_TITLE_TOP-MENU_HEADER_HEIGHT, TEXT_BGCOLOR); - lcdDrawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, LCD_H-MENU_TITLE_TOP, TEXT_BGCOLOR); - lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR); - - lcdDrawSolidFilledRect(58+menuPageIndex*MENU_ICONS_SPACING-9, 0, 32, MENU_HEADER_HEIGHT, TITLE_BGCOLOR); + if (options & OPTION_MENU_NO_FOOTER) { + lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, LCD_H-MENU_HEADER_HEIGHT, TEXT_BGCOLOR); + } + else { + lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TEXT_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); + } const uint8_t * const * icons = (menuVerticalPositions[0] == 0 ? LBM_MODEL_ICONS : LBM_RADIO_ICONS); - lcdDrawBitmapPattern(5, 7, icons[0], MENU_TITLE_COLOR); - - for (int i=0; i NUM_BODY_LINES+1) { - drawVerticalScrollbar(scrollbar_X, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H+MENU_FOOTER_HEIGHT, menuVerticalOffset, linesCount, NUM_BODY_LINES+1); + drawVerticalScrollbar(scrollbar_X, DEFAULT_SCROLLBAR_Y-FH, DEFAULT_SCROLLBAR_H+MENU_FOOTER_HEIGHT, menuVerticalOffset, linesCount, NUM_BODY_LINES+1); } } diff --git a/radio/src/gui/horus/widgets.h b/radio/src/gui/horus/widgets.h index 6aebf365e5..2f199115f6 100644 --- a/radio/src/gui/horus/widgets.h +++ b/radio/src/gui/horus/widgets.h @@ -24,7 +24,8 @@ #include "../../opentx.h" #include -#define OPTION_MENU_NO_FOOTER 0x01 +#define OPTION_MENU_NO_FOOTER 0x01 +//#define OPTION_MENU_NO_TITLE_BAR 0x02 #define OPTION_SLIDER_INVERS INVERS #define OPTION_SLIDER_BLINK BLINK @@ -67,7 +68,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int // Screen templates void drawMenuTemplate(const char * title, uint16_t scrollbar_X=0, uint32_t options=0); -void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X=0); +void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X=0, uint32_t options=0); void drawSplash(); void drawSleepBitmap(); void drawShutdownBitmap(uint32_t index); diff --git a/radio/src/sdcard.cpp b/radio/src/sdcard.cpp index ddb7547546..3da23a2798 100644 --- a/radio/src/sdcard.cpp +++ b/radio/src/sdcard.cpp @@ -94,7 +94,7 @@ int findNextFileIndex(char * filename, const char * directory) char extension[LEN_FILE_EXTENSION+1]; strncpy(extension, getFileExtension(filename), sizeof(extension)); do { - char * pos = strAppendNumber(indexPos, ++index, 2); + char * pos = strAppendUnsigned(indexPos, ++index, 2); strAppend(pos, extension); if (!isFileAvailable(filename, directory)) { return index; diff --git a/radio/src/strhelpers.cpp b/radio/src/strhelpers.cpp index bce2f02585..8e6a901bfb 100644 --- a/radio/src/strhelpers.cpp +++ b/radio/src/strhelpers.cpp @@ -145,7 +145,7 @@ char * strcat_zchar(char * dest, const char * name, uint8_t size, const char * d #endif #endif -char * strAppendNumber(char * dest, unsigned int value, uint8_t digits, uint8_t radix) +char * strAppendUnsigned(char * dest, uint32_t value, uint8_t digits, uint8_t radix) { if (digits == 0) { unsigned int tmp = value; @@ -165,6 +165,15 @@ char * strAppendNumber(char * dest, unsigned int value, uint8_t digits, uint8_t return &dest[digits]; } +char * strAppendSigned(char * dest, int32_t value, uint8_t digits, uint8_t radix) +{ + if (value < 0) { + *dest++ = '-'; + value = -value; + } + return strAppendUnsigned(dest, (uint32_t)value, digits, radix); +} + #if defined(CPUARM) || defined(SDCARD) char * strAppend(char * dest, const char * source, int len) { diff --git a/radio/src/strhelpers.h b/radio/src/strhelpers.h index fa19533463..48803bbceb 100644 --- a/radio/src/strhelpers.h +++ b/radio/src/strhelpers.h @@ -19,7 +19,8 @@ */ char * strAppend(char * dest, const char * source, int len=0); -char * strAppendNumber(char * dest, unsigned int value, uint8_t digits=0, uint8_t radix=10); +char * strAppendUnsigned(char * dest, uint32_t value, uint8_t digits=0, uint8_t radix=10); +char * strAppendSigned(char * dest, int32_t value, uint8_t digits=0, uint8_t radix=10); char * strSetCursor(char * dest, int position); char * strAppendDate(char * str, bool time=false); char * strAppendFilename(char * dest, const char * filename, const int size); diff --git a/radio/src/targets/horus/board_horus.cpp b/radio/src/targets/horus/board_horus.cpp index c9c715760f..b689e668ce 100644 --- a/radio/src/targets/horus/board_horus.cpp +++ b/radio/src/targets/horus/board_horus.cpp @@ -42,11 +42,11 @@ void watchdogInit(unsigned int duration) void getCPUUniqueID(char * s) { uint32_t * cpu_uid = (uint32_t *)0x1FFF7A10; - char * tmp = strAppendNumber(s, cpu_uid[0], 8, 16); + char * tmp = strAppendUnsigned(s, cpu_uid[0], 8, 16); *tmp = ' '; - tmp = strAppendNumber(tmp+1, cpu_uid[1], 8, 16); + tmp = strAppendUnsigned(tmp+1, cpu_uid[1], 8, 16); *tmp = ' '; - strAppendNumber(tmp+1, cpu_uid[2], 8, 16); + strAppendUnsigned(tmp+1, cpu_uid[2], 8, 16); } // Start TIMER7 at 2000000Hz diff --git a/radio/src/targets/taranis/board_taranis.cpp b/radio/src/targets/taranis/board_taranis.cpp index ce835c1bbe..516e3b4cb8 100644 --- a/radio/src/targets/taranis/board_taranis.cpp +++ b/radio/src/targets/taranis/board_taranis.cpp @@ -42,11 +42,11 @@ void watchdogInit(unsigned int duration) void getCPUUniqueID(char * s) { uint32_t * cpu_uid = (uint32_t *)0x1FFF7A10; - char * tmp = strAppendNumber(s, cpu_uid[0], 8, 16); + char * tmp = strAppendUnsigned(s, cpu_uid[0], 8, 16); *tmp = ' '; - tmp = strAppendNumber(tmp+1, cpu_uid[1], 8, 16); + tmp = strAppendUnsigned(tmp+1, cpu_uid[1], 8, 16); *tmp = ' '; - strAppendNumber(tmp+1, cpu_uid[2], 8, 16); + strAppendUnsigned(tmp+1, cpu_uid[2], 8, 16); } // Starts TIMER at 2MHz