 #error("Height incorrect, please fix Adafruit_SSD1306.h!");
 #endif
 
-
-
-// Button Variables
-
 int bpins[] = {8, 9, 10};// pin 2 isn't exposed on the trinket, just a placeholder.
 int buttons[] = {0, 0, 0};
-int lastButtonStates[] = {0, 0, 0};
-long lastDebounceTimes[] = {0, 0, 0};
-long debounceDelay = 50;
-
 long last = millis();
-int lastReadings[] = {0,0,0};
 
 void setup() {
   

  else if (mnu == 1) {
    display.clearDisplay();
    pong();
  }  
}

void menu() {
  boolean b = true;
  display.setTextSize(1);
  int m = 0;
  while (b) {
    display.clearDisplay();
    display.setCursor(0, 0);
    display.println("Time\nPong");
    if (pressedOnce(0))
      m = abs(m-1) % 2;
    else if (pressedOnce(2))
      m = abs(m+1) % 2;
    else if (pressedOnce(1))
      Serial.println(m);
    
    
    if (m == 0) {
      display.setCursor(30, 0);
    }
    else {
      display.setCursor(30, 10);
    }
    display.println("*");
    display.display();
  }
}


void updateButtonStates() {
  for (int i = 0; i < 3; ++i) {
    int reading = digitalRead(bpins[i]);
    if (reading != lastButtonStates[i]) {
      lastDebounceTimes[i] = millis();
    }
    if ((millis() - lastDebounceTimes[i]) > debounceDelay) {
      if (reading == LOW) {
       buttons[i] = 1;
      } else {
       buttons[i] = 0;
      } 
    }
    lastButtonStates[i] = reading;
  }
}

boolean pressedOnce(int b) {
  updateButtonStates();
  boolean r;
  if (buttons[b] != lastReadings[b] && buttons[b])
    r = true;
  else
    r = false;
  lastReadings[b] = buttons[b];
  return r;
}

/*********************************************************************
 * 
 * All functions defined here written by and (c) Davis Haupt under the MIT License.
 * 
 *
 * Graphics and Display Library Written by Limor Fried/Ladyada  for Adafruit Industries.  
 * BSD license, check license.txt for more information
 * All text above, and the splash screen must be included in any redistribution
 *********************************************************************/
