summaryrefslogtreecommitdiff
path: root/Puzzle_Box
diff options
context:
space:
mode:
authorJesse Morgan <jesterpm@Bismuth.jesterpm.net>2012-04-28 10:30:13 -0700
committerJesse Morgan <jesterpm@Bismuth.jesterpm.net>2012-04-28 10:30:13 -0700
commitfb8e569f2cc63022a81d0a918619fcb7d26e5e06 (patch)
treec4c817f7f209d4ddcf474b4bacf652ebcd900be6 /Puzzle_Box
parentee0e75d9457e4b9df8ee37762d761c352cbb6f67 (diff)
Adding quotes.
Diffstat (limited to 'Puzzle_Box')
-rw-r--r--Puzzle_Box/Puzzle_Box.h2
-rw-r--r--Puzzle_Box/Puzzle_Box.pde29
-rw-r--r--Puzzle_Box/quotes.h30
3 files changed, 51 insertions, 10 deletions
diff --git a/Puzzle_Box/Puzzle_Box.h b/Puzzle_Box/Puzzle_Box.h
index d792511..46a0bdb 100644
--- a/Puzzle_Box/Puzzle_Box.h
+++ b/Puzzle_Box/Puzzle_Box.h
@@ -17,7 +17,7 @@ void stepEyeAnimation();
void toggleEye(bool on);
void doMainStage();
void doButtonStage();
-void doUpdateDistance();
+bool doUpdateDistance();
void doCheckOverrideSerial();
void doCheckAccess();
void PowerOff();
diff --git a/Puzzle_Box/Puzzle_Box.pde b/Puzzle_Box/Puzzle_Box.pde
index 088ef2f..53ff040 100644
--- a/Puzzle_Box/Puzzle_Box.pde
+++ b/Puzzle_Box/Puzzle_Box.pde
@@ -52,6 +52,7 @@ long lastLoopTime = 0;
long lastAniTime = 0;
float currentDistance = -1;
+bool im_ready = false;
/* The Arduino setup() function */
@@ -124,7 +125,12 @@ void loop()
}
// Find the current distance just to be ready
- doUpdateDistance();
+ /*if (doUpdateDistance() && im_ready == false) {
+ Msg(lcd, "GPS", "Rowered!", 2000);
+ im_ready = true;
+ }*/
+
+
// Check for override login attempts
doCheckOverrideSerial();
@@ -205,15 +211,15 @@ void doButtonStage() {
/* Game over? */
// TODO: Oh no!
- /*if (attempt_counter >= DEF_ATTEMPT_MAX)
+ if (attempt_counter >= DEF_ATTEMPT_MAX)
{
Msg(lcd, "Sorry!", "No more", 2000);
Msg(lcd, "attempts", "allowed!", 2000);
PowerOff();
- }*/
+ }
/* Print out the attempt counter */
- Msg(lcd, "This is", "attempt", 2000);
+ Msg(lcd, "This is", "attempt", 1500);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(attempt_counter);
@@ -221,12 +227,10 @@ void doButtonStage() {
lcd.print(DEF_ATTEMPT_MAX);
delay(2000);
- /* Save the new attempt counter */
- EEPROM.write(EEPROM_OFFSET, attempt_counter);
-
if (currentDistance == -1) {
Msg(lcd, "Seeking", "Signal..", 0);
- doUpdateDistance();
+ long start = millis();
+ while (!doUpdateDistance() && millis() - start < 5000);
if (currentDistance == -1) {
Msg(lcd, "No :(", "Signal", 2000);
@@ -235,14 +239,19 @@ void doButtonStage() {
}
}
+ /* Save the new attempt counter */
+ EEPROM.write(EEPROM_OFFSET, attempt_counter);
+
doCheckAccess();
}
/**
* This function updates the distance, if possible.
+ *
+ * Return true if it finished reading data.
*/
-void doUpdateDistance() {
+bool doUpdateDistance() {
/* Has a valid NMEA sentence been parsed? */
if (nss.available() && tinygps.encode(nss.read()))
{
@@ -255,9 +264,11 @@ void doUpdateDistance() {
{
/* Calculate the distance to the destination */
currentDistance = TinyGPS::distance_between(lat, lon, DEST_LATITUDE, DEST_LONGITUDE);
+ return true;
}
}
+ return false;
}
/**
diff --git a/Puzzle_Box/quotes.h b/Puzzle_Box/quotes.h
new file mode 100644
index 0000000..02c3169
--- /dev/null
+++ b/Puzzle_Box/quotes.h
@@ -0,0 +1,30 @@
+typedef struct {
+ char* line1;
+ char* line2;
+} line_pair_t;
+
+typedef struct {
+ int pairs;
+ line_pair_t * lines;
+} message_t;
+
+const int msgcount = 12;
+const message_t messages[] = {
+ { 1, (line_pair_t []){ {"That is" , "my eye!" } } },
+ { 1, (line_pair_t []){ {"Ouch!" , "" } } },
+ { 1, (line_pair_t []){ {"Hey!" , "" } } },
+ { 2, (line_pair_t []){ {"Stop!" , "" },
+ {"Poking ", "Me!" } } },
+ { 2, (line_pair_t []){ {"Great...", "now I" },
+ {"can only", "see 2D" } } },
+ { 3, (line_pair_t []){ {"Grrrr!" , "" },
+ {"That." , "Is." },
+ {"My." , "Eye!" } } },
+ { 1, (line_pair_t []){ {"Ouch!" , "You Suck"} } },
+ { 1, (line_pair_t []){ {"I hate" , "you..." } } },
+ { 1, (line_pair_t []){ {"Abuse!" , "Abuse!" } } },
+ { 1, (line_pair_t []){ {"Eye !!", "Murderer"} } },
+ { 2, (line_pair_t []){ {"Its dark", "over" },
+ {"there" , " >>" } } },
+ { 1, (line_pair_t []){ {"OH! Ouch", "Pain!" } } }
+};