got rid of example menu
This commit is contained in:
parent
56b1ca8627
commit
6546f11437
@ -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 <Arduino.h>
|
||||
#include <AnalogKeypad.h>
|
||||
@ -19,10 +17,6 @@
|
||||
#include <menu.h>
|
||||
#include <menuIO/liquidCrystalOut.h>
|
||||
#include <menuIO/serialIO.h>
|
||||
#include <menuIO/stringIn.h>
|
||||
#include <menuIO/chainStream.h>
|
||||
|
||||
//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("<Back")
|
||||
);
|
||||
|
||||
MENU(mainMenu, "PhotoStepper", doNothing, noEvent, wrapStyle
|
||||
//,SUBMENU(subMenu)
|
||||
,OP("Op1", action1, anyEvent)
|
||||
//,OP("Op2",action2,enterEvent)
|
||||
//,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle)
|
||||
//,SUBMENU(setLed)
|
||||
//,OP("LED On",myLedOn,enterEvent)
|
||||
//,OP("LED Off",myLedOff,enterEvent)
|
||||
//,SUBMENU(selMenu)
|
||||
//,SUBMENU(chooseMenu)
|
||||
,OP("Alert test",doAlert,enterEvent)
|
||||
MENU(mainMenu, "Main menu", doNothing, noEvent, wrapStyle
|
||||
,OP("Sub1", doNothing, noEvent)
|
||||
,OP("Sub2", doNothing, noEvent)
|
||||
,OP("Sub3", doNothing, noEvent)
|
||||
//,EXIT("<Back")
|
||||
);
|
||||
|
||||
MENU_OUTPUTS(out, MAX_DEPTH
|
||||
,LIQUIDCRYSTAL_OUT(lcd,{0,0,16,2})
|
||||
,NONE//must have 2 items at least
|
||||
,LIQUIDCRYSTAL_OUT(lcd, {0, 0, 16, 20})
|
||||
,NONE
|
||||
);
|
||||
|
||||
stringIn<0> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user