   return sqrt(pow(from.lat - to.lat, 2) + pow(from.lng - to.lng, 2));
 }
 
+// Stores a value for the sliding window average
+void put_avg(double val) {
+  avg_buf[avg_buf_pos] = val;
+  avg_buf_pos = (avg_buf_pos + 1) % avg_count;
+}
+
+// Gets the average of all stored values
+double get_avg() {
+  double avg = 0;
+  for (int i = 0; i < avg_count; i++) {
+    avg += avg_buf[i] / avg_count;
+  }
+  return avg;
+}
+
+// Called when the GPS has a new location
 void on_new_gps(double lat, double lng) {
   current_loc.lat = lat;
   current_loc.lng = lng;

// ETA in milliseconds. If negative, we're traveling away from current_dest
double eta_time = 0;

Destination dests[] = {
  {"Test", {0.0, 10.0}},
  {"Home", {45.022884, -93.244983}},
  {"Work", {44.989136, -93.250454}},
};

// Change current_dest to change the distance and eta
Location current_dest = dests[0].loc;

#include <math.h>

// A physical location
typedef struct Location {
  double lat;
  double lng;
} Location;

// A name attached to a physical location
typedef struct Destination {
  char name[16];
  Location loc;
} Destination;

// Waypoints to be used for navigation
Destination dests[] = {
  {"Test", {0.0, 10.0}},
  {"Home", {45.022884, -93.244983}},
  {"Work", {44.989136, -93.250454}},
};

// Updated by on_new_gps
// Location
