make naive method for updating currentLevel/ check values of limit switches Cindy/Limit-Switches
authorKevin Zhang <kevin.zhang.13499@gmail.com>
Tue, 17 Nov 2015 05:23:29 +0000 (21:23 -0800)
committerKevin Zhang <kevin.zhang.13499@gmail.com>
Tue, 17 Nov 2015 05:23:29 +0000 (21:23 -0800)
src/org/usfirst/frc3501/RiceCatRobot/subsystems/Arm.java

index 3a69eea7fd4cb6ab3e9fa2d33fd4ffb909f60faf..e584153a0e30506f34d0ee2f469d611d9f4f8808 100644 (file)
@@ -10,9 +10,10 @@ import edu.wpi.first.wpilibj.command.Subsystem;
 
 public class Arm extends Subsystem {
   private CANJaguar left, right;
-  ArrayList<DigitalInput> limitSwitches;
+  private ArrayList<DigitalInput> 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;