Source popup menu
This commit is contained in:
@@ -326,7 +326,8 @@ extern uint8_t s_warning_info_flags;
|
||||
|
||||
#define NAVIGATION_MENUS
|
||||
#define MENU_ADD_ITEM(s) s_menu[s_menu_count++] = s
|
||||
#define MENU_MAX_LINES 6
|
||||
#define MENU_MAX_LINES 11
|
||||
#define MENU_MAX_DISPLAY_LINES 6
|
||||
#define MENU_ADD_SD_ITEM(s) MENU_ADD_ITEM(s)
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
|
||||
extern const char *s_menu[MENU_MAX_LINES];
|
||||
|
||||
@@ -42,6 +42,7 @@ horzpos_t m_posHorz;
|
||||
int8_t s_editMode;
|
||||
uint8_t s_noHi;
|
||||
uint8_t calibrationState;
|
||||
int s_source = MIXSRC_NONE;
|
||||
|
||||
#if defined(AUTOSWITCH)
|
||||
int8_t checkIncDecMovedSwitch(int8_t val)
|
||||
@@ -70,6 +71,61 @@ 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)
|
||||
|
||||
void onLongEnterPress(const char *result)
|
||||
{
|
||||
if (result == STR_MENU_INPUTS) {
|
||||
for (int i = MIXSRC_FIRST_INPUT; i <= MIXSRC_LAST_INPUT; i++) {
|
||||
if (isInputAvailable(i)) {
|
||||
s_source = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (result == STR_MENU_LUA) {
|
||||
for (int i = MIXSRC_FIRST_LUA; i <= MIXSRC_LAST_LUA; i++) {
|
||||
if (isSourceAvailable(i)) {
|
||||
s_source = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (result == STR_MENU_STICKS)
|
||||
s_source = MIXSRC_FIRST_STICK;
|
||||
if (result == STR_MENU_POTS)
|
||||
s_source = MIXSRC_FIRST_POT;
|
||||
if (result == STR_MENU_MAX)
|
||||
s_source = MIXSRC_MAX;
|
||||
if (result == STR_MENU_HELI)
|
||||
s_source = MIXSRC_FIRST_HELI;
|
||||
if (result == STR_MENU_TRIMS)
|
||||
s_source = MIXSRC_FIRST_TRIM;
|
||||
if (result == STR_MENU_SWITCHES)
|
||||
s_source = MIXSRC_FIRST_SWITCH;
|
||||
if (result == STR_MENU_TRAINER)
|
||||
s_source = MIXSRC_FIRST_TRAINER;
|
||||
|
||||
if (result == STR_MENU_CHANNELS) {
|
||||
for (int i = MIXSRC_FIRST_CH; i <= MIXSRC_LAST_CH; i++) {
|
||||
if (isSourceAvailable(i)) {
|
||||
s_source = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result == STR_MENU_TELEMETRY) {
|
||||
for (int i = 0; i < TELEM_VALUES_MAX; i++) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->isAvailable()) {
|
||||
s_source = MIXSRC_FIRST_TELEM + 3*i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops)
|
||||
{
|
||||
int newval = val;
|
||||
@@ -207,6 +263,68 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
|
||||
else {
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(event);
|
||||
s_source = MIXSRC_NONE;
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
|
||||
bool available = false;
|
||||
for (int i = MIXSRC_FIRST_INPUT; i <= MIXSRC_LAST_INPUT; i++) {
|
||||
if (isInputAvailable(i)) {
|
||||
available = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (available)
|
||||
MENU_ADD_ITEM(STR_MENU_INPUTS);
|
||||
}
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (i_min <= MIXSRC_FIRST_LUA && i_max >= MIXSRC_FIRST_LUA) {
|
||||
bool available = false;
|
||||
for (int i = MIXSRC_FIRST_LUA; i <= MIXSRC_LAST_LUA; i++) {
|
||||
if (isSourceAvailable(i)) {
|
||||
available = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (available)
|
||||
MENU_ADD_ITEM(STR_MENU_LUA);
|
||||
}
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_STICK && i_max >= MIXSRC_FIRST_STICK) MENU_ADD_ITEM(STR_MENU_STICKS);
|
||||
if (i_min <= MIXSRC_FIRST_POT && i_max >= MIXSRC_FIRST_POT) MENU_ADD_ITEM(STR_MENU_POTS);
|
||||
if (i_min <= MIXSRC_MAX && i_max >= MIXSRC_MAX) MENU_ADD_ITEM(STR_MENU_MAX);
|
||||
#if defined(HELI)
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI) MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_TRIM && i_max >= MIXSRC_FIRST_TRIM) MENU_ADD_ITEM(STR_MENU_TRIMS);
|
||||
if (i_min <= MIXSRC_FIRST_SWITCH && i_max >= MIXSRC_FIRST_SWITCH) MENU_ADD_ITEM(STR_MENU_SWITCHES);
|
||||
if (i_min <= MIXSRC_FIRST_TRAINER && i_max >= MIXSRC_FIRST_TRAINER) MENU_ADD_ITEM(STR_MENU_TRAINER);
|
||||
if (i_min <= MIXSRC_FIRST_CH && i_max >= MIXSRC_FIRST_CH) MENU_ADD_ITEM(STR_MENU_CHANNELS);
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
bool available = false;
|
||||
for (int i = 0; i < TELEM_VALUES_MAX; i++) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->isAvailable()) {
|
||||
available = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (available)
|
||||
MENU_ADD_ITEM(STR_MENU_TELEMETRY);
|
||||
}
|
||||
menuHandler = onLongEnterPress;
|
||||
}
|
||||
if (s_source != MIXSRC_NONE) {
|
||||
newval = s_source;
|
||||
if (s_source != MIXSRC_MAX)
|
||||
s_editMode = 1;
|
||||
s_source = MIXSRC_NONE;
|
||||
}
|
||||
}
|
||||
return newval;
|
||||
}
|
||||
|
||||
@@ -229,6 +347,7 @@ void onLongMenuPress(const char *result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tmr10ms_t menuEntryTime;
|
||||
|
||||
void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t rowcount, uint8_t flags)
|
||||
|
||||
@@ -127,18 +127,18 @@ const char * displayMenu(uint8_t event)
|
||||
{
|
||||
const char * result = NULL;
|
||||
|
||||
uint8_t display_count = min(s_menu_count, (uint16_t)MENU_MAX_LINES);
|
||||
uint8_t display_count = min(s_menu_count, (uint16_t)MENU_MAX_DISPLAY_LINES);
|
||||
uint8_t y = (display_count >= 5 ? MENU_Y - FH - 1 : MENU_Y);
|
||||
drawFilledRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2, SOLID, ERASE);
|
||||
lcd_rect(MENU_X, y, MENU_W, display_count * (FH+1) + 2);
|
||||
|
||||
for (uint8_t i=0; i<display_count; i++) {
|
||||
lcd_putsAtt(MENU_X+6, i*(FH+1) + y + 2, s_menu[i], s_menu_flags);
|
||||
lcd_putsAtt(MENU_X+6, i*(FH+1) + y + 2, s_menu[i+s_menu_offset], s_menu_flags);
|
||||
if (i == s_menu_item) drawFilledRect(MENU_X+1, i*(FH+1) + y + 1, MENU_W-2, 9);
|
||||
}
|
||||
|
||||
if (s_menu_count > display_count) {
|
||||
displayScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, MENU_MAX_LINES);
|
||||
displayScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, display_count);
|
||||
}
|
||||
|
||||
switch(event) {
|
||||
@@ -152,9 +152,9 @@ const char * displayMenu(uint8_t event)
|
||||
result = STR_UPDATE_LIST;
|
||||
}
|
||||
else {
|
||||
s_menu_item = display_count - 1;
|
||||
if (s_menu_count > MENU_MAX_LINES) {
|
||||
s_menu_offset = s_menu_count - display_count;
|
||||
s_menu_item = min(display_count, (uint8_t)MENU_MAX_DISPLAY_LINES)-1;
|
||||
if (s_menu_count > MENU_MAX_DISPLAY_LINES) {
|
||||
s_menu_offset = s_menu_count - MENU_MAX_DISPLAY_LINES;
|
||||
result = STR_UPDATE_LIST;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ const char * displayMenu(uint8_t event)
|
||||
break;
|
||||
CASE_EVT_ROTARY_BREAK
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
result = s_menu[s_menu_item];
|
||||
result = s_menu[s_menu_item+s_menu_offset];
|
||||
// no break
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
s_menu_count = 0;
|
||||
|
||||
Reference in New Issue
Block a user