summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-11-22 12:21:56 -0800
committerJesse Morgan <jesse@jesterpm.net>2011-11-22 12:21:56 -0800
commit6873b51aefeffff8ac0211e151fe38ea251e4889 (patch)
tree0698837d36ffd3c41d581ea24a2f637e24fb8078
parent60811af8060d9b27ef122f148f318bcdf30a4384 (diff)
Got the main stage setup
-rw-r--r--Puzzle_Box/Puzzle_Box.h3
-rw-r--r--Puzzle_Box/Puzzle_Box.pde97
-rw-r--r--Puzzle_Box/notes.txt11
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
+
+