Added support for automatic actions.

This commit is contained in:
2014-06-23 16:08:37 -04:30
parent 7afab2de73
commit ea8f09d30c
3 changed files with 12 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ import java.io.Serializable;
public class MotorEvent implements Serializable{
private static final long serialVersionUID = 9989L;
public enum motor_t {NONE, MOTOR_A, MOTOR_B, MOTOR_C, MOTOR_AC, RECENTER};
public enum motor_t {NONE, MOTOR_A, MOTOR_B, MOTOR_C, MOTOR_AC, RECENTER, ROTATE_90};
private motor_t motor;
private byte power;

View File

@@ -73,11 +73,16 @@ public class NxtBTCommThread extends Thread{
msg[0] |= (event.getMotor() == motor_t.MOTOR_C) ? MotorMasks.MOTOR_C : 0;
// Set the direction bit.
if(event.getPower() > 0) msg[0] |= MotorMasks.DIRECTION;
// Set the recenter bits.
// Set the recenter bit.
msg[0] |= (event.getMotor() == motor_t.RECENTER) ? MotorMasks.RECENTER : 0;
if((msg[0] & MotorMasks.RECENTER) > 0)
Logger.log_i(TAG, CLASS_NAME + ".run(): Recenter received.");
// Set the rotate bit.
msg[0] |= (event.getMotor() == motor_t.ROTATE_90) ? MotorMasks.ROTATE_90 : 0;
if((msg[0] & MotorMasks.ROTATE_90) > 0)
Logger.log_i(TAG, CLASS_NAME + ".run(): Rotate 90 received.");
// Set the power byte.
msg[1] = (byte)Math.abs(event.getPower());

View File

@@ -18,7 +18,8 @@ package ve.ucv.ciens.ccg.nxtcam.network.protocols;
/**
* <p>Bit masks used to code/decode the control instructions sent by NxtAR-cam to
* NxtAR-bot.</p>
* <p>Expansions 1-3 are currently unused.</p>
*
* <p>Expansions 2-3 are currently unused.</p>
*/
public abstract class MotorMasks {
public static final byte MOTOR_A = (byte)0x01;
@@ -26,7 +27,7 @@ public abstract class MotorMasks {
public static final byte MOTOR_C = (byte)0x04;
public static final byte DIRECTION = (byte)0x08;
public static final byte RECENTER = (byte)0x10;
public static final byte EXPANSION_1 = (byte)0x20;
public static final byte EXPANSION_2 = (byte)0x20;
public static final byte EXPANSION_3 = (byte)0x20;
public static final byte ROTATE_90 = (byte)0x20;
public static final byte EXPANSION_2 = (byte)0x40;
public static final byte EXPANSION_3 = (byte)0x80;
}