make the cycle pausable
This commit is contained in:
parent
b3026052c2
commit
cd8f565e3e
21
nametag/src/enums.cpp
Normal file
21
nametag/src/enums.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user