    return btnNONE;  // when all others fail, return this...
   }
 
-  void buttonread(){
-  
-  }

    } 
  }

  void gpsdump(TinyGPS &gps){
    long lat, lon;
    unsigned long age, date, time, chars;
    unsigned short sentences, failed;
  
    feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors
  
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("Lat/Long(float): "); printFloat(flat, 7); Serial.print(", "); printFloat(flon, 7);   // print our current posistion
    Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
    feedgps();
  
    gps.stats(&chars, &sentences, &failed);
    Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
    if(buttonreaddone!=5){
      buttonread();
    }
    if(buttonreaddone==5){
      distance();
    }
  }
  
  bool feedgps(){
    while (mySerial.available())
    {
      if (gps.encode(mySerial.read()))
        return true;
    }
    return false;
  }
  
//------------------------------below is the part of the code where everything is calculated

    pinMode(led, OUTPUT);
    //Setup input buttons
    pinMode(buttons, INPUT);
    //Show initial menu
    displayMenu();
  }

  void loop(){ 
    //Read from gps
    if (feedgps()){
      //Dump gps if new data
      gpsdump(gps);
    }
    
    updateDisplay();
  }

  void updateDisplay(){
    //Check if a button was pressed
    int btnPressed = read_LCD_buttons();
    
    boolean isPress = true;
    switch(btnPressed){
      case btnUP:
        //Move menu up
        if(mMenuPosition > 0){
          mMenuPosition--;
        }
      break; 
      case btnDOWN:
        //Move menu down
        if(mMenuPosition < MENU_LENGTH - 1){
          mMenuPosition++;
        }
      break;
      case btnSELECT:
        executeCommand(mMenuPosition);
      break;
      default:
        //No buttons pressed
        isPress = false;
      break;  
    }
    
    //Diplay menu if changed
    if(isPress){
      displayMenu();
    }
    //Short delay to prevent rebounce
    delay(150);
  }

  void displayMenu(){
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(">");
      lcd.print(mMenu[mMenuPosition]);
      if(mMenuPosition < MENU_LENGTH){
        lcd.setCursor(0,1);
        lcd.print(mMenu[mMenuPosition + 1]);
      }
  }

  void executeCommand(int cmd){
    switch(cmd){
       case 0:
       //Display current position
       lcd.clear();
       lcd.setCursor(0,0);
       lcd.print("LAT: ");
       lcd.print(flat);
       lcd.setCursor(0,1);
       lcd.print("LON: ");
       lcd.print(flon);
       delay(500);
       break; 
    }
    
  }
  
  /**
  * Prints a floating point number to the Serial output
  */
