summaryrefslogtreecommitdiff
path: root/Puzzle_Box
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2012-04-17 08:09:21 -0700
committerJesse Morgan <jesse@jesterpm.net>2012-04-17 08:09:21 -0700
commitce9f530a1014862374f6be49f6cbdbe59e7604bc (patch)
tree74d922c59f68a1423b5e2d8842d8b74d5df9ff61 /Puzzle_Box
parent6873b51aefeffff8ac0211e151fe38ea251e4889 (diff)
Adding bug fixes.
Diffstat (limited to 'Puzzle_Box')
-rw-r--r--Puzzle_Box/Puzzle_Box.pde26
1 files changed, 22 insertions, 4 deletions
diff --git a/Puzzle_Box/Puzzle_Box.pde b/Puzzle_Box/Puzzle_Box.pde
index 53f4f96..cf630d4 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 = 0;
@@ -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);
@@ -273,7 +283,7 @@ void doCheckAccess() {
Msg(lcd, "Access", "Denied!", 2000);
}
- PowerOff();
+ currentStage = MAIN_STAGE;
}
@@ -343,9 +353,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) {
@@ -377,7 +392,10 @@ float toRandomUnit(int choice, float dist) {
// hands
case 3:
-
+
+ return 0;
}
+
+ return 0;
}