diff --git a/nametag/src/enums.cpp b/nametag/src/enums.cpp new file mode 100644 index 0000000..08c9433 --- /dev/null +++ b/nametag/src/enums.cpp @@ -0,0 +1,21 @@ +#include "enums.h" +#include "constants.h" +DisplayStyle next_style(DisplayStyle style) { + switch(style) { + case Rain: + return Congress; + break; + case Congress: + return Supercomputer; + break; + case Supercomputer: + return Cyber; + break; + case Cyber: + return Flame; + break; + case Flame: + return Rain; + break; + } +} diff --git a/nametag/src/main.cpp b/nametag/src/main.cpp index bd90ca5..16ccd6b 100644 --- a/nametag/src/main.cpp +++ b/nametag/src/main.cpp @@ -20,6 +20,7 @@ Mode mode = HighVis; DisplayStyle style = Rain; unsigned long last_switch; +bool cycling = true; void setup(){ pinMode(ONBOARD_LED, OUTPUT); @@ -52,9 +53,8 @@ void setup(){ void loop() { matrix ->flipDMABuffer(); matrix->clearScreen(); - //delay(25); - if (millis() - last_switch > CYCLE_TIME_MS) { + if (cycling and millis() - last_switch > CYCLE_TIME_MS) { // next style style = next_style(style); //DisplayStyle((style + 1) % (NumStyles - 1)); last_switch = millis(); @@ -76,8 +76,15 @@ void loop() { } if(!digitalRead(NEXT_BUTTON)) { - style = next_style(style); + unsigned long pressed_at = millis(); while(!digitalRead(NEXT_BUTTON)); // Wait for release + // see if the button was held or tapped + if (millis() - pressed_at > 500) { + // todo + cycling = not cycling; + } else { + style = next_style(style); + } } switch(style) {