diff options
-rw-r--r-- | Puzzle_Box/Puzzle_Box.h | 3 | ||||
-rw-r--r-- | Puzzle_Box/Puzzle_Box.pde | 97 | ||||
-rw-r--r-- | Puzzle_Box/notes.txt | 11 |
3 files changed, 87 insertions, 24 deletions
diff --git a/Puzzle_Box/Puzzle_Box.h b/Puzzle_Box/Puzzle_Box.h index a558803..d792511 100644 --- a/Puzzle_Box/Puzzle_Box.h +++ b/Puzzle_Box/Puzzle_Box.h @@ -14,13 +14,14 @@ static const int BUTTON_PIN = 1; // The pin for the button. void Msg(LiquidCrystal &lcd, const char *top, const char *bottom, unsigned long del); void drawEye(int location); void stepEyeAnimation(); -void blinkEye(); +void toggleEye(bool on); void doMainStage(); void doButtonStage(); void doUpdateDistance(); void doCheckOverrideSerial(); void doCheckAccess(); void PowerOff(); +float toRandomUnit(int choice, float dist); /* Fixed values should not need changing */ static const int DEF_ATTEMPT_MAX = 50; diff --git a/Puzzle_Box/Puzzle_Box.pde b/Puzzle_Box/Puzzle_Box.pde index bda85f0..53f4f96 100644 --- a/Puzzle_Box/Puzzle_Box.pde +++ b/Puzzle_Box/Puzzle_Box.pde @@ -132,14 +132,49 @@ void loop() * This is what we do while idle... */ void doMainStage() { - - - if (millis() - lastLoopTime > 200) { - stepEyeAnimation(); - lastLoopTime = millis(); - } - - + /* Timeline + * 0 E On (500 ms) + * 500 E Off (200 ms) + * 700 E On (500 ms) + * 1200 E off (200 ms) + * 1400 E on (1600 ms) + * 3000 Shift Anim. (200 ms/frame * 13 frames = 2600 ms) + * 5600 On (3000 ms) + */ + + int delta = millis() - lastLoopTime; + + if (delta < 500) { + // On + toggleEye(true); + + } else if (delta < 700) { + // Off + toggleEye(false); + + } else if (delta < 1200) { + // On + toggleEye(true); + + } else if (delta < 1400) { + // Off + toggleEye(false); + + } else if (delta < 3000) { + // On + toggleEye(true); + + } else if (delta < 5600) { + // Shift Animation + stepEyeAnimation(); + + } else { + // On + toggleEye(true); + + // Reset timer + lastLoopTime = millis(); + } } /** @@ -308,25 +343,41 @@ void drawEye(int location) } void stepEyeAnimation() { - //if (currentEyeAnimationStep < 12) { drawEye(eyeAnimationSteps[currentEyeAnimationStep]); currentEyeAnimationStep++; currentEyeAnimationStep = currentEyeAnimationStep % 12; - //} } -void blinkEye() { - // Eyes on - digitalWrite(LED_pin, HIGH); - delay(100); - - // Off - lcd.noDisplay(); - digitalWrite(LED_pin, LOW); - delay(100); - - // Back on - lcd.display(); - digitalWrite(LED_pin, HIGH); +void toggleEye(bool on) { + // Eyes on + if (on) { + lcd.display(); + digitalWrite(LED_pin, HIGH); + + } else { + lcd.noDisplay(); + digitalWrite(LED_pin, LOW); + } } +/** + * Convert the distance to a particular unit. + * + */ +float toRandomUnit(int choice, float dist) { + switch (choice) { + // feet + case 0: + + // meters + case 1: + + // cubits + case 2: + + // hands + case 3: + + + } +} diff --git a/Puzzle_Box/notes.txt b/Puzzle_Box/notes.txt new file mode 100644 index 0000000..f2bb8ef --- /dev/null +++ b/Puzzle_Box/notes.txt @@ -0,0 +1,11 @@ +* Turns on + +* Eyes shift +* Blink +* Rnd Blink/shift + +Once the button has been pressed: + * Witty comment + * Give distance in a random unit + + |