 byte titleScreen() {
   byte selectedItem = TITLE_PLAY_GAME;
   unsigned short totalDelay = 0;
+  long lastDebounceTime = 0;  // the last time the button was pressed
+  long debounceDelay = 100; 
   
   arduboy.clear();
   printText("TITLE", 25, 20, 2);

void settingsScreen() {
  // TODO, this is a placeholder
  arduboy.clear();
  printText("SETTINGS", 20, 25, 2);
  arduboy.display();
  delay(5000);
}

  arduboy.display();

  while(totalDelay < ATTRACT_MODE_TIMEOUT) {

    // TODO This needs a debounced button press routine... arduboy.pressed isn't doing it
    if (arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON)) {
      break;
    }
    
    if (arduboy.pressed(LEFT_BUTTON)) {
      if ( (millis() - lastDebounceTime) > debounceDelay) {
        selectedItem = titleMenuLeftButton(selectedItem);
        lastDebounceTime = millis(); //set the current time
      }
    }
  
    if (arduboy.pressed(RIGHT_BUTTON)) {
      if ( (millis() - lastDebounceTime) > debounceDelay) {
        selectedItem = titleMenuRightButton(selectedItem);
        lastDebounceTime = millis(); //set the current time
      }
    }

    delay(15);
    totalDelay += 15;
  }
  return(totalDelay >= ATTRACT_MODE_TIMEOUT ? TITLE_TIMEOUT : selectedItem);
}

byte titleMenuLeftButton(byte selectedItem) {
  /**
   * Handle clicks on the left button
   * to navigate through main menu
   * items.
   */
  switch (selectedItem) {
        
    case TITLE_SETTINGS:
         arduboy.drawRect(76, 47, 51, 13, 0);
         arduboy.drawRect(30, 47, 45, 13, 1);
         arduboy.display();
         return TITLE_CREDITS;
         break; 

    case TITLE_CREDITS:
         arduboy.drawRect(30, 47, 45, 13, 0);
         arduboy.drawRect(2, 47, 26, 13, 1);
         arduboy.display();
         return  TITLE_PLAY_GAME;
         break;

    default: break;
  }  
}


byte titleMenuRightButton(byte selectedItem){
  /**
   * Handle clicks on the right button
   * to navigate through main menu 
   * items.
   */
  switch (selectedItem) {
        
    case TITLE_PLAY_GAME:
         arduboy.drawRect(2, 47, 26, 13, 0);
         arduboy.drawRect(30, 47, 45, 13, 1);
         arduboy.display();
         return TITLE_CREDITS;
         break; 

    case TITLE_CREDITS:
         arduboy.drawRect(30, 47, 45, 13, 0);
         arduboy.drawRect(76, 47, 51, 13, 1);
         arduboy.display(); 
         return TITLE_SETTINGS; 
         break;

    default: break;      
  }
}

void highScoreScreen() {
