From 6546f11437f7d01fe927f3028d607093f40d1acd Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Tue, 1 Feb 2022 15:15:57 +0100 Subject: [PATCH] got rid of example menu --- PhotoStepper/PhotoStepper.ino | 128 +++------------------------------- 1 file changed, 11 insertions(+), 117 deletions(-) diff --git a/PhotoStepper/PhotoStepper.ino b/PhotoStepper/PhotoStepper.ino index e500422..75fa382 100644 --- a/PhotoStepper/PhotoStepper.ino +++ b/PhotoStepper/PhotoStepper.ino @@ -10,8 +10,6 @@ // - https://www.arduino.cc/reference/en/libraries/arduinomenu-library/ // - https://www.arduino.cc/reference/en/libraries/stepperdriver/ // - https://www.arduino.cc/reference/en/libraries/analogkeypad/ -// -// this is still WIP, the menu is basically taken from example code. #include #include @@ -19,10 +17,6 @@ #include #include #include -#include -#include - -//using namespace Menu; // analog keypad #define PIN_BUTTON 0 @@ -63,116 +57,20 @@ State state = MENU; // === -result doAlert(eventMask e, prompt &item); - -result showEvent(eventMask e) { - Serial.print("event: "); - Serial.println(e); - return proceed; -} - -int test=55; - -result action1(eventMask e,navNode& nav, prompt &item) { - Serial.print("action1 event:"); - Serial.println(e); - Serial.flush(); - return proceed; -} - -result action2(eventMask e) { - Serial.print("actikon2 event:"); - Serial.println(e); - Serial.flush(); - return quit; -} - -int ledCtrl=LOW; - -result myLedOn() { - ledCtrl=HIGH; - return proceed; -} -result myLedOff() { - ledCtrl=LOW; - return proceed; -} - -TOGGLE(ledCtrl,setLed,"Led: ",doNothing,noEvent,wrapStyle//,doExit,enterEvent,noStyle - ,VALUE("On",HIGH,doNothing,noEvent) - ,VALUE("Off",LOW,doNothing,noEvent) -); - -int selTest=0; -SELECT(selTest,selMenu,"Select",doNothing,noEvent,wrapStyle - ,VALUE("Zero",0,doNothing,noEvent) - ,VALUE("One",1,doNothing,noEvent) - ,VALUE("Two",2,doNothing,noEvent) -); - -int chooseTest=-1; -CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,wrapStyle - ,VALUE("First",1,doNothing,noEvent) - ,VALUE("Second",2,doNothing,noEvent) - ,VALUE("Third",3,doNothing,noEvent) - ,VALUE("Last",-1,doNothing,noEvent) -); - -MENU(subMenu,"Sub-Menu",doNothing,anyEvent,wrapStyle - ,OP("Sub1",showEvent,enterEvent) - ,OP("Sub2",showEvent,enterEvent) - ,OP("Sub3",showEvent,enterEvent) - ,EXIT(" strIn; -serialIn serial(Serial); -NAVROOT(nav,mainMenu,MAX_DEPTH,serial,out); - -result alert(menuOut& o,idleEvent e) { - if (e==idling) { - o.setCursor(0,0); - o.print("alert test"); - o.setCursor(0,1); - o.print("[select] to continue..."); - Serial.println("rotating..."); - state = JOG; - } - return proceed; -} - -result doAlert(eventMask e, prompt &item) { - nav.idleOn(alert); - return proceed; -} - -result idle(menuOut& o,idleEvent e) { - switch(e) { - case idleStart:o.print("suspending menu!");break; - case idling:o.print("suspended...");break; - case idleEnd:o.print("resuming menu.");break; - } - return proceed; -} +serialIn in(Serial); +NAVROOT(nav, mainMenu, MAX_DEPTH, in, out); // === @@ -244,14 +142,10 @@ void setup() { while(!Serial); Serial.println("PhotoStepper -- schatenseite.de"); - pinMode(PIN_LED, OUTPUT); - // control backlight pinMode(PIN_LCD_BL, OUTPUT); digitalWrite(PIN_LCD_BL, HIGH); - nav.idleTask=idle;//point a function to be used when menu is suspended - stepper.begin(STEPPER_RPM, STEPPER_MICROSTEPS); stepper.setSpeedProfile(stepper.LINEAR_SPEED, STEPPER_ACCEL, STEPPER_DECEL); @@ -260,11 +154,11 @@ void setup() { lcd.print("PhotoStepper"); lcd.setCursor(0, 1); lcd.print("schatenseite.de"); - delay(500); + delay(2000); + nav.doOutput(); } void loop() { keypad.loop(ButtonHandler); stepper.nextAction(); - digitalWrite(PIN_LED, ledCtrl); }