                                          .current_waypoint = initial_waypoint};
 
     int started = 0;
+    lcd_clear_display();
     lcd_write_str("Pending Fix");
 
     while (1) {
+
+        noInterrupts();
+        if (g_green_button_pressed) {
+            g_green_button_pressed = 0;
+            interrupts();
+            return;
+        }
+        interrupts();
 
         if (gps_available(&gps)) {
 

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

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

void print_tracking_display(struct tracking_data_t *data)
{

    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);
