From: Kevin Zhang Date: Tue, 17 Nov 2015 05:23:29 +0000 (-0800) Subject: make naive method for updating currentLevel/ check values of limit switches X-Git-Url: http://challenge-bot.com/repos/?a=commitdiff_plain;h=refs%2Fheads%2FCindy%2FLimit-Switches;p=3501%2F2015-FRC-Spark make naive method for updating currentLevel/ check values of limit switches --- diff --git a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java index 3a69eea..e584153 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java @@ -10,9 +10,10 @@ import edu.wpi.first.wpilibj.command.Subsystem; public class Arm extends Subsystem { private CANJaguar left, right; - ArrayList limitSwitches; + private ArrayList limitSwitches; //channel index numbers correspond to limit switches - int[] channels; + private int[] channels; + private int currentLevel; private final int NUM_OF_SWITCHES = 4; public Arm() { @@ -68,6 +69,16 @@ public class Arm extends Subsystem { right.set(0); } + //should run in robot.java teleop periodic (autonomous periodic too maybe?) + public void updateLimitSwitches(){ + for(int i = 0; i < NUM_OF_SWITCHES; i ++){ + DigitalInput d = limitSwitches.get(i); + if(d.get()){ + currentLevel = i; + } + } + } + public int getLevel(){ //return last past switch return 0;