summaryrefslogtreecommitdiff
path: root/Puzzle_Box/Puzzle_Box.h
blob: 8a310facd97a51f3a5b122633c5df50f2a1f3c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Pin assignments for the version 1.1 shield */
static const int GPSrx = 4, GPStx = 3; // GPS
static const int LCD_Enable = 6, LCD_RS = 5, LCD_RW = 7; // LCD
static const int LCD_DB4 = 16, LCD_DB5 = 17, LCD_DB6 = 18, LCD_DB7 = 19;
static const int pololu_switch_off = 12; // Pololu switch control
static const int servo_control = 9; // Servo control
static const int LED_pin = 2; // The button LED
static const int BUTTON_PIN = 1; // The pin for the button.

/* Function definitions */
void Msg(LiquidCrystal &lcd, const char *top, const char *bottom, unsigned long del);
void drawEye(int location);
void stepEyeAnimation();
void toggleEye(bool on);

void doIdle();
void displayMessage();
void doLatLong();
void doHeading();
void doEastOf();

bool doUpdateDistance();
void doCheckOverrideSerial();
void doCheckAccess();
void PowerOff();
float toRandomUnit(int choice, float dist);

float toRandomUnit(int choice, float dist);
char* getUnitLabel(int choice);

/* Fixed values should not need changing */
static const int DEF_ATTEMPT_MAX = 50;
static const int EEPROM_OFFSET = 100;

/* Program Stage Constants */
static const int MAIN_STAGE = 1;
static const int BUTTON_STAGE = 2;

static const char MESSAGE = 3;
static const char LATLONG = 4;
static const char HEADING = 5;
static const char EASTOF  = 6;
static const char OPEN    = 7;

static const byte STATES[] = {
        0,
        MESSAGE, // Daniel!? Is it you?
        MESSAGE, // Finally, you found me; Adventure time
        LATLONG,
        MESSAGE, // What's that?
        HEADING,
        MESSAGE, // Well that was fun, lets go back to camp
        EASTOF,
        MESSAGE, // Oh, btw, got you a gift
        OPEN
    };

// LATLONG
static const float LATLONG_LATITUDE = 46.09681;
static const float LATLONG_LONGITUDE = -121.65900;

// HEADING
// 46.092838, -121.649211
static const float HEADING_LATITUDE = 46.092838;
static const float HEADING_LONGITUDE = -121.649211;

// EASTOF
static const float EASTOF_LONGITUDE = -121.62730;

/* Random Units */
static const int NUMBER_OF_UNITS = 4;

/* Eye Animation Steps (12 step program) */
static const int eyeAnimationSteps[] = { 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2, 1, 0 };
static const int MAX_EYE_STEPS = 13;


/* OLD CONSTANTS */

/* These values should be adjusted according to your needs */
static const int CLOSED_ANGLE = 80; // degrees
static const int OPEN_ANGLE = 200; // degrees
static const int RADIUS = 100; // meters