mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
A little commit between two snow balls fight to warm the hands: this is the way that Cam proposed to exit submenus with Rotary Encoders. Still remaining: the Curve submenu. Ideas needed ;)
This commit is contained in:
parent
b40aff1058
commit
a8167c5e0c
7 changed files with 74 additions and 20 deletions
|
@ -153,7 +153,11 @@ bool check_submenu_simple(uint8_t event, uint8_t maxrow)
|
||||||
#define SCROLL_TH 64
|
#define SCROLL_TH 64
|
||||||
#define SCROLL_POT1_TH 32
|
#define SCROLL_POT1_TH 32
|
||||||
|
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
#define MAXCOL(row) ((horTab && row > 0) ? pgm_read_byte(horTab+min(row, (int8_t)horTabMax)) : (const uint8_t)0)
|
||||||
|
#else
|
||||||
#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, horTabMax)) : (const uint8_t)0)
|
#define MAXCOL(row) (horTab ? pgm_read_byte(horTab+min(row, horTabMax)) : (const uint8_t)0)
|
||||||
|
#endif
|
||||||
#define INC(val,max) if(val<max) {val++;} else {val=0;}
|
#define INC(val,max) if(val<max) {val++;} else {val=0;}
|
||||||
#define DEC(val,max) if(val>0 ) {val--;} else {val=max;}
|
#define DEC(val,max) if(val>0 ) {val--;} else {val=max;}
|
||||||
bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, uint8_t maxrow)
|
bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, uint8_t maxrow)
|
||||||
|
@ -172,11 +176,10 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
||||||
scrollRE = 0;
|
scrollRE = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event == EVT_KEY_LONG(BTN_RE1)) {
|
if (m_posVert < 0 && (event==EVT_KEY_FIRST(BTN_RE1) || event==EVT_KEY_FIRST(KEY_MENU))) {
|
||||||
if (!menuTab && !s_editMode) {
|
|
||||||
popMenu();
|
popMenu();
|
||||||
killEvents(event);
|
killEvents(event);
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
if (event == EVT_KEY_BREAK(BTN_RE1)) {
|
if (event == EVT_KEY_BREAK(BTN_RE1)) {
|
||||||
if (s_editMode > 0 && (maxcol & ZCHAR)) {
|
if (s_editMode > 0 && (maxcol & ZCHAR)) {
|
||||||
|
@ -260,6 +263,11 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
||||||
s_noScroll = 0;
|
s_noScroll = 0;
|
||||||
DisplayScreenIndex(curr, menuTabSize, attr);
|
DisplayScreenIndex(curr, menuTabSize, attr);
|
||||||
}
|
}
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
else if (m_posVert < 0) {
|
||||||
|
lcd_putsAtt(DISPLAY_W-LEN_BACK*FW, 0, STR_BACK, INVERS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
theFile.DisplayProgressBar(menuTab ? lcd_lastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1);
|
theFile.DisplayProgressBar(menuTab ? lcd_lastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1);
|
||||||
|
|
||||||
|
@ -283,7 +291,8 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
||||||
if (maxcol & ZCHAR) maxcol = 0;
|
if (maxcol & ZCHAR) maxcol = 0;
|
||||||
if (++m_posHorz > maxcol) {
|
if (++m_posHorz > maxcol) {
|
||||||
if (m_posVert < maxrow) {
|
if (m_posVert < maxrow) {
|
||||||
maxcol = MAXCOL(++m_posVert); // TODO not stored into maxcol?
|
++m_posVert;
|
||||||
|
maxcol = MAXCOL(m_posVert); // TODO not stored into maxcol?
|
||||||
if (maxcol < 0) m_posVert++;
|
if (maxcol < 0) m_posVert++;
|
||||||
m_posHorz = 0;
|
m_posHorz = 0;
|
||||||
}
|
}
|
||||||
|
@ -296,8 +305,12 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
||||||
else {
|
else {
|
||||||
++scrollRE;
|
++scrollRE;
|
||||||
if (m_posHorz-- == 0) {
|
if (m_posHorz-- == 0) {
|
||||||
if (m_posVert-- == 0) {
|
if (m_posVert-- <= 0) {
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
m_posVert = menuTab ? 0 : -1;
|
||||||
|
#else
|
||||||
m_posVert = 0;
|
m_posVert = 0;
|
||||||
|
#endif
|
||||||
m_posHorz = 0;
|
m_posHorz = 0;
|
||||||
scrollRE = 0;
|
scrollRE = 0;
|
||||||
}
|
}
|
||||||
|
@ -376,8 +389,11 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa
|
||||||
case EVT_KEY_FIRST(KEY_DOWN): //inc
|
case EVT_KEY_FIRST(KEY_DOWN): //inc
|
||||||
if(s_editMode>0)break;
|
if(s_editMode>0)break;
|
||||||
do {
|
do {
|
||||||
INC(m_posVert,maxrow);
|
INC(m_posVert, maxrow);
|
||||||
} while(MAXCOL(m_posVert) == (uint8_t)-1);
|
} while(MAXCOL(m_posVert) == (uint8_t)-1);
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
s_editMode = 0;
|
||||||
|
#endif
|
||||||
m_posHorz = min(m_posHorz, MAXCOL(m_posVert));
|
m_posHorz = min(m_posHorz, MAXCOL(m_posVert));
|
||||||
BLINK_SYNC;
|
BLINK_SYNC;
|
||||||
break;
|
break;
|
||||||
|
@ -405,7 +421,11 @@ MenuFuncP g_menuStack[5];
|
||||||
uint8_t g_menuPos[4];
|
uint8_t g_menuPos[4];
|
||||||
uint8_t g_menuStackPtr = 0;
|
uint8_t g_menuStackPtr = 0;
|
||||||
|
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
int8_t m_posVert;
|
||||||
|
#else
|
||||||
uint8_t m_posVert;
|
uint8_t m_posVert;
|
||||||
|
#endif
|
||||||
uint8_t m_posHorz;
|
uint8_t m_posHorz;
|
||||||
|
|
||||||
void popMenu()
|
void popMenu()
|
||||||
|
|
|
@ -108,7 +108,11 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
|
||||||
var = checkIncDecGen(event,var,min,max)
|
var = checkIncDecGen(event,var,min,max)
|
||||||
|
|
||||||
// Menus related stuff ...
|
// Menus related stuff ...
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
extern int8_t m_posVert;
|
||||||
|
#else
|
||||||
extern uint8_t m_posVert;
|
extern uint8_t m_posVert;
|
||||||
|
#endif
|
||||||
extern uint8_t m_posHorz;
|
extern uint8_t m_posHorz;
|
||||||
inline void minit(){m_posVert=m_posHorz=0;}
|
inline void minit(){m_posVert=m_posHorz=0;}
|
||||||
bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *subTab, uint8_t subTabMax, uint8_t maxrow);
|
bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *subTab, uint8_t subTabMax, uint8_t maxrow);
|
||||||
|
|
|
@ -185,6 +185,10 @@ void menuProcModelSelect(uint8_t event)
|
||||||
|
|
||||||
int8_t oldSub = m_posVert;
|
int8_t oldSub = m_posVert;
|
||||||
if (!check_submenu_simple(_event_, MAX_MODELS-1)) return;
|
if (!check_submenu_simple(_event_, MAX_MODELS-1)) return;
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
if (m_posVert < 0) m_posVert = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
int8_t sub = m_posVert;
|
int8_t sub = m_posVert;
|
||||||
|
|
||||||
lcd_puts(9*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
|
lcd_puts(9*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
|
||||||
|
@ -624,7 +628,7 @@ void menuProcPhaseOne(uint8_t event)
|
||||||
PhaseData *phase = phaseaddress(s_currIdx);
|
PhaseData *phase = phaseaddress(s_currIdx);
|
||||||
putsFlightPhase(13*FW, 0, s_currIdx+1, 0);
|
putsFlightPhase(13*FW, 0, s_currIdx+1, 0);
|
||||||
|
|
||||||
SUBMENU(STR_MENUFLIGHTPHASE, (s_currIdx==0 ? 3 : 5), {ZCHAR|(sizeof(phase->name)-1), 0, 3/*, 0, 0*/});
|
SUBMENU(STR_MENUFLIGHTPHASE, (s_currIdx==0 ? 3 : 5), {ZCHAR|(sizeof(phase->name)-1), 0, 3, 0/*, 0*/});
|
||||||
|
|
||||||
int8_t sub = m_posVert;
|
int8_t sub = m_posVert;
|
||||||
|
|
||||||
|
@ -849,8 +853,14 @@ void menuProcCurveOne(uint8_t event)
|
||||||
case EVT_ENTRY:
|
case EVT_ENTRY:
|
||||||
dfltCrv = 0;
|
dfltCrv = 0;
|
||||||
autoThrStep = 0;
|
autoThrStep = 0;
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
s_editMode = -1;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case EVT_KEY_FIRST(KEY_MENU):
|
case EVT_KEY_FIRST(KEY_MENU):
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
case EVT_KEY_BREAK(BTN_RE1):
|
||||||
|
#endif
|
||||||
if (s_editMode<=0) {
|
if (s_editMode<=0) {
|
||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1182,21 +1192,20 @@ void menuProcMixOne(uint8_t event)
|
||||||
|
|
||||||
int8_t sub = m_posVert;
|
int8_t sub = m_posVert;
|
||||||
|
|
||||||
for(uint8_t k=0; k<7; k++)
|
for (uint8_t k=0; k<7; k++) {
|
||||||
{
|
|
||||||
uint8_t y = (k+1) * FH;
|
uint8_t y = (k+1) * FH;
|
||||||
uint8_t i = k + s_pgOfs;
|
uint8_t i = k + s_pgOfs;
|
||||||
uint8_t attr = sub==i ? INVERS : 0;
|
uint8_t attr = sub==i ? INVERS : 0;
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case 0:
|
case 0:
|
||||||
lcd_puts( 2*FW,y,STR_SOURCE);
|
lcd_puts(2*FW, y, STR_SOURCE);
|
||||||
putsChnRaw( FW*10,y,md2->srcRaw,attr);
|
putsChnRaw(FW*10, y, md2->srcRaw, attr);
|
||||||
if(attr) CHECK_INCDEC_MODELVAR( event, md2->srcRaw, 1,NUM_XCHNRAW);
|
if(attr) CHECK_INCDEC_MODELVAR(event, md2->srcRaw, 1,NUM_XCHNRAW);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
lcd_puts( 2*FW,y,STR_WEIGHT);
|
lcd_puts( 2*FW,y,STR_WEIGHT);
|
||||||
lcd_outdezAtt(FW*10,y,md2->weight,attr|LEFT);
|
lcd_outdezAtt(FW*10,y,md2->weight,attr|LEFT);
|
||||||
if(attr) CHECK_INCDEC_MODELVAR( event, md2->weight, -125,125);
|
if(attr) CHECK_INCDEC_MODELVAR(event, md2->weight, -125,125);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
lcd_puts( 2*FW,y,STR_OFFSET);
|
lcd_puts( 2*FW,y,STR_OFFSET);
|
||||||
|
@ -1350,7 +1359,11 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
|
||||||
lcd_puts(lcd_lastPos, 0, expo ? PSTR("/14") : PSTR("/32"));
|
lcd_puts(lcd_lastPos, 0, expo ? PSTR("/14") : PSTR("/32"));
|
||||||
SIMPLE_MENU_NOTITLE(menuTabModel, expo ? e_ExposAll : e_MixAll, s_maxLines);
|
SIMPLE_MENU_NOTITLE(menuTabModel, expo ? e_ExposAll : e_MixAll, s_maxLines);
|
||||||
|
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
int8_t sub = m_posVert;
|
||||||
|
#else
|
||||||
uint8_t sub = m_posVert;
|
uint8_t sub = m_posVert;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(_event)
|
switch(_event)
|
||||||
{
|
{
|
||||||
|
@ -1394,7 +1407,14 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// no break
|
// no break
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
case EVT_KEY_BREAK(BTN_RE1):
|
||||||
|
case EVT_KEY_LONG(BTN_RE1):
|
||||||
|
if (sub == 0)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
case EVT_KEY_LONG(KEY_MENU):
|
case EVT_KEY_LONG(KEY_MENU):
|
||||||
|
killEvents(_event);
|
||||||
if (s_copyTgtOfs) {
|
if (s_copyTgtOfs) {
|
||||||
s_copyMode = 0;
|
s_copyMode = 0;
|
||||||
s_copyTgtOfs = 0;
|
s_copyTgtOfs = 0;
|
||||||
|
@ -1409,7 +1429,6 @@ void menuProcExpoMix(uint8_t expo, uint8_t _event_)
|
||||||
s_copyMode = 0;
|
s_copyMode = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
killEvents(_event);
|
|
||||||
break;
|
break;
|
||||||
case EVT_KEY_LONG(KEY_LEFT):
|
case EVT_KEY_LONG(KEY_LEFT):
|
||||||
case EVT_KEY_LONG(KEY_RIGHT):
|
case EVT_KEY_LONG(KEY_RIGHT):
|
||||||
|
@ -1622,6 +1641,9 @@ void menuProcCurvesAll(uint8_t event)
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVT_KEY_FIRST(KEY_RIGHT):
|
case EVT_KEY_FIRST(KEY_RIGHT):
|
||||||
case EVT_KEY_FIRST(KEY_MENU):
|
case EVT_KEY_FIRST(KEY_MENU):
|
||||||
|
#ifdef NAVIGATION_RE1
|
||||||
|
case EVT_KEY_BREAK(BTN_RE1):
|
||||||
|
#endif
|
||||||
if (sub >= 0) {
|
if (sub >= 0) {
|
||||||
s_curveChan = sub;
|
s_curveChan = sub;
|
||||||
pushMenu(menuProcCurveOne);
|
pushMenu(menuProcCurveOne);
|
||||||
|
|
|
@ -270,3 +270,7 @@ const pm_char STR_RXNUM[] PROGMEM = TR_RXNUM;
|
||||||
#if defined(PXX)
|
#if defined(PXX)
|
||||||
const pm_char STR_SYNCMENU[] PROGMEM = TR_SYNCMENU;
|
const pm_char STR_SYNCMENU[] PROGMEM = TR_SYNCMENU;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(NAVIGATION_RE1)
|
||||||
|
const pm_char STR_BACK[] PROGMEM = TR_BACK;
|
||||||
|
#endif
|
||||||
|
|
|
@ -325,5 +325,7 @@ extern const pm_char STR_MENUSTAT[];
|
||||||
extern const pm_char STR_MENUDEBUG[];
|
extern const pm_char STR_MENUDEBUG[];
|
||||||
extern const pm_char STR_RXNUM[];
|
extern const pm_char STR_RXNUM[];
|
||||||
extern const pm_char STR_SYNCMENU[];
|
extern const pm_char STR_SYNCMENU[];
|
||||||
|
extern const pm_char STR_BACK[];
|
||||||
|
#define LEN_BACK PSIZE(TR_BACK)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -297,3 +297,4 @@
|
||||||
#define TR_MENUDEBUG "DEBUG"
|
#define TR_MENUDEBUG "DEBUG"
|
||||||
#define TR_RXNUM "RxNum"
|
#define TR_RXNUM "RxNum"
|
||||||
#define TR_SYNCMENU "Sync [MENU]"
|
#define TR_SYNCMENU "Sync [MENU]"
|
||||||
|
#define TR_BACK "Back"
|
||||||
|
|
|
@ -297,3 +297,4 @@
|
||||||
#define TR_MENUDEBUG "DEBUG"
|
#define TR_MENUDEBUG "DEBUG"
|
||||||
#define TR_RXNUM "RxNum"
|
#define TR_RXNUM "RxNum"
|
||||||
#define TR_SYNCMENU "Sync [MENU]"
|
#define TR_SYNCMENU "Sync [MENU]"
|
||||||
|
#define TR_BACK "Back"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue