mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 15:25:17 +03:00
Inflight parameters modification using Rotary Encoder on v4 (not finished yet).
This commit is contained in:
parent
9997b8c599
commit
33e30b8fef
10 changed files with 92 additions and 36 deletions
|
@ -109,7 +109,8 @@ struct FrskyHubData {
|
|||
// 17 spares
|
||||
uint16_t volts_bp;
|
||||
uint16_t volts_ap;
|
||||
uint16_t maxGpsSpeed; // spare reused
|
||||
// end of FrSky Hub data
|
||||
uint16_t maxGpsSpeed;
|
||||
};
|
||||
|
||||
#elif defined(WS_HOW_HIGH)
|
||||
|
|
12
src/lcd.cpp
12
src/lcd.cpp
|
@ -208,9 +208,9 @@ void lcd_outdez8(uint8_t x, uint8_t y, int8_t val)
|
|||
lcd_outdezAtt(x, y, val);
|
||||
}
|
||||
|
||||
void lcd_outdezAtt(uint8_t x, uint8_t y, int16_t val, uint8_t mode)
|
||||
void lcd_outdezAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags)
|
||||
{
|
||||
lcd_outdezNAtt(x, y, val, mode);
|
||||
lcd_outdezNAtt(x, y, val, flags);
|
||||
}
|
||||
|
||||
// TODO use doxygen style comments here
|
||||
|
@ -301,6 +301,14 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le
|
|||
|
||||
// TODO we could change the '-' to have one pixel removed at its left
|
||||
if (neg) { lcd_putcAtt(x, y, '-', flags); lcd_plot(x, y+3); }
|
||||
|
||||
#ifdef NAVIGATION_RE1
|
||||
if (flags & SURROUNDED) {
|
||||
xn = lcd_lastPos - x + 2;
|
||||
if (!neg) { x+=FW; xn-=FW; }
|
||||
lcd_rect(x-1, y-1, xn, 9, BLINK_ON_PHASE ? DOTTED : ~DOTTED);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcd_mask(uint8_t *p, uint8_t mask, uint8_t att)
|
||||
|
|
|
@ -225,6 +225,17 @@ void menuMainView(uint8_t event)
|
|||
instantTrimSwLock = true;
|
||||
trim2OfsSwLock = true;
|
||||
break;
|
||||
#ifdef NAVIGATION_RE1
|
||||
case EVT_KEY_LONG(BTN_RE1):
|
||||
if (s_inflight_value && !s_warning) {
|
||||
s_warning = s_inflight_label;
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
case EVT_KEY_BREAK(BTN_RE1):
|
||||
s_warning = NULL;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool trimSw = isFunctionActive(FUNC_INSTANT_TRIM);
|
||||
|
@ -575,5 +586,11 @@ void menuMainView(uint8_t event)
|
|||
// lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s
|
||||
}
|
||||
|
||||
#ifdef NAVIGATION_RE1
|
||||
if (s_warning) {
|
||||
displayBox();
|
||||
}
|
||||
#endif
|
||||
|
||||
theFile.DisplayProgressBar(20*FW+1);
|
||||
}
|
||||
|
|
|
@ -465,19 +465,39 @@ void pushMenu(MenuFuncP newMenu)
|
|||
(*newMenu)(EVT_ENTRY);
|
||||
}
|
||||
|
||||
const pm_char * s_warning = 0;
|
||||
void displayBox()
|
||||
{
|
||||
lcd_filled_rect(10, 16, 108, 40, SOLID, WHITE);
|
||||
lcd_rect(10, 16, 108, 40);
|
||||
lcd_puts(16, 3*FH, s_warning);
|
||||
// could be a place for a s_warning_info
|
||||
}
|
||||
|
||||
#ifdef NAVIGATION_RE1
|
||||
void * s_inflight_value;
|
||||
int8_t *s_inflight_value = NULL;
|
||||
int16_t s_inflight_min;
|
||||
int16_t s_inflight_max;
|
||||
int16_t s_inflight_shift;
|
||||
const pm_char *s_inflight_label;
|
||||
uint8_t s_inflight_flags;
|
||||
|
||||
void checkInflightIncDec(void *value, int16_t i_min, int16_t i_max, const pm_char *label, uint8_t flags)
|
||||
void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16_t i_max, int8_t i_shift, const pm_char *label)
|
||||
{
|
||||
*value = i_shift + checkIncDecModel(event, (*value)-i_shift, i_min, i_max);
|
||||
|
||||
if (event == EVT_KEY_LONG(BTN_RE1)) {
|
||||
if (value == s_inflight_value) {
|
||||
s_inflight_value = NULL;
|
||||
}
|
||||
else {
|
||||
s_inflight_value = value;
|
||||
s_inflight_min = i_min;
|
||||
s_inflight_max = i_max;
|
||||
s_inflight_shift = i_shift;
|
||||
s_inflight_label = label;
|
||||
s_inflight_flags = flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
16
src/menus.h
16
src/menus.h
|
@ -107,6 +107,18 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
|||
#define CHECK_INCDEC_GENVAR( event, var, min, max) \
|
||||
var = checkIncDecGen(event,var,min,max)
|
||||
|
||||
#ifdef NAVIGATION_RE1
|
||||
extern int8_t *s_inflight_value;
|
||||
#define INFLIGHT(val) (s_inflight_value==&val ? SURROUNDED : 0)
|
||||
void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16_t i_max, int8_t i_shift, const pm_char *label);
|
||||
#define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, imin, imax, ishift, label) \
|
||||
checkInFlightIncDecModel(event, &var, imin, imax, ishift, label)
|
||||
#else
|
||||
#define INFLIGHT(val) 0
|
||||
#define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, min, max, shift, label) \
|
||||
var = shift+checkIncDecModel(event,var-shift,min,max)
|
||||
#endif
|
||||
|
||||
// Menus related stuff ...
|
||||
#ifdef NAVIGATION_RE1
|
||||
extern int8_t m_posVert;
|
||||
|
@ -148,4 +160,8 @@ if (!check_submenu_simple(event,lines_count-1)) return;
|
|||
TITLE(title); \
|
||||
SIMPLE_SUBMENU_NOTITLE(lines_count)
|
||||
|
||||
extern const pm_char * s_warning;
|
||||
// TODO macro for s_warning
|
||||
void displayBox();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -99,20 +99,12 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
|||
#endif
|
||||
};
|
||||
|
||||
const pm_char * s_warning = 0;
|
||||
|
||||
const pm_char * s_warning_info;
|
||||
uint8_t s_warning_info_len;
|
||||
// uint8_t s_warning_info_att not needed now
|
||||
uint8_t s_confirmation = 0;
|
||||
|
||||
void displayBox()
|
||||
{
|
||||
lcd_filled_rect(10, 16, 108, 40, SOLID, WHITE);
|
||||
lcd_rect(10, 16, 108, 40);
|
||||
lcd_puts(16, 3*FH, s_warning);
|
||||
// could be a place for a s_warning_info
|
||||
}
|
||||
|
||||
void displayPopup(const pm_char * pstr)
|
||||
{
|
||||
s_warning = pstr;
|
||||
|
@ -1603,20 +1595,15 @@ void menuProcLimits(uint8_t event)
|
|||
}
|
||||
break;
|
||||
case 1:
|
||||
lcd_outdezAtt( 12*FW, y, (int8_t)(ld->min-100), attr);
|
||||
lcd_outdezAtt(12*FW, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min));
|
||||
if (active) {
|
||||
ld->min -= 100;
|
||||
CHECK_INCDEC_MODELVAR( event, ld->min, -limit, limit);
|
||||
ld->min += 100;
|
||||
// CHECK_INFLIGHT_INCDEC(ld->min, -125, 125, PSTR("Min Limit"), EE_MODEL);
|
||||
CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, limit, +100, STR_MINLIMIT);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
lcd_outdezAtt( 17*FW, y, (int8_t)(ld->max+100), attr);
|
||||
lcd_outdezAtt(17*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max));
|
||||
if (active) {
|
||||
ld->max += 100;
|
||||
CHECK_INCDEC_MODELVAR( event, ld->max, -limit, limit);
|
||||
ld->max -= 100;
|
||||
CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -limit, limit, -100, STR_MAXLIMIT);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
|
|
@ -273,4 +273,6 @@ const pm_char STR_SYNCMENU[] PROGMEM = TR_SYNCMENU;
|
|||
|
||||
#if defined(NAVIGATION_RE1)
|
||||
const pm_char STR_BACK[] PROGMEM = TR_BACK;
|
||||
const pm_char STR_MINLIMIT[] PROGMEM = TR_MINLIMIT;
|
||||
const pm_char STR_MAXLIMIT[] PROGMEM = TR_MAXLIMIT;
|
||||
#endif
|
||||
|
|
|
@ -327,5 +327,6 @@ extern const pm_char STR_RXNUM[];
|
|||
extern const pm_char STR_SYNCMENU[];
|
||||
extern const pm_char STR_BACK[];
|
||||
#define LEN_BACK PSIZE(TR_BACK)
|
||||
|
||||
extern const pm_char STR_MINLIMIT[];
|
||||
extern const pm_char STR_MAXLIMIT[];
|
||||
#endif
|
||||
|
|
|
@ -298,3 +298,5 @@
|
|||
#define TR_RXNUM "RxNum"
|
||||
#define TR_SYNCMENU "Sync [MENU]"
|
||||
#define TR_BACK "Back"
|
||||
#define TR_MINLIMIT "Min Limit"
|
||||
#define TR_MAXLIMIT "Max Limit"
|
||||
|
|
|
@ -298,3 +298,5 @@
|
|||
#define TR_RXNUM "RxNum"
|
||||
#define TR_SYNCMENU "Sync [MENU]"
|
||||
#define TR_BACK "Back"
|
||||
#define TR_MINLIMIT "Min Limit"
|
||||
#define TR_MAXLIMIT "Max Limit"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue