 void loop(void)
 { 
 }
+
+/* called on button press interrupt */
+void green_button_handler(void)
+{
+    /* only allow button press every 200 ms */
+    static uint32_t last = 0;
+    uint32_t current = millis();
+    if (current - last > 200) {
+        g_green_button_pressed = 1;
+    }
+    last = current;
+}
+
+void blue_button_handler(void)
+{
+    /* only allow button press every 200 ms */
+    static uint32_t last = 0;
+    uint32_t current = millis();
+    if (current - last > 200) {
+        g_blue_button_pressed = 1;
+    }
+    last = current;
+}
+
+void run_bluetooth(void)
+{
+    lcd_clear_display();
+    lcd_write_str("Bluetooth");
+    Adafruit_BLE_UART bluetooth = Adafruit_BLE_UART(REQ, RDY, RST);
+    bluetooth.setDeviceName("PETRICE"); /* 7 characters max! */
+    bluetooth.begin();
+    get_and_store_waypoints(bluetooth);
+}
+
+void get_and_store_waypoints(Adafruit_BLE_UART bluetooth)
+{
+    char buffer[21];
+    uint32_t count, received;
+    float latitude, longitude;
+    uint32_t *eeprom_address = 0;
+
+    /* get count */
+    bluetooth_get_token(bluetooth, buffer);
+    count = atoi(buffer);
+
+    eeprom_write_dword(eeprom_address, count);
+    eeprom_address += 1;
+
+    /* get latitudes and longitudes */
+    for (received = 0; received < count; received++) {
+
+        bluetooth_get_token(bluetooth, buffer);
+        latitude = (float)atof(buffer);
+        eeprom_write_float((float*)eeprom_address, latitude);
+
+        eeprom_address += 1;
+
+        bluetooth_get_token(bluetooth, buffer);
+        longitude = (float)atof(buffer);
+        eeprom_write_float((float*)eeprom_address, longitude);
+
+        eeprom_address += 1;
+    }
+}
+
+/* blocks until data is available from bluetooth */
+aci_evt_opcode_t bluetooth_get_token(Adafruit_BLE_UART bluetooth, char buffer[20])
+{
+    aci_evt_opcode_t status;
+    int pos = 0;
+
+    /* wait for token */
+    while (!bluetooth.available()) {
+        bluetooth.pollACI();
+        status = bluetooth.getState();
+    }
+
+    /* read token into buffer */
+    while (bluetooth.available()) {
+        buffer[pos++] = bluetooth.read();
+    }
+    buffer[pos] = '\0';
+
+    return status;
+}

#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)
{

                                         .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)) {

