     Serial.println((int)b);
 }
 
+/* todo: standby/active bluetooth and gps
+   make bluetooth interruptable
+   make bluetooth transactions reliable and "transactional" */
 void setup(void)
 {
     /* Initialise LCD - Print startup message */
     lcd_init();
     lcd_clear_display();
+    lcd_write_str("CREAM");
+
+    attachInterrupt(GREEN_BUTTON_INTERRUPT_NUM, green_button_handler, FALLING);
+    attachInterrupt(BLUE_BUTTON_INTERRUPT_NUM, blue_button_handler, FALLING);
 
     pinMode(BUSY_LED, OUTPUT);
 
+    int tracking;
+    while (1) {
+        noInterrupts();
+
+        /* handle green button press */
+        if (g_green_button_pressed) {
+            g_green_button_pressed = 0;
+            interrupts();
+
+            run_tracking();
+
+            /* clear all blue presses that occured while in tracking */
+            noInterrupts();
+            g_blue_button_pressed = 0;
+            interrupts();
+
+            lcd_clear_display();
+            lcd_write_str("CREAM");
+        }
+
+        /* handle blue button press */
+        if (g_blue_button_pressed) {
+            g_blue_button_pressed = 0;
+            interrupts();
+
+            run_bluetooth();
+
+            /* clear all green presses that occured while in bluetooth */
+            noInterrupts();
+            g_green_button_pressed = 0;
+            interrupts();
+
+            lcd_clear_display();
+            lcd_write_str("CREAM");
+        }
+
+        interrupts();
+    }
+}
+
+
+void run_tracking(void)
+{
     gps_t gps;
     gps_data_t gps_data;
     gps_initialize(&gps);

void loop(void)
{ 
}

#include "waypoint_store.h"
#include "gps.h"

#define REQ 9
#define RDY 7
#define RST 10

#define WAYPOINT_DISTANCE_THRESHOLD 50 /* meters */
#define BUSY_LED 17

#define GREEN_BUTTON_INTERRUPT_NUM 1 /* corresponds to pin 2 (D2) */
#define BLUE_BUTTON_INTERRUPT_NUM 0 /* corresponds to pin 3 (D3) */

/* Global flag indicating a button press has not yet been handled.
   Will be set to 1 on button press, and should be read and cleared
   atomically (disable/renable interrupts). */
uint8_t g_green_button_pressed = 0;
uint8_t g_blue_button_pressed = 0;

void print_tracking_display(struct tracking_data_t *data)
{
