Removed code duplication
Also fixed bug were I reset the active sub menu when then sleep timer kicks in.
This commit is contained in:
parent
65aa0f4dab
commit
6c721e8b65
1 changed files with 20 additions and 36 deletions
|
@ -947,6 +947,18 @@ static bool updateMenuPage( const MenuPage &page, uint32_t timeNow ) {
|
||||||
return redraw;
|
return redraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool updatePage(const MenuPage &page, uint32_t timeNow) {
|
||||||
|
if (stateFirstRun) {
|
||||||
|
drawMenu(page);
|
||||||
|
stateFirstRun = 0;
|
||||||
|
}
|
||||||
|
if (activeSub[page.cursor]) {
|
||||||
|
return updateSubMenu(page, timeNow);
|
||||||
|
} else {
|
||||||
|
return updateMenuPage(page, timeNow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
static void checkForPatchView(int buttons) {
|
static void checkForPatchView(int buttons) {
|
||||||
int trills = readTrills();
|
int trills = readTrills();
|
||||||
|
@ -1034,7 +1046,8 @@ void menu() {
|
||||||
// save the reading. Next time through the loop, it'll be the lastButtonState:
|
// save the reading. Next time through the loop, it'll be the lastButtonState:
|
||||||
lastDeumButtons = deumButtons;
|
lastDeumButtons = deumButtons;
|
||||||
|
|
||||||
if (state && ((timeNow - menuTime) > menuTimeUp)) { // shut off menu system if not used for a while (changes not stored by exiting a setting manually will not be stored in EEPROM)
|
// shut off menu system if not used for a while (changes not stored by exiting a setting manually will not be stored in EEPROM)
|
||||||
|
if (state && ((timeNow - menuTime) > menuTimeUp)) {
|
||||||
state = DISPLAYOFF_IDL;
|
state = DISPLAYOFF_IDL;
|
||||||
stateFirstRun = 1;
|
stateFirstRun = 1;
|
||||||
|
|
||||||
|
@ -1043,6 +1056,7 @@ void menu() {
|
||||||
subPriority = 0;
|
subPriority = 0;
|
||||||
|
|
||||||
subVibSquelch = 0;
|
subVibSquelch = 0;
|
||||||
|
memset(activeSub, 0, sizeof(activeSub));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == DISPLAYOFF_IDL) {
|
if (state == DISPLAYOFF_IDL) {
|
||||||
|
@ -1322,14 +1336,13 @@ void menu() {
|
||||||
} else if (state == ADJUST_MENU) {
|
} else if (state == ADJUST_MENU) {
|
||||||
// This is a hack to update touch_Thr is it was changed..
|
// This is a hack to update touch_Thr is it was changed..
|
||||||
int old_thr = ctouchThrVal;
|
int old_thr = ctouchThrVal;
|
||||||
int result = updateAdjustMenu( timeNow, buttonPressedAndNotUsed ? deumButtonState : 0, stateFirstRun, updateSensorPixelsFlag);
|
int result = updateAdjustMenu(timeNow, buttonPressedAndNotUsed ? deumButtonState : 0, stateFirstRun, updateSensorPixelsFlag);
|
||||||
|
|
||||||
updateSensorPixelsFlag = false;
|
updateSensorPixelsFlag = false;
|
||||||
stateFirstRun = 0;
|
stateFirstRun = 0;
|
||||||
buttonPressedAndNotUsed = 0;
|
buttonPressedAndNotUsed = 0;
|
||||||
|
|
||||||
if( result < 0)
|
if( result < 0) {
|
||||||
{
|
|
||||||
// Go back to main menu
|
// Go back to main menu
|
||||||
state = MAIN_MENU;
|
state = MAIN_MENU;
|
||||||
stateFirstRun = true;
|
stateFirstRun = true;
|
||||||
|
@ -1339,40 +1352,11 @@ void menu() {
|
||||||
touch_Thr = map(ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit);
|
touch_Thr = map(ctouchThrVal,ctouchHiLimit,ctouchLoLimit,ttouchLoLimit,ttouchHiLimit);
|
||||||
}
|
}
|
||||||
} else if (state == SETUP_BR_MENU) { // SETUP BREATH MENU HERE <<<<<<<<<<<<<<
|
} else if (state == SETUP_BR_MENU) { // SETUP BREATH MENU HERE <<<<<<<<<<<<<<
|
||||||
currentPage = &breathMenuPage;
|
redraw |= updatePage(breathMenuPage, timeNow);
|
||||||
if (stateFirstRun) {
|
|
||||||
drawMenu(*currentPage);
|
|
||||||
stateFirstRun = 0;
|
|
||||||
}
|
|
||||||
if (activeSub[currentPage->cursor]) {
|
|
||||||
redraw |= updateSubMenu(*currentPage, timeNow);
|
|
||||||
} else {
|
|
||||||
redraw |= updateMenuPage(*currentPage, timeNow);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (state == SETUP_CT_MENU) { // SETUP CONTROLLERS MENU HERE <<<<<<<<<<<<<
|
} else if (state == SETUP_CT_MENU) { // SETUP CONTROLLERS MENU HERE <<<<<<<<<<<<<
|
||||||
currentPage = &controlMenuPage;
|
redraw |= updatePage(controlMenuPage, timeNow);
|
||||||
if (stateFirstRun) {
|
|
||||||
drawMenu(*currentPage);
|
|
||||||
stateFirstRun = 0;
|
|
||||||
}
|
|
||||||
if (activeSub[currentPage->cursor]) {
|
|
||||||
redraw |= updateSubMenu(*currentPage, timeNow);
|
|
||||||
} else {
|
|
||||||
redraw |= updateMenuPage(*currentPage, timeNow);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (state == VIBRATO_MENU) { // VIBRATO MENU HERE <<<<<<<<<<<<<
|
} else if (state == VIBRATO_MENU) { // VIBRATO MENU HERE <<<<<<<<<<<<<
|
||||||
currentPage = &vibratoMenuPage;
|
redraw |= updatePage(vibratoMenuPage, timeNow);
|
||||||
if (stateFirstRun) {
|
|
||||||
drawMenu(*currentPage);
|
|
||||||
stateFirstRun = 0;
|
|
||||||
}
|
|
||||||
if (activeSub[currentPage->cursor]) {
|
|
||||||
redraw |= updateSubMenu(*currentPage, timeNow);
|
|
||||||
} else {
|
|
||||||
redraw |= updateMenuPage(*currentPage, timeNow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(redrawSubValue && currentPage) {
|
if(redrawSubValue && currentPage) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue