Created
December 17, 2018 07:04
-
-
Save jbobrow/43a7d9b5da3b64ef861fa12926da291b to your computer and use it in GitHub Desktop.
not a code reference, just an animation reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Wake, Sleep, Program | |
Wake - simple spiral before loading game state | |
Sleep - simple spiral in reverse before going dark | |
Program - flash with urgency | |
*/ | |
uint32_t timeOfPress; | |
bool isAwake = false; | |
void setup() { | |
// put your setup code here, to run once: | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
if (buttonPressed()) { | |
timeOfPress = millis(); | |
if (!isAwake) { | |
// wake up animation | |
isAwake = true; | |
} | |
} | |
if (isAwake) { | |
setColor(OFF); | |
if ((millis() - timeOfPress) < 525 ) { | |
FOREACH_FACE(f) { | |
if ((millis() - timeOfPress) / 75 > f ) { | |
setColorOnFace(WHITE, f); | |
} | |
} | |
} | |
} | |
if (buttonDown()) { | |
uint32_t timeSincePress = millis() - timeOfPress; | |
if (timeSincePress > 1000 && timeSincePress < 2500) { | |
// flash | |
if ((millis() / 100) % 2 == 0) { | |
setColor(BLUE); | |
} | |
else { | |
setColor(OFF); | |
} | |
} | |
else if (timeSincePress > 2500) { | |
// start sleep animation | |
isAwake = false; | |
// sleep animation | |
setColor(BLUE); | |
if (timeSincePress - 2500 < 525 ) { | |
FOREACH_FACE(f) { | |
if (6 - ((timeSincePress - 2500) / 75) < f ) { | |
setColorOnFace(OFF, f); | |
} | |
} | |
} | |
else { | |
setColor(OFF); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment