Beispiel #1
0
void Menu::checkMenu(){

  int xValue = Esplora.readJoystickX();        
  int yValue = Esplora.readJoystickY();        
  int button = Esplora.readJoystickSwitch();   
  
  int x = map(xValue, -512, 512, 10, -10); 
  int y = map(yValue, -512, 512, -10, 10);
  
  if(x > 4){
    if(_currentButton + 1 > (_numberOfButtons - 1))
      setCurrentButton(0);
    else
      setCurrentButton(_currentButton + 1);
    delay(100);
  }
  else if(x < -4){
    if(_currentButton -1 < 0)
      setCurrentButton(_numberOfButtons - 1);
    else
      setCurrentButton(_currentButton - 1);
    delay(100);
  }
  
  else if(y > 4){
    if(_currentButton + 2 > (_numberOfButtons - 1))
      setCurrentButton(0);
    else
      setCurrentButton(_currentButton + EsploraTFT.width() / _buttons[0].getSizeX());
    delay(100);
  }
  else if(y < -4){
    if(_currentButton -2 < 0)
      setCurrentButton(_numberOfButtons - 1);
    else
      setCurrentButton(_currentButton - EsploraTFT.width() / _buttons[0].getSizeX());
    delay(100);
  }
  if(Esplora.readButton(SWITCH_DOWN) == 0)
    menuAction(SWITCH_DOWN, _currentButton);
  if(Esplora.readButton(SWITCH_UP) == 0)
    menuAction(SWITCH_UP, _currentButton); 
  if(Esplora.readButton(SWITCH_RIGHT) == 0)
    menuAction(SWITCH_RIGHT, _currentButton);
  if(Esplora.readButton(SWITCH_LEFT) == 0)
    menuAction(SWITCH_LEFT, _currentButton);
}
Beispiel #2
0
// Set button with specified index as checked button
bool TMenuButtonGroup::setCurrentButton(int buttonIndex)
{
	// Loop over buttons in group, unchecking all others except the one provided (which we will check)
	TMenuButton* groupButton;
	for (RefListItem<TMenuButton,int>* ri = buttons_.first(); ri != NULL; ri = ri->next)
	{
		groupButton = ri->item;
		if (groupButton->index() == buttonIndex)
		{
			setCurrentButton(groupButton);
			return true;
		}
	}
	return false;
}
Beispiel #3
0
void Menu::drawMenu(){
  for(int i = 0; i < _numberOfButtons; i++){
	_buttons[i].draw();
  }
  setCurrentButton(_currentButton);
}