From fb8e569f2cc63022a81d0a918619fcb7d26e5e06 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 28 Apr 2012 10:30:13 -0700 Subject: Adding quotes. --- Puzzle_Box/Puzzle_Box.h | 2 +- Puzzle_Box/Puzzle_Box.pde | 29 ++++++++++++++++++++--------- Puzzle_Box/quotes.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 Puzzle_Box/quotes.h 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!" } } } +}; -- cgit v1.2.3