Fixed the front bumper switches, and cleaned up IOIOTruckManager.java
IOIOTruckManager.java changed initialization of mLeftFrontBumper and mRightBumper to pull down mode onConnected() removed mStatLedValue and mapped it's setter/getter methods to the super's getter setter methods
This commit is contained in:
@@ -35,7 +35,6 @@ public class IOIOTruckManager extends IOIOManager {
|
|||||||
private int mDriveValue;
|
private int mDriveValue;
|
||||||
private int mSteerValue;
|
private int mSteerValue;
|
||||||
private int mShifterValue;
|
private int mShifterValue;
|
||||||
private boolean mStatLedValue;
|
|
||||||
private TB6612FNGMotorDriver mLeftMotor;
|
private TB6612FNGMotorDriver mLeftMotor;
|
||||||
private TB6612FNGMotorDriver mRightMotor;
|
private TB6612FNGMotorDriver mRightMotor;
|
||||||
private PwmOutput mShifter;
|
private PwmOutput mShifter;
|
||||||
@@ -90,13 +89,6 @@ public class IOIOTruckManager extends IOIOManager {
|
|||||||
public synchronized int getSteerValue() {
|
public synchronized int getSteerValue() {
|
||||||
return mSteerValue;
|
return mSteerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the mStatLedValue
|
|
||||||
*/
|
|
||||||
public synchronized boolean isStatLedValue() {
|
|
||||||
return mStatLedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here we register and initialize each port
|
* Here we register and initialize each port
|
||||||
@@ -118,8 +110,8 @@ public class IOIOTruckManager extends IOIOManager {
|
|||||||
/*
|
/*
|
||||||
* bumper switches in the front
|
* bumper switches in the front
|
||||||
*/
|
*/
|
||||||
mLeftFrontBumber = ioio.openDigitalInput(IOIOTruckValues.LEFT_FRONT_BUMPER_PORT);
|
mLeftFrontBumber = ioio.openDigitalInput(IOIOTruckValues.LEFT_FRONT_BUMPER_PORT, DigitalInput.Spec.Mode.PULL_DOWN);
|
||||||
mRightFrontBumber = ioio.openDigitalInput(IOIOTruckValues.RIGHT_FRONT_BUMBER_PORT);
|
mRightFrontBumber = ioio.openDigitalInput(IOIOTruckValues.RIGHT_FRONT_BUMBER_PORT, DigitalInput.Spec.Mode.PULL_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,31 +131,29 @@ public class IOIOTruckManager extends IOIOManager {
|
|||||||
@Override
|
@Override
|
||||||
public void loop() throws ConnectionLostException, InterruptedException {
|
public void loop() throws ConnectionLostException, InterruptedException {
|
||||||
|
|
||||||
this.setStatLedEnabled(mStatLedValue);
|
this.setStatLedEnabled(isStatLedEnabled());
|
||||||
|
|
||||||
mShifter.setPulseWidth(mShifterValue);
|
mShifter.setPulseWidth(mShifterValue);
|
||||||
|
|
||||||
mMotorDriverStandBy.write(mStatLedValue);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we need to check our sensors before we can make a move.
|
* we need to check our sensors before we can make a move.
|
||||||
*/
|
*/
|
||||||
if(mLeftFrontBumber.read()){
|
if(mLeftFrontBumber.read()){
|
||||||
//TODO backup, spin right, drive forward
|
//TODO backup, spin right, drive forward
|
||||||
mLeftMotor.setSpeed(0);
|
setStatLedEnabled(false);
|
||||||
mRightMotor.setSpeed(0);
|
|
||||||
} else if(mRightFrontBumber.read()){
|
} else if(mRightFrontBumber.read()){
|
||||||
//TODO backup, spin left, drive forward
|
//TODO backup, spin left, drive forward
|
||||||
mLeftMotor.setSpeed(0);
|
setStatLedEnabled(false);
|
||||||
mRightMotor.setSpeed(0);
|
}
|
||||||
} else
|
|
||||||
|
mMotorDriverStandBy.write(isStatLedEnabled());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the autonomous routine is running
|
* if the autonomous routine is running
|
||||||
* then drive the truck
|
* then drive the truck
|
||||||
* else stop the truck
|
* else stop the truck
|
||||||
*/
|
*/
|
||||||
if(mStatLedValue){
|
if(isStatLedEnabled()){
|
||||||
arcadeDrive();
|
arcadeDrive();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -175,29 +165,22 @@ public class IOIOTruckManager extends IOIOManager {
|
|||||||
/**
|
/**
|
||||||
* @param mDriveValue the mDriveValue to set
|
* @param mDriveValue the mDriveValue to set
|
||||||
*/
|
*/
|
||||||
public synchronized void setDriveValue(int mDriveValue) {
|
public synchronized void setDriveValue(int driveValue) {
|
||||||
this.mDriveValue = mDriveValue;
|
mDriveValue = driveValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mShifterValue the mShifterValue to set
|
* @param mShifterValue the mShifterValue to set
|
||||||
*/
|
*/
|
||||||
public synchronized void setShifterValue(int mShifterValue) {
|
public synchronized void setShifterValue(int shifterValue) {
|
||||||
this.mShifterValue = mShifterValue;
|
mShifterValue = shifterValue;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mStatLedValue the mStatLedValue to set
|
|
||||||
*/
|
|
||||||
public synchronized void setStatLedValue(boolean mStatLedValue) {
|
|
||||||
this.mStatLedValue = mStatLedValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mSteerValue the mSteerValue to set
|
* @param mSteerValue the mSteerValue to set
|
||||||
*/
|
*/
|
||||||
public synchronized void setSteerValue(int mSteerValue) {
|
public synchronized void setSteerValue(int steerValue) {
|
||||||
this.mSteerValue = mSteerValue;
|
mSteerValue = steerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void updateGoButton(final boolean isRun) {
|
private void updateGoButton(final boolean isRun) {
|
||||||
mIOIOManager.setStatLedValue(!isRun);
|
mIOIOManager.setStatLedEnabled(!isRun);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public class TestActivity extends Activity implements JoystickMovedListener, OnS
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
mIOIOManager.setStatLedValue(isChecked);
|
mIOIOManager.setStatLedEnabled(isChecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user