From 3949e64c7707b53081a60daaf8e1118ebee41ea7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 7 Apr 2017 10:32:31 -0400 Subject: add compressor inhibitor --- src/org/usfirst/frc/team4272/robot2017/Autonomous.java | 1 + src/org/usfirst/frc/team4272/robot2017/Control.java | 3 ++- src/org/usfirst/frc/team4272/robot2017/HwRobot.java | 7 +++++++ src/org/usfirst/frc/team4272/robot2017/Teleop.java | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/org/usfirst/frc/team4272/robot2017/Autonomous.java b/src/org/usfirst/frc/team4272/robot2017/Autonomous.java index 28ec580..affe49d 100644 --- a/src/org/usfirst/frc/team4272/robot2017/Autonomous.java +++ b/src/org/usfirst/frc/team4272/robot2017/Autonomous.java @@ -69,6 +69,7 @@ public class Autonomous { Command init = c->{ c.lDrive = c.rDrive = 0; c.highGear = c.gedOut = false; + c.compressorEnabled = true; return true; }; diff --git a/src/org/usfirst/frc/team4272/robot2017/Control.java b/src/org/usfirst/frc/team4272/robot2017/Control.java index c8561c0..b32eac7 100644 --- a/src/org/usfirst/frc/team4272/robot2017/Control.java +++ b/src/org/usfirst/frc/team4272/robot2017/Control.java @@ -6,6 +6,7 @@ public class Control { rDrive = 0, climber = 0; boolean highGear = false, - gedOut = false; + gedOut = false, + compressorEnabled = true; public Control() {} } diff --git a/src/org/usfirst/frc/team4272/robot2017/HwRobot.java b/src/org/usfirst/frc/team4272/robot2017/HwRobot.java index 533cf9d..23e5c34 100644 --- a/src/org/usfirst/frc/team4272/robot2017/HwRobot.java +++ b/src/org/usfirst/frc/team4272/robot2017/HwRobot.java @@ -29,6 +29,7 @@ */ package org.usfirst.frc.team4272.robot2017; +import edu.wpi.first.wpilibj.Compressor; import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.Encoder; @@ -70,6 +71,8 @@ public class HwRobot { private final DoubleSolenoid shifter = new DoubleSolenoid(/*PCM*/4, /*PCM*/5), ged = new DoubleSolenoid(/*PCM*/6, /*PCM*/7); + private final Compressor + compressor = new Compressor(); // Sensors/info should be public /////////////////////////////////////// public final Encoder lDriveE = new Encoder(/*DIO*/0,/*DIO*/1, /*reverse*/false); public final Encoder rDriveE = new Encoder(/*DIO*/2,/*DIO*/3, /*reverse*/true); @@ -116,6 +119,10 @@ public class HwRobot { minBatt = batt; SmartDashboard.putNumber("minBatt", minBatt); + if (c.compressorEnabled != compressor.getClosedLoopControl()) + compressor.setClosedLoopControl(c.compressorEnabled); + + SmartDashboard.putBoolean("compressorOn", compressor.enabled()); SmartDashboard.putBoolean("highGear", c.highGear); SmartDashboard.putBoolean("gedOut", c.gedOut); } diff --git a/src/org/usfirst/frc/team4272/robot2017/Teleop.java b/src/org/usfirst/frc/team4272/robot2017/Teleop.java index 4dc3627..b55a42b 100644 --- a/src/org/usfirst/frc/team4272/robot2017/Teleop.java +++ b/src/org/usfirst/frc/team4272/robot2017/Teleop.java @@ -96,6 +96,9 @@ public class Teleop { /* GED */ control.gedOut = oi.xbox.getTriggerAxis(Hand.kRight) > 0.5; + /* compressor */ + control.compressorEnabled = !oi.xbox.getAButton(); + return control; } } -- cgit v1.2.3