diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2012-04-17 08:37:45 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2012-04-17 08:37:45 -0700 |
commit | ee0e75d9457e4b9df8ee37762d761c352cbb6f67 (patch) | |
tree | b3fd2ee6938956fa9f72e0938f833f7b7f959090 /Puzzle_Box | |
parent | ae546ae8ac3f5392720554b37f86d4535bc67cfa (diff) | |
parent | ce9f530a1014862374f6be49f6cbdbe59e7604bc (diff) |
Merge branch 'master' of californium.jesterpm.net:git/puzzlebox
Conflicts:
Puzzle_Box/Puzzle_Box.pde
Diffstat (limited to 'Puzzle_Box')
-rw-r--r-- | Puzzle_Box/Puzzle_Box.pde | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Puzzle_Box/Puzzle_Box.pde b/Puzzle_Box/Puzzle_Box.pde index 5da3dd8..088ef2f 100644 --- a/Puzzle_Box/Puzzle_Box.pde +++ b/Puzzle_Box/Puzzle_Box.pde @@ -49,6 +49,7 @@ int currentStage = MAIN_STAGE; int attempt_counter; int currentEyeAnimationStep = 0; long lastLoopTime = 0; +long lastAniTime = 0; float currentDistance = -1; @@ -92,6 +93,11 @@ void setup() if (attempt_counter == 0xFF) // brand new EEPROM? attempt_counter = 0; + + lastLoopTime = millis(); + + pinMode(BUTTON_PIN, INPUT); + digitalWrite(BUTTON_PIN, HIGH); } /* The Arduino loop() function */ @@ -101,7 +107,7 @@ void loop() // Check for a stage transition int buttonState = digitalRead(BUTTON_PIN); - if (buttonState = HIGH) { + if (buttonState == LOW ) { currentStage = BUTTON_STAGE; } @@ -140,6 +146,7 @@ void doMainStage() { * 1400 E on (1600 ms) * 3000 Shift Anim. (200 ms/frame * 13 frames = 2600 ms) * 5600 On (3000 ms) + * 8600 Back to the start */ int delta = millis() - lastLoopTime; @@ -164,10 +171,13 @@ void doMainStage() { // On toggleEye(true); - } else if (delta < 5600) { + } else if (delta <= 5600) { // Shift Animation stepEyeAnimation(); + } else if (delta < 8600) { + // Do nothing for now + } else { // On toggleEye(true); @@ -220,6 +230,7 @@ void doButtonStage() { if (currentDistance == -1) { Msg(lcd, "No :(", "Signal", 2000); + attempt_counter--; return; } } @@ -350,9 +361,14 @@ void drawEye(int location) } void stepEyeAnimation() { + long delta = millis() - lastAniTime; + + if (delta >= 200) { drawEye(eyeAnimationSteps[currentEyeAnimationStep]); currentEyeAnimationStep++; currentEyeAnimationStep = currentEyeAnimationStep % 12; + lastAniTime = millis(); + } } void toggleEye(bool on) { @@ -385,7 +401,7 @@ float toRandomUnit(int choice, float dist) { // hands case 3: - return dist; + return dist; } } @@ -410,6 +426,8 @@ char* getUnitLabel(int choice) { case 3: return " hn."; + default: + return " ?"; } } |