Skip to content

Commit

Permalink
use non-blocking blink example, fix action serialio example handler
Browse files Browse the repository at this point in the history
  • Loading branch information
neu-rah committed Apr 1, 2019
1 parent 455646f commit 537427d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ examples/clickEncoder
examples/screenNav
/dev
/examples/dev
/composition_test
/examples/tiny
15 changes: 7 additions & 8 deletions examples/Blink/Blink/Blink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ using namespace Menu;
#define LEDPIN LED_BUILTIN
#define MAX_DEPTH 1

int timeOn=10;
int timeOff=90;
unsigned int timeOn=10;
unsigned int timeOff=90;

MENU(mainMenu, "Blink menu", Menu::doNothing, Menu::noEvent, Menu::wrapStyle
,FIELD(timeOn,"On","ms",0,100,10,1, Menu::doNothing, Menu::noEvent, Menu::noStyle)
,FIELD(timeOff,"Off","ms",0,100,10,1,Menu::doNothing, Menu::noEvent, Menu::noStyle)
,FIELD(timeOn,"On","ms",0,1000,10,1, Menu::doNothing, Menu::noEvent, Menu::noStyle)
,FIELD(timeOff,"Off","ms",0,10000,10,1,Menu::doNothing, Menu::noEvent, Menu::noStyle)
,EXIT("<Back")
);

Expand All @@ -47,10 +47,9 @@ void setup() {
Serial.println("to control the menu navigation");
}

bool blink(int timeOn,int timeOff) {return millis()%(unsigned long)(timeOn+timeOff)<(unsigned long)timeOn;}

void loop() {
nav.poll();
digitalWrite(LEDPIN, HIGH);
delay(timeOn);
digitalWrite(LEDPIN, LOW);
delay(timeOff);
digitalWrite(LEDPIN, blink(timeOn,timeOff));
}
2 changes: 1 addition & 1 deletion examples/Blink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ src_dir=Blink
platform = atmelavr
board = nanoatmega328
framework = arduino
upload_port=/dev/ttyUSB*
upload_port=/dev/ttyUSB1
upload_flags=-V
build_flags = -DNODEBUG

Expand Down
2 changes: 1 addition & 1 deletion examples/Serial/serialio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ src_dir=serialio
platform = atmelavr
board = nanoatmega328
framework = arduino
upload_port=/dev/ttyUSB*
upload_port=/dev/ttyUSB1
upload_flags=-V
build_flags = -DNO_MENU_DEBUG -Wno-strict-aliasing -Wno-sign-compare -Wno-write-strings
;
Expand Down
2 changes: 1 addition & 1 deletion examples/Serial/serialio/serialio/serialio.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ result action1(eventMask e) {
return proceed;
}

result action2(eventMask e, prompt &item) {
result action2(eventMask e,navNode& nav,prompt& item) {
Serial.print(e);
Serial.print(" action2 executed, quiting menu");
return quit;
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ArduinoMenu library
version=4.17.20
version=4.17.21
author=Rui Azevedo, [email protected]
maintainer=neu-rah, [email protected]
sentence=Generic menu/interactivity system
Expand Down

0 comments on commit 537427d

Please sign in to comment.