Example #1
0
  public void sendDataString(int addressH, int addressL, String data) {
    if (DEBUG) System.out.println("executing sendString");
    String cmdString = data;
    int[] myCommand = new int[2];
    myCommand[0] = TRANSMIT_REQUEST; // frame identifier
    myCommand[1] = 0x01; // frame type

    // break up the address and append the bytes of it:
    byte thisByte = 0;
    // get each byte from the 4-byte int:
    for (int b = 3; b > -1; b--) {
      thisByte = (byte) (addressH >> (8 * b));
      myCommand = parent.append(myCommand, thisByte);
    }
    // same for addressL:
    for (int b = 3; b > -1; b--) {
      thisByte = (byte) (addressL >> (8 * b));
      myCommand = parent.append(myCommand, thisByte);
    }
    // 16-bit address:
    myCommand = parent.append(myCommand, 0xFF);
    myCommand = parent.append(myCommand, 0xFE);

    myCommand = parent.append(myCommand, 0x00); // broadcast radius
    myCommand = parent.append(myCommand, 0x00); // options
    // append the cmdString to the array
    for (int i = 0; i < cmdString.length(); i++) {
      myCommand = parent.append(myCommand, (int) (cmdString.charAt(i)));
    }
    sendPacket(myCommand);
  }
Example #2
0
  public void sendRemoteCommand(
      int addressH, int addressL, int address16, String remoteCommand, int option) {
    // not correct, I think the frame identifier is wrong
    String cmdString;
    if (option > 0) {
      cmdString = remoteCommand + (char) (option);
    } else {
      cmdString = remoteCommand;
    }
    int[] myCommand = new int[2];
    myCommand[0] = REMOTE_ATCOMMAND_REQUEST; // frame identifier
    myCommand[1] = 0x01; // frame ID
    // break up the remote address to send to:
    byte thisByte = 0;
    // get each byte from the 4-byte int:
    for (int b = 3; b > -1; b--) {
      thisByte = (byte) (addressH >> (8 * b));
      myCommand = parent.append(myCommand, thisByte);
    }
    // same with addressL:
    for (int b = 3; b > -1; b--) {
      thisByte = (byte) (addressL >> (8 * b));
      myCommand = parent.append(myCommand, thisByte);
    }

    // 16 bit address:
    for (int b = 1; b > -1; b--) {
      thisByte = (byte) (address16 >> (8 * b));
      myCommand = parent.append(myCommand, thisByte);
    }

    myCommand = parent.append(myCommand, 0x02); // apply changes on remote

    // append the cmdString to the array
    for (int i = 0; i < cmdString.length(); i++) {
      myCommand = parent.append(myCommand, (int) (cmdString.charAt(i)));
    }

    sendPacket(myCommand);
  }
Example #3
0
  // generic structure for AT commands
  public void sendATCommand(String thisCommand, int apiID, int frameID) {

    int[] myCommand = new int[2]; // array that you'll pass to sendATCommand()
    myCommand[0] = apiID; // frame identifier
    myCommand[1] = frameID; // frame type

    // parent.append the cmdString to the array
    for (int i = 0; i < thisCommand.length(); i++) {
      myCommand = parent.append(myCommand, (int) (thisCommand.charAt(i)));
    }
    // send it out:
    sendPacket(myCommand);
  }
 @Override
 public void generateBullet(
     float targetX, float targetY, float startX, float startY, float angle) {
   SuperAlienRifleBullet bullet =
       new SuperAlienRifleBullet(
           p,
           new PVector(startX, startY),
           "sdf.sdf",
           angle + p.random(-jitter, jitter),
           0xFFFFFFFF,
           caliber,
           60,
           this.bulletSpeed,
           this,
           this.weight / rackSize,
           new PVector(startX, startY));
   bullet.sprite = new Animation(this.bulletAnimation);
   this.bullets = (Bullet[]) PApplet.append(this.bullets, bullet);
   currentRackSize--;
   lastShotTime = p.millis();
 }