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:
2012-01-28 18:11:49 -05:00
parent 92419a398a
commit 2385361813
3 changed files with 18 additions and 35 deletions

View File

@@ -35,7 +35,6 @@ public class IOIOTruckManager extends IOIOManager {
private int mDriveValue;
private int mSteerValue;
private int mShifterValue;
private boolean mStatLedValue;
private TB6612FNGMotorDriver mLeftMotor;
private TB6612FNGMotorDriver mRightMotor;
private PwmOutput mShifter;
@@ -90,13 +89,6 @@ public class IOIOTruckManager extends IOIOManager {
public synchronized int getSteerValue() {
return mSteerValue;
}
/**
* @return the mStatLedValue
*/
public synchronized boolean isStatLedValue() {
return mStatLedValue;
}
/**
* Here we register and initialize each port
@@ -118,8 +110,8 @@ public class IOIOTruckManager extends IOIOManager {
/*
* bumper switches in the front
*/
mLeftFrontBumber = ioio.openDigitalInput(IOIOTruckValues.LEFT_FRONT_BUMPER_PORT);
mRightFrontBumber = ioio.openDigitalInput(IOIOTruckValues.RIGHT_FRONT_BUMBER_PORT);
mLeftFrontBumber = ioio.openDigitalInput(IOIOTruckValues.LEFT_FRONT_BUMPER_PORT, DigitalInput.Spec.Mode.PULL_DOWN);
mRightFrontBumber = ioio.openDigitalInput(IOIOTruckValues.RIGHT_FRONT_BUMBER_PORT, DigitalInput.Spec.Mode.PULL_DOWN);
}
/**
@@ -139,31 +131,29 @@ public class IOIOTruckManager extends IOIOManager {
@Override
public void loop() throws ConnectionLostException, InterruptedException {
this.setStatLedEnabled(mStatLedValue);
this.setStatLedEnabled(isStatLedEnabled());
mShifter.setPulseWidth(mShifterValue);
mMotorDriverStandBy.write(mStatLedValue);
/*
* we need to check our sensors before we can make a move.
*/
if(mLeftFrontBumber.read()){
//TODO backup, spin right, drive forward
mLeftMotor.setSpeed(0);
mRightMotor.setSpeed(0);
setStatLedEnabled(false);
} else if(mRightFrontBumber.read()){
//TODO backup, spin left, drive forward
mLeftMotor.setSpeed(0);
mRightMotor.setSpeed(0);
} else
setStatLedEnabled(false);
}
mMotorDriverStandBy.write(isStatLedEnabled());
/*
* if the autonomous routine is running
* then drive the truck
* else stop the truck
*/
if(mStatLedValue){
if(isStatLedEnabled()){
arcadeDrive();
}
else{
@@ -175,29 +165,22 @@ public class IOIOTruckManager extends IOIOManager {
/**
* @param mDriveValue the mDriveValue to set
*/
public synchronized void setDriveValue(int mDriveValue) {
this.mDriveValue = mDriveValue;
public synchronized void setDriveValue(int driveValue) {
mDriveValue = driveValue;
}
/**
* @param mShifterValue the mShifterValue to set
*/
public synchronized void setShifterValue(int mShifterValue) {
this.mShifterValue = mShifterValue;
}
/**
* @param mStatLedValue the mStatLedValue to set
*/
public synchronized void setStatLedValue(boolean mStatLedValue) {
this.mStatLedValue = mStatLedValue;
public synchronized void setShifterValue(int shifterValue) {
mShifterValue = shifterValue;
}
/**
* @param mSteerValue the mSteerValue to set
*/
public synchronized void setSteerValue(int mSteerValue) {
this.mSteerValue = mSteerValue;
public synchronized void setSteerValue(int steerValue) {
mSteerValue = steerValue;
}
/**

View File

@@ -177,7 +177,7 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
* @author ricky barrette
*/
private void updateGoButton(final boolean isRun) {
mIOIOManager.setStatLedValue(!isRun);
mIOIOManager.setStatLedEnabled(!isRun);
runOnUiThread(new Runnable() {
@Override
public void run(){

View File

@@ -158,7 +158,7 @@ public class TestActivity extends Activity implements JoystickMovedListener, OnS
*/
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mIOIOManager.setStatLedValue(isChecked);
mIOIOManager.setStatLedEnabled(isChecked);
}
/**