[X9E/X7D] Rotary encoder navigation speed implemented (#3724)

This commit is contained in:
Bertrand Songis
2016-08-27 18:19:44 +02:00
committed by Andre Bernet
parent 3cb64d984a
commit 1d735f2bd3
114 changed files with 785 additions and 865 deletions
+43 -37
View File
@@ -146,21 +146,21 @@ extern const CheckIncDecStops &stopsSwitch;
const CheckIncDecStops &var = (const CheckIncDecStops&)_ ## var;
#define CATEGORY_END(val) \
(val), (val+1)
int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags=0, IsValueAvailable isValueAvailable=NULL, const CheckIncDecStops &stops=stops100);
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags=0, IsValueAvailable isValueAvailable=NULL, const CheckIncDecStops &stops=stops100);
#else
int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
int16_t checkIncDec(event_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0);
#endif
int8_t checkIncDecMovedSwitch(int8_t val);
#if defined(CPUM64)
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
int8_t checkIncDecModelZero(uint8_t event, int8_t i_val, int8_t i_max);
int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
int8_t checkIncDecModel(event_t event, int8_t i_val, int8_t i_min, int8_t i_max);
int8_t checkIncDecModelZero(event_t event, int8_t i_val, int8_t i_max);
int8_t checkIncDecGen(event_t event, int8_t i_val, int8_t i_min, int8_t i_max);
#else
#define checkIncDecModel(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_MODEL)
#define checkIncDecModelZero(event, i_val, i_max) checkIncDec(event, i_val, 0, i_max, EE_MODEL)
#define checkIncDecGen(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_GENERAL)
#define checkIncDecModel(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_MODEL)
#define checkIncDecModelZero(event, i_val, i_max) checkIncDec(event, i_val, 0, i_max, EE_MODEL)
#define checkIncDecGen(event, i_val, i_min, i_max) checkIncDec(event, i_val, i_min, i_max, EE_GENERAL)
#endif
#define CHECK_INCDEC_MODELVAR(event, var, min, max) \
@@ -289,9 +289,9 @@ typedef int choice_t;
typedef int8_t choice_t;
#endif
choice_t editChoice(coord_t x, coord_t y, const pm_char * label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, uint8_t event);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char * label, LcdFlags attr, uint8_t event);
int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event);
choice_t editChoice(coord_t x, coord_t y, const pm_char * label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char * label, LcdFlags attr, event_t event);
int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, event_t event);
#define ON_OFF_MENU_ITEM(value, x, y, label, attr, event) value = editCheckBox(value, x, y, label, attr, event)
@@ -301,27 +301,29 @@ int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t eve
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) editGVarFieldValue(x, y, v, min, max, attr, event)
#endif
#if defined(GVARS)
#if defined(CPUARM)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event);
#else
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); // @@@ open.20.fsguruh
#endif
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#if defined(GVARS) && defined(CPUARM)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, event_t event);
#elif defined(GVARS)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, event_t event);
#else
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event);
#define displayGVar(x, y, v, min, max) lcdDraw8bitsNumber(x, y, v)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, event_t event);
#endif
void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active);
#if defined(GVARS)
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
#else
#define displayGVar(x, y, v, min, max) lcdDraw8bitsNumber(x, y, v)
#endif
void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, uint8_t active);
#if defined(CPUM64)
#define editSingleName(x, y, label, name, size, event, active) editName(x, y, name, size, event, active)
#else
void editSingleName(coord_t x, coord_t y, const pm_char *label, char *name, uint8_t size, uint8_t event, uint8_t active);
void editSingleName(coord_t x, coord_t y, const pm_char * label, char * name, uint8_t size, event_t event, uint8_t active);
#endif
uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char * str, uint8_t delay);
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const pm_char * str, uint8_t delay);
#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay)
#define WARNING_TYPE_ASTERISK 0
@@ -358,7 +360,7 @@ void drawStatusLine();
#if defined(CPUARM)
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void menuTextView(uint8_t event);
void menuTextView(event_t event);
void pushMenuTextView(const char *filename);
void pushModelNotes();
#endif
@@ -368,17 +370,21 @@ void drawStatusLine();
#define CURSOR_MOVED_LEFT(event) (IS_ROTARY_LEFT(event) || EVT_KEY_MASK(event) == KEY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (IS_ROTARY_RIGHT(event) || EVT_KEY_MASK(event) == KEY_RIGHT)
#if defined(ROTARY_ENCODERS)
#define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK:
#define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG:
#else
#define CASE_EVT_ROTARY_BREAK
#define CASE_EVT_ROTARY_LONG
#endif
#if defined(ROTARY_ENCODER_NAVIGATION)
#define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT)
#define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT)
#define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK)
#define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG)
#define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e)
#define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK:
#define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG:
#define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT:
#define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT:
void repeatLastCursorMove(uint8_t event);
void repeatLastCursorMove(event_t event);
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else repeatLastCursorMove(event); }
#define MOVE_CURSOR_FROM_HERE() if (menuHorizontalPosition > 0) REPEAT_LAST_CURSOR_MOVE()
#else
@@ -387,17 +393,17 @@ void drawStatusLine();
#define IS_ROTARY_BREAK(evt) (0)
#define IS_ROTARY_LONG(evt) (0)
#define IS_ROTARY_EVENT(evt) (0)
#define CASE_EVT_ROTARY_BREAK
#define CASE_EVT_ROTARY_LONG
#define CASE_EVT_ROTARY_LEFT
#define CASE_EVT_ROTARY_RIGHT
void repeatLastCursorMove(uint8_t event);
void repeatLastCursorMove(event_t event);
#define REPEAT_LAST_CURSOR_MOVE() repeatLastCursorMove(event)
#define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE()
#endif
#define POS_HORZ_INIT(posVert) 0
// TODO enum
#if defined(PCBX7D)
#define EDIT_MODE_INIT 0
#else
#define EDIT_MODE_INIT -1
#endif
typedef int (*FnFuncP) (int x);
void drawFunction(FnFuncP fn, uint8_t offset=0);
@@ -457,12 +463,12 @@ void showAlertBox(const pm_char * title, const pm_char * text, const char * acti
#define IS_OTHER_VIEW_DISPLAYED() false
#if defined(CPUARM)
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, LcdFlags flags);
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
#endif
#if defined(FLIGHT_MODES)
void displayFlightModes(coord_t x, coord_t y, FlightModesType value);
FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModesType value, uint8_t attr);
FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModesType value, uint8_t attr);
#else
#define displayFlightModes(...)
#endif
+4 -4
View File
@@ -24,7 +24,7 @@
#include "view_mavlink.h"
#endif
uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay)
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const pm_char * str, uint8_t delay)
{
lcdDrawTextAlignedLeft(y, str);
lcdDrawNumber(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
@@ -46,7 +46,7 @@ uint8_t s_copySrcCh;
#endif
#if defined(PCBX7D)
void editName(coord_t x, coord_t y, char * name, uint8_t size, uint8_t event, uint8_t active/* TODO, uint8_t attr*/)
void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, uint8_t active/* TODO, uint8_t attr*/)
{
LcdFlags attr = ZCHAR; // TODO in args
uint8_t mode = 0;
@@ -135,7 +135,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, uint8_t event, ui
}
}
#else
void editName(coord_t x, coord_t y, char * name, uint8_t size, uint8_t event, uint8_t active)
void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, uint8_t active)
{
#if defined(CPUM64)
// in order to save flash
@@ -221,7 +221,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, uint8_t event, ui
#endif
#if !defined(CPUM64)
void editSingleName(coord_t x, coord_t y, const pm_char * label, char * name, uint8_t size, uint8_t event, uint8_t active)
void editSingleName(coord_t x, coord_t y, const pm_char * label, char * name, uint8_t size, event_t event, uint8_t active)
{
lcdDrawTextAlignedLeft(y, label);
editName(x, y, name, size, event, active);
+1 -1
View File
@@ -21,7 +21,7 @@
#include "opentx.h"
#if defined(CPUARM)
void menuRadioSpecialFunctions(uint8_t event)
void menuRadioSpecialFunctions(event_t event)
{
MENU(STR_MENUSPECIALFUNCS, menuTabGeneral, MENU_RADIO_SPECIAL_FUNCTIONS, HEADER_LINE+MAX_SPECIAL_FUNCTIONS, { HEADER_LINE_COLUMNS NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
return menuSpecialFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext);
+1 -1
View File
@@ -61,7 +61,7 @@ void pushMenu(MenuHandlerFunc newMenu)
}
#if defined(CPUARM)
void menuModelNotes(uint8_t event)
void menuModelNotes(event_t event)
{
if (event == EVT_ENTRY) {
strcpy(s_text_file, MODELS_PATH "/");
+36 -36
View File
@@ -39,7 +39,7 @@ typedef uint16_t vertpos_t;
typedef uint8_t vertpos_t;
#endif
typedef void (*MenuHandlerFunc)(uint8_t event);
typedef void (*MenuHandlerFunc)(event_t event);
#if defined(CPUARM)
extern tmr10ms_t menuEntryTime;
@@ -66,11 +66,11 @@ inline MenuHandlerFunc lastPopMenu()
void onMainViewMenu(const char * result);
void menuFirstCalib(uint8_t event);
void menuMainView(uint8_t event);
void menuViewTelemetryFrsky(uint8_t event);
void menuViewTelemetryMavlink(uint8_t event);
void menuSpecialFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
void menuFirstCalib(event_t event);
void menuMainView(event_t event);
void menuViewTelemetryFrsky(event_t event);
void menuViewTelemetryMavlink(event_t event);
void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
enum MenuRadioIndexes
{
@@ -86,15 +86,15 @@ enum MenuRadioIndexes
MENU_RADIO_PAGES_COUNT
};
void menuRadioSetup(uint8_t event);
void menuRadioSdManager(uint8_t event);
void menuRadioSpecialFunctions(uint8_t event);
void menuRadioTrainer(uint8_t event);
void menuRadioVersion(uint8_t event);
void menuRadioDiagKeys(uint8_t event);
void menuRadioDiagAnalogs(uint8_t event);
void menuRadioHardware(uint8_t event);
void menuRadioCalibration(uint8_t event);
void menuRadioSetup(event_t event);
void menuRadioSdManager(event_t event);
void menuRadioSpecialFunctions(event_t event);
void menuRadioTrainer(event_t event);
void menuRadioVersion(event_t event);
void menuRadioDiagKeys(event_t event);
void menuRadioDiagAnalogs(event_t event);
void menuRadioHardware(event_t event);
void menuRadioCalibration(event_t event);
static const MenuHandlerFunc menuTabGeneral[] PROGMEM = {
menuRadioSetup,
@@ -126,23 +126,23 @@ enum MenuModelIndexes {
MENU_MODEL_PAGES_COUNT
};
void menuModelSelect(uint8_t event);
void menuModelSetup(uint8_t event);
void menuModelHeli(uint8_t event);
void menuModelFlightModesAll(uint8_t event);
void menuModelExposAll(uint8_t event);
void menuModelMixAll(uint8_t event);
void menuModelLimits(uint8_t event);
void menuModelCurvesAll(uint8_t event);
void menuModelCurveOne(uint8_t event);
void menuModelGVars(uint8_t event);
void menuModelLogicalSwitches(uint8_t event);
void menuModelSpecialFunctions(uint8_t event);
void menuModelTelemetryFrsky(uint8_t event);
void menuModelTelemetryMavlink(uint8_t event);
void menuModelDisplay(uint8_t event);
void menuModelTemplates(uint8_t event);
void menuModelExpoOne(uint8_t event);
void menuModelSelect(event_t event);
void menuModelSetup(event_t event);
void menuModelHeli(event_t event);
void menuModelFlightModesAll(event_t event);
void menuModelExposAll(event_t event);
void menuModelMixAll(event_t event);
void menuModelLimits(event_t event);
void menuModelCurvesAll(event_t event);
void menuModelCurveOne(event_t event);
void menuModelGVars(event_t event);
void menuModelLogicalSwitches(event_t event);
void menuModelSpecialFunctions(event_t event);
void menuModelTelemetryFrsky(event_t event);
void menuModelTelemetryMavlink(event_t event);
void menuModelDisplay(event_t event);
void menuModelTemplates(event_t event);
void menuModelExpoOne(event_t event);
static const MenuHandlerFunc menuTabModel[] PROGMEM = {
menuModelSelect,
@@ -161,12 +161,12 @@ static const MenuHandlerFunc menuTabModel[] PROGMEM = {
CASE_TEMPLATES(menuModelTemplates)
};
void menuStatisticsView(uint8_t event);
void menuStatisticsDebug(uint8_t event);
void menuAboutView(uint8_t event);
void menuStatisticsView(event_t event);
void menuStatisticsDebug(event_t event);
void menuAboutView(event_t event);
#if defined(DEBUG_TRACE_BUFFER)
void menuTraceBuffer(uint8_t event);
void menuTraceBuffer(event_t event);
#endif
#endif // _MENUS_H_
+2 -2
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void displayPresetChoice(uint8_t event)
void displayPresetChoice(event_t event)
{
runPopupWarning(event);
lcdDrawNumber(WARNING_LINE_X+FW*7, WARNING_LINE_Y, 45*warningInputValue/4, LEFT|INVERS);
@@ -64,7 +64,7 @@ void onCurveOneMenu(const char * result)
}
}
void menuModelCurveOne(uint8_t event)
void menuModelCurveOne(event_t event)
{
CurveData & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuModelCurveOne(uint8_t event)
void menuModelCurveOne(event_t event)
{
TITLE(STR_MENUCURVE);
lcdDrawNumber(PSIZE(TR_MENUCURVE)*FW+1, 0, s_curveChan+1, INVERS|LEFT);
+1 -1
View File
@@ -82,7 +82,7 @@ void onTelemetryScriptFileSelectionMenu(const char *result)
}
#endif
void menuModelDisplay(uint8_t event)
void menuModelDisplay(event_t event)
{
MENU(STR_MENU_DISPLAY, menuTabModel, MENU_MODEL_DISPLAY, HEADER_LINE + ITEM_DISPLAY_MAX, { HEADER_LINE_COLUMNS TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), TELEMETRY_SCREEN_ROWS(2), TELEMETRY_SCREEN_ROWS(3) });
+3 -3
View File
@@ -32,7 +32,7 @@ void displayFlightModes(coord_t x, coord_t y, FlightModesType value)
}
#if !defined(CPUARM)
FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModesType value, uint8_t attr)
FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModesType value, uint8_t attr)
{
drawFieldLabel(x, y, STR_FLMODE);
@@ -84,7 +84,7 @@ bool isTrimModeAvailable(int mode)
return (mode < 0 || (mode%2) == 0 || (mode/2) != s_currIdx);
}
void menuModelPhaseOne(uint8_t event)
void menuModelPhaseOne(event_t event)
{
FlightModeData * fm = flightModeAddress(s_currIdx);
drawFlightMode(13*FW, 0, s_currIdx+1, (getFlightMode()==s_currIdx ? BOLD : 0));
@@ -246,7 +246,7 @@ void menuModelPhaseOne(uint8_t event)
#define TRIMS_OFS (FW/2)
#endif
void menuModelFlightModesAll(uint8_t event)
void menuModelFlightModesAll(event_t event)
{
SIMPLE_MENU(STR_MENUFLIGHTMODES, menuTabModel, MENU_MODEL_FLIGHT_MODES, HEADER_LINE+MAX_FLIGHT_MODES+1);
+2 -2
View File
@@ -175,7 +175,7 @@ enum ExposFields {
EXPO_FIELD_MAX
};
void menuModelExpoOne(uint8_t event)
void menuModelExpoOne(event_t event)
{
if (event == EVT_KEY_LONG(KEY_MENU)) {
// TODO pushMenu(menuChannelsView);
@@ -350,7 +350,7 @@ void displayExpoLine(coord_t y, ExpoData * ed)
displayFlightModes(EXPO_LINE_INFOS_POS, y, ed->flightModes);
}
void menuModelExposAll(uint8_t event)
void menuModelExposAll(event_t event)
{
int8_t sub = menuVerticalPosition - HEADER_LINE;
+6 -6
View File
@@ -229,7 +229,7 @@ enum ExposFields {
#define CURVE_ROWS 0
void menuModelExpoOne(uint8_t event)
void menuModelExpoOne(event_t event)
{
ExpoData * ed = expoAddress(s_currIdx);
drawSource(7*FW+FW/2, 0, MIXSRC_Rud+ed->chn, 0);
@@ -339,7 +339,7 @@ enum MixFields {
MIX_FIELD_COUNT
};
void gvarWeightItem(coord_t x, coord_t y, MixData *md, uint8_t attr, uint8_t event)
void gvarWeightItem(coord_t x, coord_t y, MixData * md, uint8_t attr, event_t event)
{
u_int8int16_t weight;
MD_WEIGHT_TO_UNION(md, weight);
@@ -400,7 +400,7 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
#undef GAUGE_HEIGHT
#endif
void menuModelMixOne(uint8_t event)
void menuModelMixOne(event_t event)
{
TITLE(STR_MIXER);
MixData * md2 = mixAddress(s_currIdx) ;
@@ -658,7 +658,7 @@ void displayExpoLine(coord_t y, ExpoData *ed)
displayFlightModes(EXPO_LINE_FM_POS, y, ed->flightModes)
#endif
void menuModelExpoMix(uint8_t expo, uint8_t event)
void menuModelExpoMix(uint8_t expo, event_t event)
{
uint8_t sub = menuVerticalPosition;
@@ -920,12 +920,12 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
if (sub >= s_maxLines-1) menuVerticalPosition = s_maxLines-1;
}
void menuModelExposAll(uint8_t event)
void menuModelExposAll(event_t event)
{
return menuModelExpoMix(1, event);
}
void menuModelMixAll(uint8_t event)
void menuModelMixAll(event_t event)
{
return menuModelExpoMix(0, event);
}
@@ -58,7 +58,7 @@ void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lat
#define CSWONE_2ND_COLUMN (11*FW)
void menuModelLogicalSwitchOne(uint8_t event)
void menuModelLogicalSwitchOne(event_t event)
{
TITLE(STR_MENULOGICALSWITCH);
@@ -215,7 +215,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
}
}
void menuModelLogicalSwitches(uint8_t event)
void menuModelLogicalSwitches(event_t event)
{
SIMPLE_MENU(STR_MENULOGICALSWITCHES, menuTabModel, MENU_MODEL_LOGICAL_SWITCHES, HEADER_LINE+MAX_LOGICAL_SWITCHES);
@@ -294,7 +294,7 @@ void menuModelLogicalSwitches(uint8_t event)
#else
void menuModelLogicalSwitches(uint8_t event)
void menuModelLogicalSwitches(event_t event)
{
INCDEC_DECLARE_VARS(EE_MODEL);
+3 -3
View File
@@ -142,7 +142,7 @@ enum MixFields {
MIX_FIELD_COUNT
};
void gvarWeightItem(coord_t x, coord_t y, MixData *md, uint8_t attr, uint8_t event)
void gvarWeightItem(coord_t x, coord_t y, MixData *md, uint8_t attr, event_t event)
{
u_int8int16_t weight;
MD_WEIGHT_TO_UNION(md, weight);
@@ -195,7 +195,7 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
}
}
void menuModelMixOne(uint8_t event)
void menuModelMixOne(event_t event)
{
if (event == EVT_KEY_LONG(KEY_MENU)) {
// TODO pushMenu(menuChannelsView);
@@ -375,7 +375,7 @@ void displayMixLine(coord_t y, MixData * md)
displayFlightModes(MIX_LINE_FM_POS, y, md->flightModes);
}
void menuModelMixAll(uint8_t event)
void menuModelMixAll(event_t event)
{
int8_t sub = menuVerticalPosition - HEADER_LINE;
+1 -1
View File
@@ -87,7 +87,7 @@ enum MenuModelOutputsItems {
#define MIN_MAX_DISPLAY(x) ((int8_t)(x))
#endif
void menuModelLimits(uint8_t event)
void menuModelLimits(event_t event)
{
uint8_t sub = menuVerticalPosition - HEADER_LINE;
+183 -179
View File
@@ -20,11 +20,11 @@
#include "opentx.h"
#define MODELSIZE_POS_X 170
#define MODELSEL_W LCD_W
#define MODELSIZE_POS_X 170
#define MODELSEL_W LCD_W
#if defined(NAVIGATION_MENUS)
void onModelSelectMenu(const char *result)
void onModelSelectMenu(const char * result)
{
int8_t sub = menuVerticalPosition;
@@ -75,7 +75,7 @@ void onModelSelectMenu(const char *result)
}
#endif
void menuModelSelect(uint8_t event)
void menuModelSelect(event_t event)
{
if (warningResult) {
warningResult = 0;
@@ -84,7 +84,7 @@ void menuModelSelect(uint8_t event)
event = EVT_ENTRY_UP;
}
uint8_t _event_ = (IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event) ? 0 : event);
event_t _event_ = (IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event) ? 0 : event);
if ((s_copyMode && EVT_KEY_MASK(event) == KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) {
_event_ -= KEY_EXIT;
@@ -111,205 +111,209 @@ void menuModelSelect(uint8_t event)
int8_t sub = menuVerticalPosition;
switch (event) {
case EVT_ENTRY:
case EVT_ENTRY:
menuVerticalPosition = sub = g_eeGeneral.currModel;
if (sub >= LCD_LINES-1) menuVerticalOffset = sub-LCD_LINES+2;
s_copyMode = 0;
s_editMode = EDIT_MODE_INIT;
storageCheck(true);
break;
case EVT_KEY_LONG(KEY_EXIT):
killEvents(event);
if (s_copyMode && s_copyTgtOfs == 0 && g_eeGeneral.currModel != sub && eeModelExists(sub)) {
POPUP_CONFIRMATION(STR_DELETEMODEL);
#if defined(CPUARM)
SET_WARNING_INFO(modelHeaders[sub].name, sizeof(g_model.header.name), ZCHAR);
#else
char * name = reusableBuffer.modelsel.mainname;
eeLoadModelName(sub, name);
SET_WARNING_INFO(name, sizeof(g_model.header.name), ZCHAR);
#endif
}
else {
s_copyMode = 0;
menuVerticalPosition = g_eeGeneral.currModel;
}
break;
#if defined(ROTARY_ENCODERS)
case EVT_ROTARY_LONG:
killEvents(event);
if (s_editMode < 0) {
popMenu();
break;
}
else if (!s_copyMode) {
menuVerticalPosition = sub = g_eeGeneral.currModel;
if (sub >= LCD_LINES-1) menuVerticalOffset = sub-LCD_LINES+2;
s_copyMode = 0;
s_editMode = EDIT_MODE_INIT;
storageCheck(true);
break;
case EVT_KEY_LONG(KEY_EXIT):
killEvents(event);
if (s_copyMode && s_copyTgtOfs == 0 && g_eeGeneral.currModel != sub && eeModelExists(sub)) {
POPUP_CONFIRMATION(STR_DELETEMODEL);
#if defined(CPUARM)
SET_WARNING_INFO(modelHeaders[sub].name, sizeof(g_model.header.name), ZCHAR);
#else
char * name = reusableBuffer.modelsel.mainname;
eeLoadModelName(sub, name);
SET_WARNING_INFO(name, sizeof(g_model.header.name), ZCHAR);
#endif
}
else {
s_copyMode = 0;
menuVerticalPosition = g_eeGeneral.currModel;
}
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LONG:
killEvents(event);
if (s_editMode < 0) {
popMenu();
break;
}
else if (!s_copyMode) {
menuVerticalPosition = sub = g_eeGeneral.currModel;
s_copyMode = 0;
s_editMode = EDIT_MODE_INIT;
}
// no break
}
// no break
#endif
case EVT_KEY_BREAK(KEY_EXIT):
if (s_copyMode) {
sub = menuVerticalPosition = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow;
s_copyMode = 0;
}
else if (uint8_t(menuVerticalPosition) != g_eeGeneral.currModel) {
menuVerticalPosition = g_eeGeneral.currModel;
}
else {
popMenu();
}
break;
case EVT_KEY_BREAK(KEY_EXIT):
if (s_copyMode) {
sub = menuVerticalPosition = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow;
s_copyMode = 0;
}
else if (uint8_t(menuVerticalPosition) != g_eeGeneral.currModel) {
menuVerticalPosition = g_eeGeneral.currModel;
}
else {
popMenu();
}
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_BREAK:
if (s_editMode == -1) {
s_editMode = 0;
break;
}
// no break;
#endif
case EVT_KEY_LONG(KEY_ENTER):
case EVT_KEY_BREAK(KEY_ENTER):
#if defined(ROTARY_ENCODERS)
case EVT_ROTARY_BREAK:
if (s_editMode == -1) {
s_editMode = 0;
if (READ_ONLY()) {
if (g_eeGeneral.currModel != sub && eeModelExists(sub)) {
selectModel(sub);
}
}
else if (s_copyMode && (s_copyTgtOfs || s_copySrcRow>=0)) {
showMessageBox(s_copyMode==COPY_MODE ? STR_COPYINGMODEL : STR_MOVINGMODEL);
storageCheck(true); // force writing of current model data before this is changed
uint8_t cur = (MAX_MODELS + sub + s_copyTgtOfs) % MAX_MODELS;
if (s_copyMode == COPY_MODE) {
if (!eeCopyModel(cur, s_copySrcRow)) {
cur = sub;
}
}
s_copySrcRow = g_eeGeneral.currModel; // to update the currModel value
while (sub != cur) {
uint8_t src = cur;
cur = (s_copyTgtOfs > 0 ? cur+MAX_MODELS-1 : cur+1) % MAX_MODELS;
eeSwapModels(src, cur);
if (src == s_copySrcRow)
s_copySrcRow = cur;
else if (cur == s_copySrcRow)
s_copySrcRow = src;
}
if (s_copySrcRow != g_eeGeneral.currModel) {
g_eeGeneral.currModel = s_copySrcRow;
storageDirty(EE_GENERAL);
}
s_copyMode = 0;
event = EVT_ENTRY_UP;
}
else if (event == EVT_KEY_LONG(KEY_ENTER) || IS_ROTARY_BREAK(event)) {
s_copyMode = 0;
killEvents(event);
#if defined(NAVIGATION_MENUS)
if (g_eeGeneral.currModel != sub) {
if (eeModelExists(sub)) {
POPUP_MENU_ADD_ITEM(STR_SELECT_MODEL);
POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
POPUP_MENU_ADD_ITEM(STR_COPY_MODEL);
POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL);
POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL);
}
else {
#if defined(SDCARD)
POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL);
POPUP_MENU_ADD_ITEM(STR_RESTORE_MODEL);
#else
selectModel(sub);
break;
}
// no break;
#endif
}
case EVT_KEY_LONG(KEY_ENTER):
case EVT_KEY_BREAK(KEY_ENTER):
s_editMode = 0;
if (READ_ONLY()) {
if (g_eeGeneral.currModel != sub && eeModelExists(sub)) {
selectModel(sub);
}
}
else if (s_copyMode && (s_copyTgtOfs || s_copySrcRow>=0)) {
showMessageBox(s_copyMode==COPY_MODE ? STR_COPYINGMODEL : STR_MOVINGMODEL);
storageCheck(true); // force writing of current model data before this is changed
uint8_t cur = (MAX_MODELS + sub + s_copyTgtOfs) % MAX_MODELS;
if (s_copyMode == COPY_MODE) {
if (!eeCopyModel(cur, s_copySrcRow)) {
cur = sub;
}
else {
}
s_copySrcRow = g_eeGeneral.currModel; // to update the currModel value
while (sub != cur) {
uint8_t src = cur;
cur = (s_copyTgtOfs > 0 ? cur+MAX_MODELS-1 : cur+1) % MAX_MODELS;
eeSwapModels(src, cur);
if (src == s_copySrcRow)
s_copySrcRow = cur;
else if (cur == s_copySrcRow)
s_copySrcRow = src;
}
if (s_copySrcRow != g_eeGeneral.currModel) {
g_eeGeneral.currModel = s_copySrcRow;
storageDirty(EE_GENERAL);
}
s_copyMode = 0;
event = EVT_ENTRY_UP;
}
else if (event == EVT_KEY_LONG(KEY_ENTER) || IS_ROTARY_BREAK(event)) {
s_copyMode = 0;
killEvents(event);
#if defined(NAVIGATION_MENUS)
if (g_eeGeneral.currModel != sub) {
if (eeModelExists(sub)) {
POPUP_MENU_ADD_ITEM(STR_SELECT_MODEL);
POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
POPUP_MENU_ADD_ITEM(STR_COPY_MODEL);
POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL);
POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL);
}
POPUP_MENU_START(onModelSelectMenu);
else {
#if defined(SDCARD)
POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL);
POPUP_MENU_ADD_ITEM(STR_RESTORE_MODEL);
#else
if (g_eeGeneral.currModel != sub) {
selectModel(sub);
#endif
}
#endif
}
else if (eeModelExists(sub)) {
s_copyMode = (s_copyMode == COPY_MODE ? MOVE_MODE : COPY_MODE);
s_copyTgtOfs = 0;
s_copySrcRow = -1;
}
break;
#if defined(PCBX7D)
case EVT_KEY_LONG(KEY_PAGE):
chainMenu(menuTabModel[DIM(menuTabModel)-1]);
killEvents(event);
break;
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuModelSetup);
break;
#else
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
case EVT_KEY_FIRST(KEY_LEFT):
case EVT_KEY_FIRST(KEY_RIGHT):
#if defined(ROTARY_ENCODER_NAVIGATION)
if ((!IS_ROTARY_RIGHT(event) && !IS_ROTARY_LEFT(event)) || s_editMode < 0) {
#endif
if (sub == g_eeGeneral.currModel) {
chainMenu((IS_ROTARY_RIGHT(event) || event == EVT_KEY_FIRST(KEY_RIGHT)) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1]);
}
else {
AUDIO_WARNING2();
POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
POPUP_MENU_ADD_ITEM(STR_COPY_MODEL);
POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL);
}
break;
POPUP_MENU_START(onModelSelectMenu);
#else
if (g_eeGeneral.currModel != sub) {
selectModel(sub);
}
#endif
}
else if (eeModelExists(sub)) {
s_copyMode = (s_copyMode == COPY_MODE ? MOVE_MODE : COPY_MODE);
s_copyTgtOfs = 0;
s_copySrcRow = -1;
}
break;
#if defined(PCBX7D)
case EVT_KEY_LONG(KEY_PAGE):
chainMenu(menuTabModel[DIM(menuTabModel)-1]);
killEvents(event);
break;
case EVT_KEY_BREAK(KEY_PAGE):
chainMenu(menuModelSetup);
break;
#else
#if defined(ROTARY_ENCODER_NAVIGATION)
}
// no break
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
case EVT_KEY_FIRST(KEY_LEFT):
case EVT_KEY_FIRST(KEY_RIGHT):
#if defined(ROTARY_ENCODER_NAVIGATION)
if ((!IS_ROTARY_RIGHT(event) && !IS_ROTARY_LEFT(event)) || s_editMode < 0) {
#endif
if (sub == g_eeGeneral.currModel) {
chainMenu((IS_ROTARY_RIGHT(event) || event == EVT_KEY_FIRST(KEY_RIGHT)) ? menuModelSetup : menuTabModel[DIM(menuTabModel)-1]);
}
else {
AUDIO_WARNING2();
}
break;
#if defined(ROTARY_ENCODER_NAVIGATION)
}
// no break
#endif
#endif
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_REPT(KEY_UP):
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_REPT(KEY_DOWN):
if (s_copyMode) {
int8_t next_ofs = s_copyTgtOfs + oldSub - menuVerticalPosition;
if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS)
next_ofs = 0;
#if defined(PCBX7D)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
case EVT_KEY_FIRST(KEY_UP):
case EVT_KEY_REPT(KEY_UP):
case EVT_KEY_FIRST(KEY_DOWN):
case EVT_KEY_REPT(KEY_DOWN):
if (s_copyMode) {
int8_t next_ofs = s_copyTgtOfs + oldSub - menuVerticalPosition;
if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS)
next_ofs = 0;
if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) {
s_copySrcRow = oldSub;
// find a hole (in the first empty slot above / below)
sub = eeFindEmptyModel(s_copySrcRow, IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_DOWN));
if (sub < 0) {
// no free room for duplicating the model
AUDIO_ERROR();
sub = oldSub;
s_copyMode = 0;
}
next_ofs = 0;
menuVerticalPosition = sub;
if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) {
s_copySrcRow = oldSub;
// find a hole (in the first empty slot above / below)
sub = eeFindEmptyModel(s_copySrcRow, IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_DOWN));
if (sub < 0) {
// no free room for duplicating the model
AUDIO_ERROR();
sub = oldSub;
s_copyMode = 0;
}
s_copyTgtOfs = next_ofs;
next_ofs = 0;
menuVerticalPosition = sub;
}
break;
s_copyTgtOfs = next_ofs;
}
break;
}
#if defined(EEPROM_RLC) && defined(CPUARM)
@@ -325,7 +329,7 @@ void menuModelSelect(uint8_t event)
#if defined(PCBX7D)
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), 0);
#elif defined(ROTARY_ENCODER_NAVIGATION)
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_RE_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_ROTARY_ENCODER_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0);
#else
drawScreenIndex(MENU_MODEL_SELECT, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0);
#endif
+3 -3
View File
@@ -22,7 +22,7 @@
#if defined(CPUARM)
uint8_t g_moduleIdx;
void menuModelFailsafe(uint8_t event);
void menuModelFailsafe(event_t event);
#endif
enum MenuModelSetupItems {
@@ -190,7 +190,7 @@ enum MenuModelSetupItems {
#define MODEL_SETUP_MAX_LINES ((IS_PPM_PROTOCOL(protocol)||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? HEADER_LINE+ITEM_MODEL_SETUP_MAX : HEADER_LINE+ITEM_MODEL_SETUP_MAX-1)
#endif
void menuModelSetup(uint8_t event)
void menuModelSetup(event_t event)
{
#if defined(CPUARM)
MENU_TAB({ HEADER_LINE_COLUMNS 0, TIMER_ROWS, TIMER_ROWS, TIMER_ROWS, 0, 1, 0, 0, 0, 0, 0, CASE_CPUARM(LABEL(PreflightCheck)) CASE_CPUARM(0) 0, NUM_SWITCHES-1, NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_ROTARY_ENCODERS-1, 0,
@@ -1080,7 +1080,7 @@ void menuModelSetup(uint8_t event)
}
#if defined(CPUARM)
void menuModelFailsafe(uint8_t event)
void menuModelFailsafe(event_t event)
{
static bool longNames = false;
bool newLongNames = false;
@@ -70,7 +70,7 @@ void onCustomFunctionsFileSelectionMenu(const char *result)
}
#endif
void menuSpecialFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext)
void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext)
{
int8_t sub = menuVerticalPosition - HEADER_LINE;
@@ -375,7 +375,7 @@ void menuSpecialFunctions(uint8_t event, CustomFunctionData * functions, CustomF
}
}
void menuModelSpecialFunctions(uint8_t event)
void menuModelSpecialFunctions(event_t event)
{
MENU(STR_MENUCUSTOMFUNC, menuTabModel, MENU_MODEL_SPECIAL_FUNCTIONS, MAX_SPECIAL_FUNCTIONS+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/});
return menuSpecialFunctions(event, g_model.customFn, &modelFunctionsContext);
+2 -2
View File
@@ -212,7 +212,7 @@ enum SensorFields {
#define SENSOR_FILTER_ROWS (sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW)
#define SENSOR_PERSISTENT_ROWS (sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : HIDDEN_ROW)
void menuModelSensor(uint8_t event)
void menuModelSensor(event_t event)
{
TelemetrySensor * sensor = & g_model.telemetrySensors[s_currIdx];
@@ -458,7 +458,7 @@ void onSensorMenu(const char *result)
}
#endif
void menuModelTelemetryFrsky(uint8_t event)
void menuModelTelemetryFrsky(event_t event)
{
#if defined(CPUARM)
if (warningResult) {
+1 -1
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuModelTemplates(uint8_t event)
void menuModelTemplates(event_t event)
{
SIMPLE_MENU(STR_MENUTEMPLATES, menuTabModel, MENU_MODEL_TEMPLATES, 1+TMPL_COUNT);
+28 -44
View File
@@ -70,12 +70,12 @@ INIT_STOPS(stops100, 3, -100, 0, 100)
INIT_STOPS(stops1000, 3, -1000, 0, 1000)
INIT_STOPS(stopsSwitch, 15, SWSRC_FIRST, CATEGORY_END(-SWSRC_FIRST_LOGICAL_SWITCH), CATEGORY_END(-SWSRC_FIRST_TRIM), CATEGORY_END(-SWSRC_LAST_SWITCH+1), 0, CATEGORY_END(SWSRC_LAST_SWITCH), CATEGORY_END(SWSRC_FIRST_TRIM-1), CATEGORY_END(SWSRC_FIRST_LOGICAL_SWITCH-1), SWSRC_LAST)
#if defined(PCBX7D)
int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
#if defined(PCBX7D)
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
{
int newval = val;
#if defined(DBLKEYS)
#if 0 // TODO ? defined(DBLKEYS)
uint32_t in = KEYS_PRESSED();
if (!(i_flags & NO_DBLKEYS) && (EVT_KEY_MASK(event))) {
bool dblkey = true;
@@ -117,33 +117,23 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
}
#endif
if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_PLUS) || event==EVT_KEY_REPT(KEY_PLUS))) {
do {
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
newval += min(10, i_max-val);
}
else {
newval++;
}
} while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
if (s_editMode>0 && event==EVT_ROTARY_RIGHT) {
newval += min<int>(rotencSpeed, i_max-val);
while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max) {
newval++;
}
if (newval > i_max) {
newval = val;
killEvents(event);
AUDIO_KEY_ERROR();
}
}
else if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_MINUS) || event==EVT_KEY_REPT(KEY_MINUS))) {
do {
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
newval -= min(10, val-i_min);
}
else {
newval--;
}
} while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min);
else if (s_editMode>0 && event==EVT_ROTARY_LEFT) {
newval -= min<int>(rotencSpeed, val-i_min);
while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min) {
newval--;
}
if (newval < i_min) {
newval = val;
killEvents(event);
AUDIO_KEY_ERROR();
}
}
@@ -179,17 +169,8 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
#endif
if (newval != val) {
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && stops.contains(newval)) {
bool pause = (newval > val ? !stops.contains(newval+1) : !stops.contains(newval-1));
if (pause) {
pauseEvents(event); // delay before auto-repeat continues
}
}
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
if (!IS_KEY_REPT(event)) {
AUDIO_KEY_PRESS();
}
}
else {
checkIncDec_Ret = 0;
@@ -275,8 +256,8 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
#endif
return newval;
}
#else
int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
#else
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
{
int newval = val;
@@ -397,7 +378,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
}
#endif
#else
int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, uint8_t i_flags)
int16_t checkIncDec(event_t event, int16_t val, int16_t i_min, int16_t i_max, uint8_t i_flags)
{
int16_t newval = val;
@@ -497,17 +478,17 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
#endif
#if defined(CPUM64)
int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
int8_t checkIncDecModel(event_t event, int8_t i_val, int8_t i_min, int8_t i_max)
{
return checkIncDec(event, i_val, i_min, i_max, EE_MODEL);
}
int8_t checkIncDecModelZero(uint8_t event, int8_t i_val, int8_t i_max)
int8_t checkIncDecModelZero(event_t event, int8_t i_val, int8_t i_max)
{
return checkIncDecModel(event, i_val, 0, i_max);
}
int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
int8_t checkIncDecGen(event_t event, int8_t i_val, int8_t i_min, int8_t i_max)
{
return checkIncDec(event, i_val, i_min, i_max, EE_GENERAL);
}
@@ -522,9 +503,8 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max)
#define CURSOR_NOT_ALLOWED_IN_ROW(row) (MAXCOL(row) == TITLE_ROW)
#endif
#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#define INC(val, min, max) if (val<max) {val++;} else {val=min;}
#define DEC(val, min, max) if (val>min) {val--;} else {val=max;}
#define INC(val, min, max) if (val<max) {val++;} else {val=min;}
#define DEC(val, min, max) if (val>min) {val--;} else {val=max;}
#if defined(CPUARM)
tmr10ms_t menuEntryTime;
@@ -536,7 +516,6 @@ tmr10ms_t menuEntryTime;
#define COLATTR(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (const uint8_t)0 : (const uint8_t)(MAXCOL_RAW(row) & NAVIGATION_LINE_BY_LINE))
#define MENU_FIRST_LINE_EDIT (menuTab ? (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) : 0)
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
#define EDIT_MODE_INIT 0 // TODO enum
void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t menuTabSize, const pm_uint8_t * horTab, uint8_t horTabMax, vertpos_t rowcount)
{
@@ -649,6 +628,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
}
break;
case EVT_ROTARY_RIGHT:
case EVT_KEY_FIRST(KEY_RIGHT):
AUDIO_KEY_PRESS();
// no break
@@ -679,6 +659,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
l_posHorz = POS_HORZ_INIT(l_posVert);
break;
case EVT_ROTARY_LEFT:
case EVT_KEY_FIRST(KEY_LEFT):
AUDIO_KEY_PRESS();
// no break
@@ -777,6 +758,9 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
menuHorizontalPosition = l_posHorz;
}
#else
#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0)
#define POS_HORZ_INIT(posVert) 0
void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
{
vertpos_t l_posVert = menuVerticalPosition;
@@ -871,7 +855,7 @@ void check(event_t event, uint8_t curr, const MenuHandlerFunc *menuTab, uint8_t
}
#if defined(ROTARY_ENCODER_NAVIGATION)
if (IS_RE_NAVIGATION_ENABLE() && s_editMode < 0)
if (IS_ROTARY_ENCODER_NAVIGATION_ENABLE() && s_editMode < 0)
attr = INVERS|BLINK;
#endif
}
@@ -1144,7 +1128,7 @@ void check_submenu_simple(event_t event, uint8_t maxrow)
check_simple(event, 0, 0, 0, maxrow);
}
void repeatLastCursorMove(uint8_t event)
void repeatLastCursorMove(event_t event)
{
if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) {
putEvent(event);
+4 -11
View File
@@ -94,7 +94,7 @@ void showAlertBox(const pm_char * title, const pm_char * text, const char * acti
clearKeyEvents();
}
void runPopupWarning(uint8_t event)
void runPopupWarning(event_t event)
{
warningResult = false;
drawMessageBox();
@@ -103,18 +103,11 @@ void runPopupWarning(uint8_t event)
}
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH, warningType == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS);
switch (event) {
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_BREAK:
#endif
case EVT_KEY_BREAK(KEY_ENTER):
if (warningType == WARNING_TYPE_ASTERISK)
break;
warningResult = true;
// no break
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LONG:
killEvents(event);
#endif
case EVT_KEY_BREAK(KEY_EXIT):
warningText = NULL;
warningType = WARNING_TYPE_ASTERISK;
@@ -131,7 +124,7 @@ void runPopupWarning(uint8_t event)
}
#if defined(CPUARM)
void (*popupFunc)(uint8_t event) = NULL;
void (*popupFunc)(event_t event) = NULL;
#endif
#if defined(NAVIGATION_MENUS)
@@ -146,7 +139,7 @@ void (*popupMenuHandler)(const char * result);
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
#endif
const char * runPopupMenu(uint8_t event)
const char * runPopupMenu(event_t event)
{
const char * result = NULL;
@@ -164,7 +157,7 @@ const char * runPopupMenu(uint8_t event)
drawVerticalScrollbar(MENU_X+MENU_W-1, y+1, POPUP_MENU_MAX_LINES * (FH+1), popupMenuOffset, popupMenuNoItems, POPUP_MENU_MAX_LINES);
}
switch(event) {
switch (event) {
#if defined(ROTARY_ENCODER_NAVIGATION)
CASE_EVT_ROTARY_LEFT
#endif
+3 -3
View File
@@ -30,10 +30,10 @@
void drawMessageBox();
void showMessageBox(const pm_char * title);
void runPopupWarning(uint8_t event);
void runPopupWarning(event_t event);
#if defined(CPUARM)
extern void (*popupFunc)(uint8_t event);
extern void (*popupFunc)(event_t event);
extern int16_t warningInputValue;
extern int16_t warningInputValueMin;
extern int16_t warningInputValueMax;
@@ -100,7 +100,7 @@ extern uint8_t warningInfoFlags;
extern uint16_t popupMenuOffset;
extern const char * popupMenuItems[POPUP_MENU_MAX_LINES];
extern uint16_t popupMenuNoItems;
const char * runPopupMenu(uint8_t event);
const char * runPopupMenu(event_t event);
extern void (*popupMenuHandler)(const char * result);
#endif
+3 -3
View File
@@ -31,7 +31,7 @@ enum CalibrationState {
CALIB_FINISHED
};
void menuCommonCalib(uint8_t event)
void menuCommonCalib(event_t event)
{
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) { // get low and high vals for sticks and trims
int16_t vt = anaIn(i);
@@ -108,7 +108,7 @@ void menuCommonCalib(uint8_t event)
doMainScreenGraphics();
}
void menuRadioCalibration(uint8_t event)
void menuRadioCalibration(event_t event)
{
check_simple(event, MENU_RADIO_CALIBRATION, menuTabGeneral, DIM(menuTabGeneral), 0);
@@ -120,7 +120,7 @@ void menuRadioCalibration(uint8_t event)
menuCommonCalib(READ_ONLY() ? 0 : event);
}
void menuFirstCalib(uint8_t event)
void menuFirstCalib(event_t event)
{
if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == CALIB_FINISHED) {
menuCalibrationState = CALIB_START;
+1 -1
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuRadioDiagAnalogs(uint8_t event)
void menuRadioDiagAnalogs(event_t event)
{
// TODO enum
#if defined(TX_CAPACITY_MEASUREMENT)
+8 -4
View File
@@ -26,7 +26,7 @@ void displayKeyState(uint8_t x, uint8_t y, uint8_t key)
lcdDrawChar(x, y, t+'0', t ? INVERS : 0);
}
void menuRadioDiagKeys(uint8_t event)
void menuRadioDiagKeys(event_t event)
{
SIMPLE_MENU(STR_MENU_RADIO_SWITCHES, menuTabGeneral, MENU_RADIO_SWITCHES_TEST, 1);
@@ -64,11 +64,15 @@ void menuRadioDiagKeys(uint8_t event)
#endif
}
#if defined(ROTARY_ENCODERS) || defined(ROTARY_ENCODER_NAVIGATION) // TODO || defined(PCBX7D)
for (uint8_t i=0; i<DIM(g_rotenc); i++) {
#if defined(ROTARY_ENCODER_NAVIGATION)
for (uint8_t i=0; i<DIM(rotencValue); i++) {
coord_t y = MENU_HEADER_HEIGHT /* ??? + 1 ??? */ + i*FH;
lcdDrawTextAtIndex(14*FW, y, STR_VRENCODERS, i, 0);
lcdDrawNumber(18*FW, y, g_rotenc[i], LEFT|(keyState(BTN_REa+i) ? INVERS : 0));
#if defined(ROTARY_ENCODERS)
lcdDrawNumber(18*FW, y, rotencValue[i], LEFT|(keyState(BTN_REa+i) ? INVERS : 0));
#else
lcdDrawNumber(18*FW, y, rotencValue[i], LEFT);
#endif
}
#endif
+1 -1
View File
@@ -33,7 +33,7 @@ enum MenuRadioHardwareItems {
};
#define GENERAL_HW_PARAM_OFS (2+(15*FW))
void menuRadioHardware(uint8_t event)
void menuRadioHardware(event_t event)
{
#if defined(PCBX7D)
#else
+4 -4
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuRadioSdManagerInfo(uint8_t event)
void menuRadioSdManagerInfo(event_t event)
{
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1);
@@ -56,7 +56,7 @@ inline bool isFilenameLower(bool isfile, const char * fn, const char * line)
return (!isfile && line[SD_SCREEN_FILE_LENGTH+1]) || (isfile==(bool)line[SD_SCREEN_FILE_LENGTH+1] && strcasecmp(fn, line) < 0);
}
void onSdManagerMenu(const char *result)
void onSdManagerMenu(const char * result)
{
TCHAR lfn[_MAX_LFN+1];
@@ -95,7 +95,7 @@ void onSdManagerMenu(const char *result)
#endif
}
void menuRadioSdManager(uint8_t _event)
void menuRadioSdManager(event_t _event)
{
#if defined(SDCARD)
if (warningResult) {
@@ -118,7 +118,7 @@ void menuRadioSdManager(uint8_t _event)
}
#endif
uint8_t event = ((READ_ONLY() && EVT_KEY_MASK(_event) == KEY_ENTER) ? 0 : _event);
event_t event = ((READ_ONLY() && EVT_KEY_MASK(_event) == KEY_ENTER) ? 0 : _event);
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, MENU_RADIO_SD_MANAGER, HEADER_LINE+reusableBuffer.sdmanager.count);
+3 -3
View File
@@ -117,7 +117,7 @@ enum MenuRadioSetupItems {
#define COL_TX_MODE LABEL(TX_MODE)
#endif
void menuRadioSetup(uint8_t event)
void menuRadioSetup(event_t event)
{
#if defined(RTCLOCK)
struct gtm t;
@@ -409,11 +409,11 @@ void menuRadioSetup(uint8_t event)
if(attr) g_eeGeneral.inactivityTimer = checkIncDec(event, g_eeGeneral.inactivityTimer, 0, 250, EE_GENERAL); //0..250minutes
break;
#if ROTARY_ENCODERS > 0
#if defined(ROTARY_ENCODERS)
case ITEM_SETUP_RE_NAVIGATION:
g_eeGeneral.reNavigation = editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_RENAVIG, STR_VRENAVIG, g_eeGeneral.reNavigation, 0, NUM_ROTARY_ENCODERS, attr, event);
if (attr && checkIncDec_Ret) {
g_rotenc[NAVIGATION_RE_IDX()] = 0;
ROTARY_ENCODER_NAVIGATION_VALUE = 0;
}
break;
#endif
+1 -1
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuRadioTrainer(uint8_t event)
void menuRadioTrainer(event_t event)
{
uint8_t y;
bool slave = SLAVE_MODE();
+1 -1
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuRadioVersion(uint8_t event)
void menuRadioVersion(event_t event)
{
#if defined(CPUARM) && defined(EEPROM_RLC)
if (warningResult) {
+1 -1
View File
@@ -42,7 +42,7 @@ enum AboutScreens {
#define ABOUT_X 2
#define ABOUT_INDENT 4
void menuAboutView(uint8_t event)
void menuAboutView(event_t event)
{
static uint8_t screenIndex;
static uint8_t greyIndex;
+1 -1
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuChannelsView(uint8_t event)
void menuChannelsView(event_t event)
{
static bool longNames = false;
bool newLongNames = false;
+1 -1
View File
@@ -283,7 +283,7 @@ void onMainViewMenu(const char *result)
}
#endif
void menuMainView(uint8_t event)
void menuMainView(event_t event)
{
STICK_SCROLL_DISABLE();
+3 -3
View File
@@ -35,7 +35,7 @@ uint8_t MAVLINK_menu = MENU_INFO;
* lanuched by the menu button. On exit (with exit button) the mavlink
* extension is reinitialized.
*/
void menuViewTelemetryMavlink(uint8_t event) {
void menuViewTelemetryMavlink(event_t event) {
switch (event) // new event received, branch accordingly
{
@@ -433,7 +433,7 @@ void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val) {
}
//! \brief Hex dump of the current mavlink message.
void menuTelemetryMavlinkDump(uint8_t event) {
void menuTelemetryMavlinkDump(event_t event) {
uint8_t x = 0;
uint8_t y = FH;
uint16_t count = 0;
@@ -481,7 +481,7 @@ void menuTelemetryMavlinkDump(uint8_t event) {
* This funcion is called from the model setup menus, not directly by the
* telemetry menus
*/
void menuModelTelemetryMavlink(uint8_t event) {
void menuModelTelemetryMavlink(event_t event) {
MENU(STR_MAVMENUSETUP_TITLE, menuTabModel, MENU_MODEL_TELEMETRY_MAVLINK, ITEM_MAVLINK_MAX + 1, {0, 0, 1/*to force edit mode*/});
+2 -2
View File
@@ -31,7 +31,7 @@
#define APSIZE (BSS | DBLSIZE)
void menuViewTelemetryMavlink(uint8_t event);
void menuViewTelemetryMavlink(event_t event);
void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode = 0);
void mav_title(const pm_char * s, uint8_t index);
void menuTelemetryMavlinkInfos(void);
@@ -41,7 +41,7 @@ void menuTelemetryMavlinkNavigation(void);
void menuTelemetryMavlinkGPS(void);
#ifdef DUMP_RX_TX
void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val);
void menuTelemetryMavlinkDump(uint8_t event);
void menuTelemetryMavlinkDump(event_t event);
#endif
/*! \brief Mavlink menu enumerator
+2 -2
View File
@@ -20,7 +20,7 @@
#include "opentx.h"
void menuStatisticsView(uint8_t event)
void menuStatisticsView(event_t event)
{
TITLE(STR_MENUSTAT);
@@ -81,7 +81,7 @@ void menuStatisticsView(uint8_t event)
#define MENU_DEBUG_COL1_OFS (14*FW)
#endif
void menuStatisticsDebug(uint8_t event)
void menuStatisticsDebug(event_t event)
{
TITLE(STR_MENUDEBUG);
+1 -1
View File
@@ -490,7 +490,7 @@ void incrTelemetryScreen()
}
#endif
void menuViewTelemetryFrsky(uint8_t event)
void menuViewTelemetryFrsky(event_t event)
{
#if defined(CPUARM)
enum NavigationDirection direction = none;
+1 -1
View File
@@ -88,7 +88,7 @@ void readTextFile(int & lines_count)
}
}
void menuTextView(uint8_t event)
void menuTextView(event_t event)
{
static int lines_count;
+6 -6
View File
@@ -72,7 +72,7 @@ void title(const pm_char * s)
lcdDrawText(0, 0, s, INVERS);
}
choice_t editChoice(coord_t x, coord_t y, const pm_char *label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, uint8_t event)
choice_t editChoice(coord_t x, coord_t y, const pm_char * label, const pm_char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event)
{
drawFieldLabel(x, y, label);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
@@ -80,7 +80,7 @@ choice_t editChoice(coord_t x, coord_t y, const pm_char *label, const pm_char *v
return value;
}
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event )
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, event_t event )
{
#if defined(GRAPHICS)
drawCheckBox(x, y, value, attr);
@@ -90,7 +90,7 @@ uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const pm_char *label,
#endif
}
int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event)
int8_t editSwitch(coord_t x, coord_t y, int8_t value, LcdFlags attr, event_t event)
{
drawFieldLabel(x, y, STR_SWITCH);
drawSwitch(x, y, value, attr);
@@ -120,7 +120,7 @@ bool noZero(int val)
return val != 0;
}
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, event_t event)
{
uint16_t delta = GV_GET_GV1_VALUE(max);
bool invers = (attr & INVERS);
@@ -167,7 +167,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
return value;
}
#elif defined(GVARS)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, event_t event)
{
uint16_t delta = GV_GET_GV1_VALUE(max);
bool invers = (attr & INVERS);
@@ -207,7 +207,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
return value;
}
#else
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, event_t event)
{
lcdDrawNumber(x, y, value, attr);
if (attr&INVERS) value = checkIncDec(event, value, min, max, EE_MODEL);