 #include <NMEAGPS.h>
 #include <NeoSWSerial.h>
 
-NMEAGPS gps;  // The parsing object
-gps_fix fix;  // GPS fields are stored here as they are parsed
-uint8_t gpsUpdates = 0; // how many updates since power_save
+static NMEAGPS gps;  // The parsing object
+static gps_fix fix;  // GPS fields are stored here as they are parsed
 
-NeoSWSerial gpsS(RXPIN, TXPIN);
+static NeoSWSerial gpsS(RXPIN, TXPIN);
 
 //Internal Temp sensor
 #include <Wire.h>

    
    gpsS.begin(9600);

    next_aprs = millis() + 5000l;
}

void loop() {
  if (gps.available(gpsS)) {
    fix = gps.read();
    gpsUpdates++;
  }

  if (millis() >= next_aprs && gpsUpdates >= 2) {
    gpsUpdates = 0;

    fix = gps.read();
    char latitude[9];
    snprintf(latitude, 9, "%02d%02d.%02u%c", fix.latitudeDMS.degrees, fix.latitudeDMS.minutes, truncate(fix.latitudeDMS.seconds_whole, 2), fix.latitudeDMS.NS() );

    char longitude[10];
    snprintf(longitude, 10, "%03d%02d.%02u%c", fix.longitudeDMS.degrees, fix.longitudeDMS.minutes, truncate(fix.longitudeDMS.seconds_whole, 2), fix.longitudeDMS.EW() );

    char datetime[7];
    snprintf(datetime, 7, "%02d%02d%02d", fix.dateTime.hours, fix.dateTime.minutes, fix.dateTime.seconds);
  
    //Check pressure the flight day in http://weather.noaa.gov/weather/current/LEMD.html
    //We take the value between parenthesis. If pressure is 1013 write in readAltitude
    //this value multiplied by 100
    APRSPacket packet(datetime,
                      bmp.readAltitude(101900),
                      fix.speed(),
                      fix.heading(),
                      bmp.readTemperature(),
                      bmp.readPressure());

    packet.setLatitude(latitude);
    packet.setLongitude(longitude);
    packet.setLatitudeF(fix.latitude());
    packet.setLongitudeF(fix.longitude());
  
    packet.aprs_send();
  
    while (afsk_flush()) {
      power_save();
    }
  
    next_aprs = millis() + 5000l;
  }
}



Adafruit_BMP085 bmp;

static uint8_t next_aprs = 0;

void setup() {
    pinMode(LED_PIN, OUTPUT);
