|
| 1 | +/******************** |
| 2 | +Arduino generic menu system |
| 3 | +control led on/off delays |
| 4 | +
|
| 5 | +Rui Azevedo - ruihfazevedo(@rrob@)gmail.com |
| 6 | +
|
| 7 | +output: Serial |
| 8 | +input: Serial |
| 9 | +mcu: nano328p |
| 10 | +*/ |
| 11 | + |
| 12 | +#include <menu.h> |
| 13 | +#include <menuIO/serialOut.h> |
| 14 | +#include <menuIO/chainStream.h> |
| 15 | +#include <menuIO/serialIn.h> |
| 16 | + |
| 17 | +using namespace Menu; |
| 18 | + |
| 19 | +#define LEDPIN LED_BUILTIN |
| 20 | +#define MAX_DEPTH 1 |
| 21 | + |
| 22 | +int timeOn=10; |
| 23 | +int timeOff=90; |
| 24 | + |
| 25 | +MENU(mainMenu, "Blink menu", Menu::doNothing, Menu::noEvent, Menu::wrapStyle |
| 26 | + ,FIELD(timeOn,"On","ms",0,100,10,1, Menu::doNothing, Menu::noEvent, Menu::noStyle) |
| 27 | + ,FIELD(timeOff,"Off","ms",0,100,10,1,Menu::doNothing, Menu::noEvent, Menu::noStyle) |
| 28 | + ,EXIT("<Back") |
| 29 | +); |
| 30 | + |
| 31 | +serialIn serial(Serial); |
| 32 | +MENU_INPUTS(in,&serial); |
| 33 | + |
| 34 | +MENU_OUTPUTS(out,MAX_DEPTH |
| 35 | + ,SERIAL_OUT(Serial) |
| 36 | + ,NONE//must have 2 items at least |
| 37 | +); |
| 38 | + |
| 39 | +NAVROOT(nav,mainMenu,MAX_DEPTH,in,out); |
| 40 | + |
| 41 | +void setup() { |
| 42 | + pinMode(LEDPIN, OUTPUT); |
| 43 | + Serial.begin(115200); |
| 44 | + while(!Serial); |
| 45 | + Serial.println("Menu 4.x"); |
| 46 | + Serial.println("Use keys + - * /"); |
| 47 | + Serial.println("to control the menu navigation"); |
| 48 | +} |
| 49 | + |
| 50 | +void loop() { |
| 51 | + nav.poll(); |
| 52 | + digitalWrite(LEDPIN, HIGH); |
| 53 | + delay(timeOn); |
| 54 | + digitalWrite(LEDPIN, LOW); |
| 55 | + delay(timeOff); |
| 56 | +} |
0 commit comments