Skip to content

Commit 205d9b5

Browse files
authored
Merge pull request #231 from ALittleSlow/master
similar to standard Arduino Button example
2 parents cc5a885 + c0bf2ad commit 205d9b5

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

examples/Button/Button/Button.ino

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
}

examples/Button/platformio.ini

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter, extra scripting
4+
; Upload options: custom port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
;
7+
; Please visit documentation for the other options and examples
8+
; http://docs.platformio.org/en/stable/projectconf.html
9+
10+
11+
[platformio]
12+
src_dir=Blink
13+
; lib_dir=~/Arduino/Libraries
14+
15+
[env:nanoatmega328]
16+
platform = atmelavr
17+
board = nanoatmega328
18+
framework = arduino
19+
upload_port=/dev/ttyUSB*
20+
upload_flags=-V
21+
build_flags = -DNODEBUG
22+
23+
; [env:uno]
24+
; platform = atmelavr
25+
; board = nanoatmega328
26+
; framework = arduino
27+
28+
; [env:due]
29+
; platform = atmelsam
30+
; board = due
31+
; framework = arduino
32+
; build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined
33+
34+
; [env:teensy31]
35+
; platform = teensy
36+
; board = teensy31
37+
; framework = arduino
38+
; build_flags = -DMENU_USERAM

0 commit comments

Comments
 (0)