refact: ADC, switches and keys
Add "hardware_defs" target to dump hardware defines from hal.h per target Fixed hal.h definitions for switches & ADC inputs Tools to generate hardware definitions from current hal.h generator: add support for EXTx and analog switches WiP Add generated header to hardware_defs target Add support for ADC input direction and index per GPIO port Incredible: it compiles Removed StdPeriph ADC driver Works on QX7 Works on TX16S (VBat missing) Switch driver using generated switches for stm32 targets Switch driver with generated switches for simu Use switch names from switch driver Fixed single conversion handling Fixed horus VBat reading Added switch name Fix warnings about bitfield offsets and GCC 4.4 This is caused by bitfields that cross type boundaries. In this particular case, it happens as the bitfield is not defined the same in `rtc_backup.cpp`. Switches has already been moved to generic driver Jitter measurement for each sample, not just for oversampled values Moved periph clock init to the ADC driver ADC & GPIOs. Add switchInit() to init pins Fix NV14 CMake Fix taranis target Fix NV14 (again) Model audio files: use new interface for switch index Fix X9-lite Fix simu headers Fix getSwitchName() Add support for ADC switches Fix switch warning YAML Test only switches which are defined Conversions tests for QX7 only on QX7 Fix X12S Fix function switch names Enable ADC periph clock before initialising channels NV14: offset inputs for the sticks & fix switches WiP: get rid of VSRCRAW and some more Simu shall use normal ADC driver fix x7 fix nv14 Fix 9x nav fix 212x64 fix xlite fix x9e fix simu lib fix unit tests fix x7 tests PWM stick values should be written directly into adcValues ... just like FlySky sticks. fix x12s fix nv14 Add some support for SPI ADC (only unit tests) Remove `jq` usage fix generate_yaml.py for newer libclang fix pot config fix stick names Some YAML generator improvements Max 16 Pots on COLORLCD Fix some source names Use 10 bits for switches to prevent overflow Removed horus constants for switches & ADC inputs Fix unit tests Fix curve edit Fix libsimulator Fix function switches (tpro) Refine ADC & analog API Moved hardware definitions scripts and templates into own dir cleanup API refine Fix unit tests Mixer: apply calibration only on required inputs Place ADC switches after all other ADC inputs Fix X12S Remove useless TR_POTS_VSRCRAW, TR_SW_VSRCRAW, and TR_VSRCRAW Cleanup redundant generated YAML parsers Fixes Boxer rebase Add boxer to generate-hw-defs.sh Obsolete LUA exports Add boxer ADC_DIRECTION Split generate_hw_defs.py into multiple files Some cleanup (+ LUA switches) Fix AXIS definitions Fixed translation strings declarations Some rebase fixes Remove some useless StdPeriph drivers fix: set pin mode to reset state on usart deinit fix: use canonical names for calibration data fix: ADC driver does not care about unconfigured inputs fix X12S ADC Add support for ADC conversion chaining Better X12S ADC implem Moved X12S ADC driver to HAL/LL Improve ADC driver separation Fixed taranis & nv14 Moved PWM gimbals to HAL/LL Removed useless TR_EXTRA_VSRCRAW Fixed include guards Small fixes Renamed control inputs Moved internal and external module pulse driver def to boards Move more things to the generic_stm32 board Remove STR_VMIXTRIMS Added analog labels Generate main control names Misuse labels / short labels for main controls Backward compatibility: sliders and legacy names New keys driver Let's get rid of StdPeriph headers in simu Add jinja2 to CI workflows Use `grep` instead of `sed` chore: add python jinja2 oto msys setup script Removed more static definitions and use dynamic ones instead Fixes X9E Fix x7 nav too 212 switch display Fix default sliders Removed NUM_STICKS 212 switch display working nicely Surface radio 'stick' replacements fix: switch, trim & rotary pin init Remove old key drivers Removed VKEYS Removed ETX_FOURCC Fixed SURFACE_NAME Removed TR_VSWITCHES & TR_TRIMS_SWITCHES Fix xpot switches Store calibrated analogs in physical order Use getSourceString in drawSource Implement missing YAML read/write Fix isSourceAvailableInInputs() Fix isSourceAvailable() Some surface fixes Fix CLI debug Ported colour UI of analog diagnostics to new ADC API Small fixes Better input mapping Minor tpro fixes Fix trims available Remove TX mode choice on surface radio Rename surface controls Channel order alignement Fix throttle warning Fix checkTrims() Fix pot config casting issue Fix IS_SWITCH_FS() Fixed input mapping Fix fswitch auto-switch Fixed storing / reading function switches in YAML Fix enableVBatBridge() / disableVBatBridge() Fix interesting mode conversion Fix sources issues Fix special funnction list Proper function switch handling 128 GUI improvements Fix compilation Boxer cosmetics 128 hardware screen cosmetic Fix TX12 switches More switches fixes Simplify CPU type handling Fix flash size Fixed page-up / page-down in libopenui
This commit is contained in:
committed by
Malte Langermann
parent
b6dd3a0ef8
commit
2b100e0eb5
@@ -20,31 +20,24 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "navigation.h"
|
||||
|
||||
#include "hal/switch_driver.h"
|
||||
#include "switches.h"
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
swsrc_t checkIncDecMovedSwitch(swsrc_t val)
|
||||
{
|
||||
if (s_editMode>0) {
|
||||
swsrc_t swtch = getMovedSwitch();
|
||||
if (swtch) {
|
||||
#if defined(PCBFRSKY)
|
||||
div_t info = switchInfo(swtch);
|
||||
if (IS_CONFIG_TOGGLE(info.quot)) {
|
||||
if (info.rem != 0) {
|
||||
val = (val == swtch ? swtch-2 : swtch);
|
||||
}
|
||||
swsrc_t swtch = getMovedSwitch();
|
||||
if (swtch) {
|
||||
div_t info = switchInfo(swtch);
|
||||
if (IS_CONFIG_TOGGLE(info.quot)) {
|
||||
if (info.rem != 0) {
|
||||
val = (val == swtch ? swtch-2 : swtch);
|
||||
}
|
||||
else {
|
||||
val = swtch;
|
||||
}
|
||||
#else
|
||||
if (IS_CONFIG_TOGGLE(swtch) && swtch==val) {
|
||||
val = -val;
|
||||
}
|
||||
else {
|
||||
val = swtch;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
val = swtch;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
@@ -55,7 +48,7 @@ int checkIncDecSelection = 0;
|
||||
|
||||
void repeatLastCursorMove(event_t event)
|
||||
{
|
||||
if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) {
|
||||
if (IS_PREVIOUS_EVENT(event) || IS_NEXT_EVENT(event)) {
|
||||
pushEvent(event);
|
||||
}
|
||||
else {
|
||||
@@ -63,13 +56,36 @@ void repeatLastCursorMove(event_t event)
|
||||
}
|
||||
}
|
||||
|
||||
void onSwitchLongEnterPress(const char * result)
|
||||
{
|
||||
if (result == STR_MENU_SWITCHES) {
|
||||
checkIncDecSelection = SWSRC_FIRST_SWITCH;
|
||||
} else if (result == STR_MENU_TRIMS) {
|
||||
checkIncDecSelection = SWSRC_FIRST_TRIM;
|
||||
} else if (result == STR_MENU_LOGICAL_SWITCHES) {
|
||||
checkIncDecSelection =
|
||||
SWSRC_FIRST_LOGICAL_SWITCH +
|
||||
getFirstAvailable(0, MAX_LOGICAL_SWITCHES, isLogicalSwitchAvailable);
|
||||
} else if (result == STR_MENU_OTHER) {
|
||||
checkIncDecSelection = SWSRC_ON;
|
||||
} else if (result == STR_MENU_INVERT) {
|
||||
checkIncDecSelection = SWSRC_INVERT;
|
||||
}
|
||||
}
|
||||
|
||||
void onSourceLongEnterPress(const char * result)
|
||||
{
|
||||
if (result == STR_MENU_INPUTS)
|
||||
checkIncDecSelection = getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable)+1;
|
||||
if (result == STR_MENU_INPUTS) {
|
||||
checkIncDecSelection =
|
||||
getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT,
|
||||
isInputAvailable) +
|
||||
1;
|
||||
}
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
else if (result == STR_MENU_LUA)
|
||||
checkIncDecSelection = getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable);
|
||||
else if (result == STR_MENU_LUA) {
|
||||
checkIncDecSelection =
|
||||
getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable);
|
||||
}
|
||||
#endif
|
||||
else if (result == STR_MENU_STICKS)
|
||||
checkIncDecSelection = MIXSRC_FIRST_STICK;
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct CheckIncDecStops
|
||||
{
|
||||
const int count;
|
||||
const int stops[];
|
||||
int min() const
|
||||
{
|
||||
return stops[0];
|
||||
}
|
||||
int max() const
|
||||
{
|
||||
return stops[count-1];
|
||||
}
|
||||
bool contains(int value) const
|
||||
{
|
||||
for (int i=0; i<count; ++i) {
|
||||
int stop = stops[i];
|
||||
if (value == stop)
|
||||
return true;
|
||||
else if (value < stop)
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
extern const CheckIncDecStops &stops100;
|
||||
extern const CheckIncDecStops &stops1000;
|
||||
extern const CheckIncDecStops &stopsSwitch;
|
||||
|
||||
#define INIT_STOPS(var, ...) \
|
||||
const int _ ## var[] = { __VA_ARGS__ }; \
|
||||
const CheckIncDecStops &var = (const CheckIncDecStops&)_ ## var;
|
||||
|
||||
#define CATEGORY_END(val) \
|
||||
(val), (val+1)
|
||||
|
||||
extern int8_t checkIncDec_Ret; // global helper vars
|
||||
|
||||
#define CURSOR_ON_LINE() (menuHorizontalPosition < 0)
|
||||
|
||||
#define EDIT_SELECT_FIELD 0
|
||||
#define EDIT_MODIFY_FIELD 1
|
||||
#define EDIT_MODIFY_STRING 2
|
||||
extern int8_t s_editMode; // global editmode
|
||||
|
||||
// checkIncDec flags
|
||||
// we leave room for EE_MODEL and EE_GENERAL
|
||||
#define NO_INCDEC_MARKS 0x04
|
||||
#define INCDEC_SWITCH 0x08
|
||||
#define INCDEC_SOURCE 0x10
|
||||
#define INCDEC_REP10 0x40
|
||||
#define NO_DBLKEYS 0x80
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
unsigned int i_flags = 0, IsValueAvailable isValueAvailable = nullptr,
|
||||
const CheckIncDecStops &stops = stops100);
|
||||
|
||||
#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 NAVIGATION_LINE_BY_LINE 0x40
|
||||
|
||||
#define CHECK_FLAG_NO_SCREEN_INDEX 1
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax,
|
||||
vertpos_t rowcount, uint8_t flags = 0);
|
||||
|
||||
#define INCDEC_DECLARE_VARS(f) \
|
||||
uint8_t incdecFlag = (f); \
|
||||
IsValueAvailable isValueAvailable = nullptr
|
||||
|
||||
#define INCDEC_SET_FLAG(f) incdecFlag = (f)
|
||||
|
||||
#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn
|
||||
|
||||
#define CHECK_INCDEC_PARAM(event, var, min, max) \
|
||||
checkIncDec(event, var, min, max, incdecFlag, isValueAvailable)
|
||||
|
||||
#define CHECK_INCDEC_MODELVAR(event, var, min, max) \
|
||||
var = checkIncDecModel(event, var, min, max)
|
||||
|
||||
#define CHECK_INCDEC_MODELVAR_ZERO(event, var, max) \
|
||||
var = checkIncDecModelZero(event, var, max)
|
||||
|
||||
#define CHECK_INCDEC_MODELVAR_CHECK(event, var, min, max, check) \
|
||||
var = checkIncDec(event, var, min, max, EE_MODEL, check)
|
||||
|
||||
#define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \
|
||||
var = checkIncDec(event, var, 0, max, EE_MODEL, check)
|
||||
|
||||
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
|
||||
#define CHECK_INCDEC_SWITCH(event, var, min, max, flags, available) \
|
||||
var = checkIncDec(event, var, min, max, (flags)|INCDEC_SWITCH, available)
|
||||
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \
|
||||
CHECK_INCDEC_SWITCH(event, var, min, max, EE_MODEL, available)
|
||||
|
||||
#define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \
|
||||
var = checkIncDec(event, var, min, max, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable)
|
||||
|
||||
#define CHECK_INCDEC_GENVAR(event, var, min, max) \
|
||||
var = checkIncDecGen(event, var, min, max)
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
swsrc_t checkIncDecMovedSwitch(swsrc_t val);
|
||||
#endif
|
||||
|
||||
void repeatLastCursorMove(event_t event);
|
||||
|
||||
void onSwitchLongEnterPress(const char * result);
|
||||
void onSourceLongEnterPress(const char * result);
|
||||
|
||||
void check_submenu_simple(event_t event, uint8_t rowcount);
|
||||
|
||||
void check_simple(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
uint8_t menuTabSize, vertpos_t rowcount);
|
||||
|
||||
|
||||
#define MENU_TAB_ARRAY_NAME mstate_tab
|
||||
#define MENU_TAB_ARRAY_TYPE const uint8_t
|
||||
#define MENU_TAB_ARRAY_DEF MENU_TAB_ARRAY_TYPE MENU_TAB_ARRAY_NAME
|
||||
#define MENU_TAB(...) MENU_TAB_ARRAY_DEF[] = __VA_ARGS__
|
||||
|
||||
#define MENU_CHECK(tab, menu, lines_count) \
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count)
|
||||
|
||||
#define MENU_CHECK_FLAGS(tab, menu, flags, lines_count) \
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count, flags)
|
||||
|
||||
#define MENU(name, tab, menu, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
MENU_CHECK(tab, menu, lines_count); \
|
||||
title(name)
|
||||
|
||||
#define MENU_FLAGS(name, tab, menu, flags, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
MENU_CHECK_FLAGS(tab, menu, flags, lines_count); \
|
||||
title(name)
|
||||
|
||||
#define SIMPLE_MENU(name, tab, menu, lines_count) \
|
||||
check_simple(event, menu, tab, DIM(tab), lines_count); \
|
||||
title(name)
|
||||
|
||||
#define SUBMENU_NOTITLE(lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, lines_count);
|
||||
|
||||
#define SUBMENU(name, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
check(event, 0, nullptr, 0, mstate_tab, DIM(mstate_tab)-1, lines_count); \
|
||||
title(name)
|
||||
|
||||
#define SIMPLE_SUBMENU_NOTITLE(lines_count) \
|
||||
check_submenu_simple(event, lines_count)
|
||||
|
||||
#define SIMPLE_SUBMENU(name, lines_count) \
|
||||
SIMPLE_SUBMENU_NOTITLE(lines_count); \
|
||||
title(name)
|
||||
@@ -20,95 +20,66 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "navigation.h"
|
||||
|
||||
#include "switches.h"
|
||||
|
||||
vertpos_t menuVerticalOffset;
|
||||
int8_t s_editMode;
|
||||
uint8_t noHighlightCounter;
|
||||
uint8_t menuCalibrationState;
|
||||
vertpos_t menuVerticalPosition;
|
||||
horzpos_t menuHorizontalPosition;
|
||||
|
||||
int8_t checkIncDec_Ret;
|
||||
int8_t s_editMode;
|
||||
uint8_t noHighlightCounter;
|
||||
uint8_t menuCalibrationState;
|
||||
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(in) ((in & (KEYS_GPIO_PIN_RIGHT + KEYS_GPIO_PIN_LEFT)) == (KEYS_GPIO_PIN_RIGHT + KEYS_GPIO_PIN_LEFT))
|
||||
#define DBLKEYS_PRESSED_UP_DWN(in) ((in & (KEYS_GPIO_PIN_UP + KEYS_GPIO_PIN_DOWN)) == (KEYS_GPIO_PIN_UP + KEYS_GPIO_PIN_DOWN))
|
||||
#define DBLKEYS_PRESSED_RGT_UP(in) ((in & (KEYS_GPIO_PIN_RIGHT + KEYS_GPIO_PIN_UP)) == (KEYS_GPIO_PIN_RIGHT + KEYS_GPIO_PIN_UP))
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(in) ((in & (KEYS_GPIO_PIN_LEFT + KEYS_GPIO_PIN_DOWN)) == (KEYS_GPIO_PIN_LEFT + KEYS_GPIO_PIN_DOWN))
|
||||
int8_t checkIncDec_Ret;
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
extern int checkIncDecSelection;
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
|
||||
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)
|
||||
uint8_t in = KEYS_PRESSED();
|
||||
if (!(i_flags & NO_DBLKEYS) && (EVT_KEY_MASK(event))) {
|
||||
bool dblkey = true;
|
||||
if (DBLKEYS_PRESSED_RGT_LFT(in)) {
|
||||
if (!isValueAvailable || isValueAvailable(-val)) {
|
||||
newval = -val;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_RGT_UP(in)) {
|
||||
newval = (i_max > stops.max() ? stops.max() : i_max);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval>i_min) {
|
||||
--newval;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_LFT_DWN(in)) {
|
||||
newval = (i_min < stops.min() ? stops.min() : i_min);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval<i_max) {
|
||||
++newval;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_UP_DWN(in)) {
|
||||
newval = 0;
|
||||
}
|
||||
else {
|
||||
dblkey = false;
|
||||
}
|
||||
|
||||
if (dblkey) {
|
||||
killEvents(KEY_UP);
|
||||
killEvents(KEY_DOWN);
|
||||
killEvents(KEY_RIGHT);
|
||||
killEvents(KEY_LEFT);
|
||||
event = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((s_editMode>0 && (IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP)))) {
|
||||
if (s_editMode > 0) {
|
||||
if (event == EVT_KEY_FIRST(KEY_UP) || event == EVT_KEY_REPT(KEY_UP) ||
|
||||
event == EVT_KEY_FIRST(KEY_RIGHT) || event == EVT_KEY_REPT(KEY_RIGHT)) {
|
||||
do {
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval += min(10, i_max-val);
|
||||
newval += min(10, i_max - val);
|
||||
}
|
||||
else {
|
||||
newval++;
|
||||
}
|
||||
} while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
|
||||
} while (isValueAvailable && !isValueAvailable(newval) &&
|
||||
newval <= i_max);
|
||||
|
||||
if (newval > i_max) {
|
||||
newval = val;
|
||||
killEvents(event);
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
else if ((s_editMode>0 && (IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN)))) {
|
||||
} else if (event == EVT_KEY_FIRST(KEY_DOWN) || event == EVT_KEY_REPT(KEY_DOWN) ||
|
||||
event == EVT_KEY_FIRST(KEY_LEFT) || event == EVT_KEY_REPT(KEY_LEFT)) {
|
||||
do {
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval -= min(10, val-i_min);
|
||||
}
|
||||
else {
|
||||
newval -= min(10, val - i_min);
|
||||
} else {
|
||||
newval--;
|
||||
}
|
||||
} while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min);
|
||||
|
||||
} while (isValueAvailable && !isValueAvailable(newval) &&
|
||||
newval >= i_min);
|
||||
|
||||
if (newval < i_min) {
|
||||
newval = val;
|
||||
killEvents(event);
|
||||
@@ -116,20 +87,14 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min==0 && i_max==1 && (event==EVT_KEY_BREAK(KEY_ENTER) || IS_ROTARY_BREAK(event))) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (s_editMode>0) {
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
@@ -143,14 +108,27 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
(event == EVT_KEY_BREAK(KEY_ENTER))) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && (newval==0 || newval==-100 || newval==+100) && !IS_ROTARY_EVENT(event)) {
|
||||
pauseEvents(event); // delay before auto-repeat continues
|
||||
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
|
||||
}
|
||||
}
|
||||
if (!IS_KEY_REPT(event)) {
|
||||
AUDIO_KEY_PRESS();
|
||||
}
|
||||
AUDIO_KEY_PRESS();
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
@@ -204,7 +182,9 @@ uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax,
|
||||
vertpos_t maxrow, uint8_t flags)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -220,34 +200,10 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
int8_t cc = curr;
|
||||
|
||||
switch (event) {
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ROTARY_BREAK:
|
||||
if (s_editMode < 0 && maxrow > 0) {
|
||||
s_editMode = 0;
|
||||
// TODO ? l_posVert = (horTab && horTab[1]==0xff) ? 2 : 1;
|
||||
l_posHorz = 0;
|
||||
}
|
||||
else {
|
||||
s_editMode = -1;
|
||||
}
|
||||
event = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ROTARY_LEFT:
|
||||
if (s_editMode >= 0)
|
||||
break;
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_LEFT):
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, -1);
|
||||
break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ROTARY_RIGHT:
|
||||
if (s_editMode >= 0)
|
||||
break;
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
cc = chgMenu(curr, menuTab, menuTabSize, 1);
|
||||
break;
|
||||
@@ -256,11 +212,6 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
if (cc != curr) {
|
||||
chainMenu(menuTab[cc].menuFunc);
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (IS_ROTARY_ENCODER_NAVIGATION_ENABLE() && s_editMode < 0)
|
||||
attr = INVERS|BLINK;
|
||||
#endif
|
||||
}
|
||||
|
||||
menuCalibrationState = 0;
|
||||
@@ -273,25 +224,8 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
menuEntryTime = get_tmr10ms();
|
||||
l_posVert = 0;
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (menuTab) {
|
||||
s_editMode = EDIT_MODE_INIT;
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
#else
|
||||
s_editMode = EDIT_MODE_INIT;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ENTRY_UP:
|
||||
s_editMode = 0;
|
||||
break;
|
||||
|
||||
case EVT_ROTARY_BREAK:
|
||||
if (s_editMode > 1) break;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
if (!menuTab || l_posVert>0) {
|
||||
@@ -301,18 +235,6 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
case EVT_ROTARY_LONG:
|
||||
if (s_editMode > 1) break;
|
||||
killEvents(event);
|
||||
if (l_posVert != 0) {
|
||||
l_posVert = 0;
|
||||
s_editMode = EDIT_MODE_INIT;
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
#endif
|
||||
|
||||
case EVT_KEY_LONG(KEY_EXIT):
|
||||
s_editMode = 0; // TODO needed? we call ENTRY_UP after which does the same
|
||||
popMenu();
|
||||
@@ -320,11 +242,6 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
AUDIO_KEY_PRESS();
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (s_editMode == 0)
|
||||
s_editMode = EDIT_MODE_INIT;
|
||||
else
|
||||
#endif
|
||||
if (s_editMode>0) {
|
||||
s_editMode = 0;
|
||||
break;
|
||||
@@ -345,47 +262,18 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
|
||||
case EVT_KEY_FIRST(KEY_RIGHT)://inc
|
||||
if (!horTab || s_editMode>0) break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
CASE_EVT_ROTARY_RIGHT
|
||||
if (s_editMode != 0) break;
|
||||
if (l_posHorz < maxcol) {
|
||||
l_posHorz++;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
l_posHorz = 0;
|
||||
if (!IS_ROTARY_RIGHT(event))
|
||||
break;
|
||||
}
|
||||
#else
|
||||
INC(l_posHorz, 0, maxcol);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_REPT(KEY_DOWN):
|
||||
if (!IS_ROTARY_RIGHT(event) && l_posVert==maxrow) break;
|
||||
if (l_posVert==maxrow) break;
|
||||
// no break
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
if (s_editMode>0) break;
|
||||
do {
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (g_eeGeneral.rotEncMode >=
|
||||
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
|
||||
DEC(l_posVert, 0, maxrow);
|
||||
} else {
|
||||
INC(l_posVert, 0, maxrow);
|
||||
}
|
||||
#else
|
||||
INC(l_posVert, 0, maxrow);
|
||||
#endif
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
s_editMode = 0; // if we go down, we must be in this mode
|
||||
#endif
|
||||
|
||||
l_posHorz = min<horzpos_t>(l_posHorz, MAXCOL(l_posVert));
|
||||
break;
|
||||
|
||||
@@ -395,50 +283,18 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
|
||||
case EVT_KEY_FIRST(KEY_LEFT)://dec
|
||||
if (!horTab || s_editMode>0) break;
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
CASE_EVT_ROTARY_LEFT
|
||||
if (s_editMode != 0) break;
|
||||
if (l_posHorz > 0) {
|
||||
l_posHorz--;
|
||||
break;
|
||||
} else if (IS_ROTARY_LEFT(event) && s_editMode == 0) {
|
||||
l_posHorz = 0xff;
|
||||
} else {
|
||||
l_posHorz =
|
||||
g_eeGeneral.rotEncMode == ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_ALT
|
||||
? 0
|
||||
: maxcol;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
DEC(l_posHorz, 0, maxcol);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_REPT(KEY_UP):
|
||||
if (!IS_ROTARY_LEFT(event) && l_posVert==0) break;
|
||||
if (l_posVert==0) break;
|
||||
// no break
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
if (s_editMode>0) break;
|
||||
|
||||
do {
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (g_eeGeneral.rotEncMode >=
|
||||
ROTARY_ENCODER_MODE_INVERT_VERT_HORZ_NORM) {
|
||||
INC(l_posVert, 0, maxrow);
|
||||
} else {
|
||||
DEC(l_posVert, 0, maxrow);
|
||||
}
|
||||
#else
|
||||
DEC(l_posVert, 0, maxrow);
|
||||
#endif
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
s_editMode = 0; // if we go up, we must be in this mode
|
||||
#endif
|
||||
|
||||
l_posHorz = min((uint8_t)l_posHorz, MAXCOL(l_posVert));
|
||||
break;
|
||||
}
|
||||
@@ -511,4 +367,3 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,86 +20,83 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "navigation.h"
|
||||
|
||||
#include "switches.h"
|
||||
#include "hal/rotary_encoder.h"
|
||||
|
||||
vertpos_t menuVerticalOffset;
|
||||
vertpos_t menuVerticalPosition;
|
||||
horzpos_t menuHorizontalPosition;
|
||||
|
||||
int8_t s_editMode;
|
||||
uint8_t noHighlightCounter;
|
||||
uint8_t menuCalibrationState;
|
||||
vertpos_t menuVerticalPosition;
|
||||
horzpos_t menuHorizontalPosition;
|
||||
int8_t checkIncDec_Ret;
|
||||
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(in) (false)
|
||||
#define DBLKEYS_PRESSED_UP_DWN(in) (false)
|
||||
#define DBLKEYS_PRESSED_RGT_UP(in) (false)
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(in) (false)
|
||||
int8_t checkIncDec_Ret;
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
extern int checkIncDecSelection;
|
||||
|
||||
void onSwitchLongEnterPress(const char * result)
|
||||
{
|
||||
if (result == STR_MENU_SWITCHES)
|
||||
checkIncDecSelection = SWSRC_FIRST_SWITCH;
|
||||
else if (result == STR_MENU_TRIMS)
|
||||
checkIncDecSelection = SWSRC_FIRST_TRIM;
|
||||
else if (result == STR_MENU_LOGICAL_SWITCHES)
|
||||
checkIncDecSelection = SWSRC_FIRST_LOGICAL_SWITCH + getFirstAvailable(0, MAX_LOGICAL_SWITCHES, isLogicalSwitchAvailable);
|
||||
else if (result == STR_MENU_OTHER)
|
||||
checkIncDecSelection = SWSRC_ON;
|
||||
else if (result == STR_MENU_INVERT)
|
||||
checkIncDecSelection = SWSRC_INVERT;
|
||||
}
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
|
||||
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(ROTARY_ENCODER_NAVIGATION)
|
||||
if (s_editMode>0 && event==EVT_ROTARY_RIGHT) {
|
||||
#else
|
||||
if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_PLUS) || event==EVT_KEY_REPT(KEY_PLUS))) {
|
||||
#endif
|
||||
newval += min<int>(rotencSpeed, i_max-val);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max) {
|
||||
newval++;
|
||||
}
|
||||
if (newval > i_max) {
|
||||
newval = val;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
else if (s_editMode>0 && event==EVT_ROTARY_LEFT) {
|
||||
#else
|
||||
if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_MINUS) || event==EVT_KEY_REPT(KEY_MINUS))) {
|
||||
#endif
|
||||
newval -= min<int>(rotencSpeed, val-i_min);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min) {
|
||||
newval--;
|
||||
}
|
||||
if (newval < i_min) {
|
||||
newval = val;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min==0 && i_max==1 && event==EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
if (s_editMode > 0) {
|
||||
if (event == EVT_ROTARY_RIGHT || event == EVT_KEY_FIRST(KEY_PLUS) ||
|
||||
event == EVT_KEY_REPT(KEY_PLUS)) {
|
||||
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval += min(10, i_max - val);
|
||||
} else {
|
||||
newval += min<int>(rotaryEncoderGetAccel(), i_max - val);
|
||||
}
|
||||
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval <= i_max) {
|
||||
newval++;
|
||||
}
|
||||
|
||||
if (newval > i_max) {
|
||||
newval = val;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
} else if (event == EVT_ROTARY_LEFT || event == EVT_KEY_FIRST(KEY_MINUS) ||
|
||||
event == EVT_KEY_REPT(KEY_MINUS)) {
|
||||
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval -= min(10, val - i_min);
|
||||
} else {
|
||||
newval -= min<int>(rotaryEncoderGetAccel(), val - i_min);
|
||||
}
|
||||
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval >= i_min) {
|
||||
newval--;
|
||||
}
|
||||
|
||||
if (newval < i_min) {
|
||||
newval = val;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (s_editMode>0) {
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
int source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
@@ -113,8 +110,14 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
@@ -248,7 +251,9 @@ uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t menuTabSize, const uint8_t * horTab, uint8_t horTabMax, vertpos_t rowcount)
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax,
|
||||
vertpos_t rowcount, uint8_t flags)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -303,7 +308,7 @@ void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t men
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
break;
|
||||
|
||||
case EVT_ROTARY_BREAK:
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (s_editMode > 1)
|
||||
break;
|
||||
if (menuHorizontalPosition < 0 && maxcol > 0 && READ_ONLY_UNLOCKED()) {
|
||||
@@ -345,14 +350,11 @@ void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t men
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
|
||||
case EVT_ROTARY_RIGHT:
|
||||
case EVT_KEY_FIRST(KEY_MINUS):
|
||||
case EVT_KEY_REPT(KEY_MINUS):
|
||||
AUDIO_KEY_PRESS();
|
||||
// no break
|
||||
#else
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_REPT(KEY_DOWN):
|
||||
#endif
|
||||
if (s_editMode > 0) break; // TODO it was !=
|
||||
if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
|
||||
if (l_posHorz >= 0) {
|
||||
@@ -387,14 +389,11 @@ void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t men
|
||||
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
break;
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
|
||||
case EVT_ROTARY_LEFT:
|
||||
case EVT_KEY_FIRST(KEY_PLUS):
|
||||
case EVT_KEY_REPT(KEY_PLUS):
|
||||
AUDIO_KEY_PRESS();
|
||||
// no break
|
||||
#else
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_REPT(KEY_UP):
|
||||
#endif
|
||||
if (s_editMode > 0) break; // TODO it was !=
|
||||
if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
|
||||
if (l_posHorz >= 0) {
|
||||
@@ -440,7 +439,10 @@ void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t men
|
||||
|
||||
int linesCount = rowcount;
|
||||
|
||||
if (l_posVert == 0 || (l_posVert==1 && MAXCOL(vertpos_t(0)) >= HIDDEN_ROW) || (l_posVert==2 && MAXCOL(vertpos_t(0)) >= HIDDEN_ROW && MAXCOL(vertpos_t(1)) >= HIDDEN_ROW)) {
|
||||
if (l_posVert == 0 ||
|
||||
(l_posVert == 1 && MAXCOL(vertpos_t(0)) >= HIDDEN_ROW) ||
|
||||
(l_posVert == 2 && MAXCOL(vertpos_t(0)) >= HIDDEN_ROW &&
|
||||
MAXCOL(vertpos_t(1)) >= HIDDEN_ROW)) {
|
||||
menuVerticalOffset = 0;
|
||||
if (horTab) {
|
||||
linesCount = 0;
|
||||
@@ -450,8 +452,7 @@ void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t men
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (horTab) {
|
||||
} else if (horTab) {
|
||||
if (rowcount > NUM_BODY_LINES) {
|
||||
while (1) {
|
||||
vertpos_t firstLine = 0;
|
||||
@@ -485,8 +486,7 @@ void check(event_t event, uint8_t curr, const MenuHandler * menuTab, uint8_t men
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (l_posVert>=NUM_BODY_LINES+menuVerticalOffset) {
|
||||
menuVerticalOffset = l_posVert-NUM_BODY_LINES+1;
|
||||
}
|
||||
|
||||
@@ -20,153 +20,83 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "navigation.h"
|
||||
|
||||
#include "switches.h"
|
||||
#include "hal/rotary_encoder.h"
|
||||
|
||||
vertpos_t menuVerticalOffset;
|
||||
vertpos_t menuVerticalPosition;
|
||||
horzpos_t menuHorizontalPosition;
|
||||
|
||||
int8_t s_editMode;
|
||||
uint8_t noHighlightCounter;
|
||||
uint8_t menuCalibrationState;
|
||||
extern int checkIncDecSelection;
|
||||
|
||||
int8_t checkIncDec_Ret;
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
void onSwitchLongEnterPress(const char * result)
|
||||
{
|
||||
if (result == STR_MENU_SWITCHES)
|
||||
checkIncDecSelection = SWSRC_FIRST_SWITCH;
|
||||
else if (result == STR_MENU_TRIMS)
|
||||
checkIncDecSelection = SWSRC_FIRST_TRIM;
|
||||
else if (result == STR_MENU_LOGICAL_SWITCHES)
|
||||
checkIncDecSelection = SWSRC_FIRST_LOGICAL_SWITCH + getFirstAvailable(0, MAX_LOGICAL_SWITCHES, isLogicalSwitchAvailable);
|
||||
else if (result == STR_MENU_OTHER)
|
||||
checkIncDecSelection = SWSRC_ON;
|
||||
else if (result == STR_MENU_INVERT)
|
||||
checkIncDecSelection = SWSRC_INVERT;
|
||||
}
|
||||
extern int checkIncDecSelection;
|
||||
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(in) ((in & ((1<<KEY_PLUS) + (1<<KEY_MINUS))) == ((1<<KEY_PLUS) + (1<<KEY_MINUS)))
|
||||
#define DBLKEYS_PRESSED_UP_DWN(in) ((in & ((1<<KEY_MENU) + (1<<KEY_PAGE))) == ((1<<KEY_MENU) + (1<<KEY_PAGE)))
|
||||
#define DBLKEYS_PRESSED_RGT_UP(in) ((in & ((1<<KEY_ENTER) + (1<<KEY_MINUS))) == ((1<<KEY_ENTER) + (1<<KEY_MINUS)))
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(in) ((in & ((1<<KEY_PAGE) + (1<<KEY_EXIT))) == ((1<<KEY_PAGE) + (1<<KEY_EXIT)))
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
|
||||
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)
|
||||
uint32_t in = KEYS_PRESSED();
|
||||
if (!(i_flags & NO_DBLKEYS) && (EVT_KEY_MASK(event))) {
|
||||
bool dblkey = true;
|
||||
if (DBLKEYS_PRESSED_RGT_LFT(in)) {
|
||||
if (!isValueAvailable || isValueAvailable(-val)) {
|
||||
newval = -val;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_RGT_UP(in)) {
|
||||
newval = (i_max > stops.max() ? stops.max() : i_max);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval>i_min) {
|
||||
--newval;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_LFT_DWN(in)) {
|
||||
newval = (i_min < stops.min() ? stops.min() : i_min);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval<i_max) {
|
||||
++newval;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_UP_DWN(in)) {
|
||||
newval = 0;
|
||||
}
|
||||
else {
|
||||
dblkey = false;
|
||||
}
|
||||
if (s_editMode > 0) {
|
||||
if (event == EVT_ROTARY_RIGHT || event == EVT_KEY_FIRST(KEY_PLUS) ||
|
||||
event == EVT_KEY_REPT(KEY_PLUS)) {
|
||||
|
||||
if (dblkey) {
|
||||
killEvents(KEY_UP);
|
||||
killEvents(KEY_DOWN);
|
||||
killEvents(KEY_RIGHT);
|
||||
killEvents(KEY_LEFT);
|
||||
killEvents(KEY_PAGE);
|
||||
killEvents(KEY_MENU);
|
||||
killEvents(KEY_ENTER);
|
||||
killEvents(KEY_EXIT);
|
||||
event = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
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;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
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;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
#else
|
||||
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);
|
||||
newval += min(10, i_max - val);
|
||||
} else {
|
||||
newval += min<int>(rotaryEncoderGetAccel(), i_max - val);
|
||||
}
|
||||
else {
|
||||
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval <= i_max) {
|
||||
newval++;
|
||||
}
|
||||
} while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
|
||||
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);
|
||||
|
||||
if (newval > i_max) {
|
||||
newval = val;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
else {
|
||||
} else if (event == EVT_ROTARY_LEFT || event == EVT_KEY_FIRST(KEY_MINUS) ||
|
||||
event == EVT_KEY_REPT(KEY_MINUS)) {
|
||||
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval -= min(10, val - i_min);
|
||||
} else {
|
||||
newval -= min<int>(rotaryEncoderGetAccel(), val - i_min);
|
||||
}
|
||||
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval >= i_min) {
|
||||
newval--;
|
||||
}
|
||||
} while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min);
|
||||
if (newval < i_min) {
|
||||
newval = val;
|
||||
killEvents(event);
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!READ_ONLY() && i_min==0 && i_max==1 && event==EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
if (newval < i_min) {
|
||||
newval = val;
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (s_editMode>0) {
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
int source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
@@ -180,15 +110,23 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
#if !defined(ROTARY_ENCODER_NAVIGATION)
|
||||
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 (!(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
|
||||
pauseEvents(event); // delay before auto-repeat continues
|
||||
}
|
||||
}
|
||||
if (!IS_KEY_REPT(event)) {
|
||||
@@ -333,7 +271,9 @@ uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t rowcount, uint8_t flags)
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax,
|
||||
vertpos_t rowcount, uint8_t flags)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
@@ -443,11 +383,10 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
}
|
||||
break;
|
||||
|
||||
CASE_EVT_ROTARY_RIGHT
|
||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||
case EVT_ROTARY_RIGHT:
|
||||
case EVT_KEY_FIRST(KEY_MINUS):
|
||||
case EVT_KEY_REPT(KEY_MINUS):
|
||||
AUDIO_KEY_PRESS();
|
||||
// no break
|
||||
case EVT_KEY_REPT(KEY_RIGHT):
|
||||
if (s_editMode != 0) break;
|
||||
if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
|
||||
if (l_posHorz >= 0) {
|
||||
@@ -483,11 +422,10 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
break;
|
||||
|
||||
CASE_EVT_ROTARY_LEFT
|
||||
case EVT_KEY_FIRST(KEY_LEFT):
|
||||
case EVT_ROTARY_LEFT:
|
||||
case EVT_KEY_FIRST(KEY_PLUS):
|
||||
case EVT_KEY_REPT(KEY_PLUS):
|
||||
AUDIO_KEY_PRESS();
|
||||
// no break
|
||||
case EVT_KEY_REPT(KEY_LEFT):
|
||||
if (s_editMode != 0) break;
|
||||
if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
|
||||
if (l_posHorz >= 0) {
|
||||
@@ -595,4 +533,3 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menu
|
||||
menuVerticalPosition = l_posVert;
|
||||
menuHorizontalPosition = l_posHorz;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,89 +20,38 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "switches.h"
|
||||
|
||||
vertpos_t menuVerticalOffset;
|
||||
int8_t s_editMode;
|
||||
uint8_t noHighlightCounter;
|
||||
uint8_t menuCalibrationState;
|
||||
vertpos_t menuVerticalPosition;
|
||||
horzpos_t menuHorizontalPosition;
|
||||
|
||||
int8_t checkIncDec_Ret;
|
||||
int8_t s_editMode;
|
||||
uint8_t noHighlightCounter;
|
||||
uint8_t menuCalibrationState;
|
||||
|
||||
// invert the value
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(in) ((in & ((1<<KEY_SHIFT) + (1<<KEY_UP))) == ((1<<KEY_SHIFT) + (1<<KEY_UP)))
|
||||
// set to 0
|
||||
#define DBLKEYS_PRESSED_UP_DWN(in) ((in & ((1<<KEY_SHIFT) + (1<<KEY_DOWN))) == ((1<<KEY_SHIFT) + (1<<KEY_DOWN)))
|
||||
// set to max
|
||||
#define DBLKEYS_PRESSED_RGT_UP(in) ((in & ((1<<KEY_SHIFT) + (1<<KEY_RIGHT))) == ((1<<KEY_SHIFT) + (1<<KEY_RIGHT)))
|
||||
// set to min
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(in) ((in & ((1<<KEY_SHIFT) + (1<<KEY_LEFT))) == ((1<<KEY_SHIFT) + (1<<KEY_LEFT)))
|
||||
int8_t checkIncDec_Ret;
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
extern int checkIncDecSelection;
|
||||
|
||||
void onSwitchLongEnterPress(const char * result)
|
||||
{
|
||||
if (result == STR_MENU_SWITCHES)
|
||||
checkIncDecSelection = SWSRC_FIRST_SWITCH;
|
||||
else if (result == STR_MENU_TRIMS)
|
||||
checkIncDecSelection = SWSRC_FIRST_TRIM;
|
||||
else if (result == STR_MENU_LOGICAL_SWITCHES)
|
||||
checkIncDecSelection = SWSRC_FIRST_LOGICAL_SWITCH + getFirstAvailable(0, MAX_LOGICAL_SWITCHES, isLogicalSwitchAvailable);
|
||||
else if (result == STR_MENU_OTHER)
|
||||
checkIncDecSelection = SWSRC_ON;
|
||||
else if (result == STR_MENU_INVERT)
|
||||
checkIncDecSelection = SWSRC_INVERT;
|
||||
}
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
|
||||
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)
|
||||
uint8_t in = KEYS_PRESSED();
|
||||
if (!(i_flags & NO_DBLKEYS) && (EVT_KEY_MASK(event))) {
|
||||
bool dblkey = true;
|
||||
if (DBLKEYS_PRESSED_RGT_LFT(in)) {
|
||||
if (!isValueAvailable || isValueAvailable(-val)) {
|
||||
newval = -val;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_RGT_UP(in)) {
|
||||
newval = (i_max > stops.max() ? stops.max() : i_max);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval>i_min) {
|
||||
--newval;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_LFT_DWN(in)) {
|
||||
newval = (i_min < stops.min() ? stops.min() : i_min);
|
||||
while (isValueAvailable && !isValueAvailable(newval) && newval<i_max) {
|
||||
++newval;
|
||||
}
|
||||
}
|
||||
else if (DBLKEYS_PRESSED_UP_DWN(in)) {
|
||||
newval = 0;
|
||||
}
|
||||
else {
|
||||
dblkey = false;
|
||||
}
|
||||
|
||||
if (dblkey) {
|
||||
killEvents(KEY_UP);
|
||||
killEvents(KEY_DOWN);
|
||||
killEvents(KEY_RIGHT);
|
||||
killEvents(KEY_LEFT);
|
||||
event = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (s_editMode > 0) {
|
||||
if (event==EVT_KEY_FIRST(KEY_RIGHT) || event==EVT_KEY_REPT(KEY_RIGHT) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP)) {
|
||||
if (event == EVT_KEY_FIRST(KEY_RIGHT) || event == EVT_KEY_REPT(KEY_RIGHT) ||
|
||||
event == EVT_KEY_FIRST(KEY_UP) || event == EVT_KEY_REPT(KEY_UP)) {
|
||||
do {
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval += min(10, i_max-val);
|
||||
@@ -110,15 +59,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
else {
|
||||
newval++;
|
||||
}
|
||||
} while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
|
||||
} while (isValueAvailable && !isValueAvailable(newval) &&
|
||||
newval <= i_max);
|
||||
|
||||
if (newval > i_max) {
|
||||
newval = val;
|
||||
killEvents(event);
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
else if (event==EVT_KEY_FIRST(KEY_LEFT) || event==EVT_KEY_REPT(KEY_LEFT) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN)) {
|
||||
} else if (event == EVT_KEY_FIRST(KEY_LEFT) ||
|
||||
event == EVT_KEY_REPT(KEY_LEFT) ||
|
||||
event == EVT_KEY_FIRST(KEY_DOWN) ||
|
||||
event == EVT_KEY_REPT(KEY_DOWN)) {
|
||||
do {
|
||||
if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) {
|
||||
newval -= min(10, val-i_min);
|
||||
@@ -134,22 +86,15 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
AUDIO_KEY_ERROR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 && event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
if (i_flags & INCDEC_SWITCH) {
|
||||
newval = checkIncDecMovedSwitch(newval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (s_editMode > 0) {
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
@@ -163,14 +108,27 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && (newval==0 || newval==-100 || newval==+100)) {
|
||||
pauseEvents(event); // delay before auto-repeat continues
|
||||
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
|
||||
}
|
||||
}
|
||||
if (!IS_KEY_REPT(event)) {
|
||||
AUDIO_KEY_PRESS();
|
||||
}
|
||||
AUDIO_KEY_PRESS();
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
@@ -179,7 +137,7 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && !IS_SHIFT_PRESSED()) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && !keysGetState(KEY_SHIFT)) {
|
||||
killEvents(event);
|
||||
checkIncDecSelection = MIXSRC_NONE;
|
||||
|
||||
@@ -230,7 +188,7 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla
|
||||
}
|
||||
}
|
||||
else if (i_flags & INCDEC_SWITCH) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && !IS_SHIFT_PRESSED()) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && !keysGetState(KEY_SHIFT)) {
|
||||
killEvents(event);
|
||||
checkIncDecSelection = SWSRC_NONE;
|
||||
if (i_min <= SWSRC_FIRST_SWITCH && i_max >= SWSRC_LAST_SWITCH) POPUP_MENU_ADD_ITEM(STR_MENU_SWITCHES);
|
||||
@@ -302,7 +260,9 @@ uint8_t menuIdx(const MenuHandler * menuTab, uint8_t curr)
|
||||
return menuSize(menuTab, curr + 1) - 1;
|
||||
}
|
||||
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab, uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow)
|
||||
void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
uint8_t menuTabSize, const uint8_t *horTab, uint8_t horTabMax,
|
||||
vertpos_t maxrow, uint8_t flags)
|
||||
{
|
||||
vertpos_t l_posVert = menuVerticalPosition;
|
||||
horzpos_t l_posHorz = menuHorizontalPosition;
|
||||
|
||||
Reference in New Issue
Block a user