Example #1
0
 public void moveCursor(char dir) {
   switch (dir) {
       // left
     case 'a':
       if (cursorCol != 0) {
         ard.sendString("a");
         cursorCol--;
       }
       break;
       // up
     case 'w':
       if (cursorRow != (HEIGHT - 1)) {
         ard.sendString("w");
         cursorRow++;
       }
       break;
       // right
     case 'd':
       if (cursorCol != (WIDTH - 1)) {
         ard.sendString("d");
         cursorCol++;
       }
       break;
       // down
     case 's':
       if (cursorRow != 0) {
         ard.sendString("s");
         cursorRow--;
       }
       break;
     default:
   }
 }
Example #2
0
  private void sendMessage(int r, int c, int l) {
    char r1 = (char) ('0' + r / 10);
    char r2 = (char) ('0' + r % 10);
    char c1 = (char) ('0' + c / 10);
    char c2 = (char) ('0' + c % 10);
    char color = (char) ('0' + l);

    if (ard != null) {
      ard.sendString("$" + r1 + r2 + c1 + c2 + color + "!");
      System.out.println("$" + r1 + r2 + c1 + c2 + color + "!");
      try {
        Thread.sleep(200);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      System.out.print("$");
      System.out.print(r1);
      System.out.print(r2);
      System.out.print(c1);
      System.out.print(c2);
      System.out.print(color);
      System.out.println("!");
    }

    return;
  }
Example #3
0
 public LightsOut(XboxController xc, ArduinoDriver arduino) {
   ard = arduino;
   ard.sendString("W");
   x = xc;
 }