Esempio n. 1
0
//--------------------------------------------------------------------
// getKeyboardOrder
//--------------------------------------------------------------------
bool getKeyboardOrder(Order &order)
{
    order.reset();
    char rep;
    read(0,&rep,1);
  //  printf("read=%d\n", rep);
    switch (rep) {
        // motor
    case 27 : 
        read(0,&rep,1); 
        read(0,&rep,1);
        switch (rep) {
	case 'A' : handleForward(order); break;
	case 'B' : handleBackward(order); break;
	case 'D' : handleLeft(order); break;
	case 'C' : handleRight(order); break;
        }
        break;
    case '8' : handleForward(order); break;
    case '2' : handleBackward(order); break;
    case '4' : handleLeft(order); break;
    case '6' : handleRight(order); break;
        // emergency stop
    case '5' :
    case ' ' : 
        setEmergencyStopOrder(order);
        break; 
    case 'r' :
    case 'R' :    
	order.resetRobotPos=true;
        order.motorReset=1;
        order.speedLeft=0;
        order.speedRight=0;
        break;  
    case 'h' :
    case 'H' : 
        showUsage();
        break;   
    case 'q': 
    case 'Q': 
    case '-':
        quitApplication = true;
        break;
    default:
        break;
    }
    checkMotorOrder(order);
    return true;
}
Esempio n. 2
0
void pacmanRound() {
  switch (pacman.dir) {
    case UP:
        if (map[pacman.mapY + 1][pacman.mapX] != 0)
          clearPerson(map, pacman.mapX, pacman.mapY + 1);
        clearPerson(map, pacman.mapX, pacman.mapY);
        handleUp();
        break;
    case DOWN:
        if (map[pacman.mapY - 1][pacman.mapX] != 0)
          clearPerson(map, pacman.mapX, pacman.mapY - 1);
        clearPerson(map, pacman.mapX, pacman.mapY);
        handleDown();
        break;
    case LEFT:
        if (map[pacman.mapY][pacman.mapX + 1] != 0)
          clearPerson(map, pacman.mapX + 1, pacman.mapY);
        clearPerson(map, pacman.mapX, pacman.mapY);
        handleLeft();
        break;
    case RIGHT:
        if (map[pacman.mapY][pacman.mapX - 1] != 0)
          clearPerson(map, pacman.mapX - 1, pacman.mapY);
        clearPerson(map, pacman.mapX, pacman.mapY);
        handleRight();
        break;
  }
  changeDir();
  drawPacman((int)pacman.screenX, (int)pacman.screenY, pacman.dir);
}
Esempio n. 3
0
  ReflowParameters ControlPage::run() {

    uint32_t start;

    // draw the full GUI

    redrawAll();

    // go into a keypress/timeout event loop

    start=MillisecondTimer::millis();

    for(;;) {

      // each second, sample the temperature and display it

      if(MillisecondTimer::hasTimedOut(start,1000)) {
        drawTemperature();
        start=MillisecondTimer::millis();
      }

      if(_buttonPressed) {

        // interrupt handler has indicated that a button is down

        switch(_buttonId) {

          case ButtonIdentifier::LEFT:
            handleLeft();
            break;

          case ButtonIdentifier::RIGHT:
            handleRight();
            break;

          case ButtonIdentifier::OK:
            if(handleOk()) {

              // user has clicked reflow, return the parameters we gathered on this page

              ReflowParameters params;

              params.P=_p.getValue();
              params.I=_i.getValue();
              params.D=_d.getValue();
              params.Leaded=_leadedChecked;

              return params;
            }
            break;
        }

        // ready for the next press

        _buttonPressed=false;
      }
    }
  }