refactored

This commit is contained in:
Ronald Schaten 2022-02-01 18:39:59 +01:00
parent 9b76d6766a
commit d92f47ee26

View File

@ -98,26 +98,20 @@ NAVROOT(nav, mainMenu, MAX_DEPTH, in, out);
// === // ===
void ButtonHandler(const ButtonParam& param) { void ButtonHandler_menu(const ButtonParam& param) {
Serial.print("ButtonHandler_menu(");
Serial.print(param.button); Serial.print(param.button);
Serial.print(" "); Serial.println(")");
switch (state) {
case STATE_MENU:
Serial.print("menu - ");
switch (param.state) { switch (param.state) {
case ButtonState_Click: case ButtonState_Click:
Serial.print("Click"); Serial.print("Click");
switch (param.button) { switch (param.button) {
case KEY_RIGHT:
break;
case KEY_UP: case KEY_UP:
nav.doNav(upCmd); nav.doNav(upCmd);
break; break;
case KEY_DOWN: case KEY_DOWN:
nav.doNav(downCmd); nav.doNav(downCmd);
break; break;
case KEY_LEFT:
break;
case KEY_SELECT: case KEY_SELECT:
nav.doNav(enterCmd); nav.doNav(enterCmd);
break; break;
@ -125,9 +119,12 @@ void ButtonHandler(const ButtonParam& param) {
nav.doOutput(); nav.doOutput();
break; break;
} }
break; }
case STATE_JOG:
Serial.print("jogging - "); void ButtonHandler_jog(const ButtonParam& param) {
Serial.print("ButtonHandler_jog(");
Serial.print(param.button);
Serial.println(")");
switch (param.state) { switch (param.state) {
case ButtonState_Up: case ButtonState_Up:
Serial.print("Up"); Serial.print("Up");
@ -158,9 +155,12 @@ void ButtonHandler(const ButtonParam& param) {
Serial.print("Hold"); Serial.print("Hold");
break; break;
} }
break;
} }
Serial.println();
void ButtonHandler_run(const ButtonParam& param) {
Serial.print("ButtonHandler_run(");
Serial.print(param.button);
Serial.println(")");
} }
void setup() { void setup() {
@ -183,6 +183,16 @@ void setup() {
} }
void loop() { void loop() {
keypad.loop(ButtonHandler); switch (state) {
case STATE_MENU:
keypad.loop(ButtonHandler_menu);
break;
case STATE_JOG:
keypad.loop(ButtonHandler_jog);
break;
case STATE_RUN:
keypad.loop(ButtonHandler_run);
break;
}
stepper.nextAction(); stepper.nextAction();
} }