diff --git a/src/org/usfirst/frc/team2059/robot/OI.java b/src/org/usfirst/frc/team2059/robot/OI.java index eb6d946..5f05cb8 100644 --- a/src/org/usfirst/frc/team2059/robot/OI.java +++ b/src/org/usfirst/frc/team2059/robot/OI.java @@ -20,10 +20,8 @@ public class OI { joystickButtons[0][i] = new JoystickButton(joysticks[0], i + 1); joystickButtons[1][i] = new JoystickButton(joysticks[1], i + 1); } - // Start logging with button1, stop with button2 - Command logEncoder = new LogEncoder(); - joystickButtons[0][0].whenPressed(logEncoder); - joystickButtons[0][1].cancelWhenPressed(logEncoder); + // Print log when button 1 pressed + joystickButtons[0][0].whenPressed(new LogEncoder()); } } // vim: sw=2:ts=2:sts=2 diff --git a/src/org/usfirst/frc/team2059/robot/commands/CommandBase.java b/src/org/usfirst/frc/team2059/robot/commands/CommandBase.java index ba9889f..10b734e 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/CommandBase.java +++ b/src/org/usfirst/frc/team2059/robot/commands/CommandBase.java @@ -2,8 +2,8 @@ package org.usfirst.frc.team2059.robot.commands; import org.usfirst.frc.team2059.robot.subsystems.Drivebase; import org.usfirst.frc.team2059.robot.subsystems.Encoderbase; import edu.wpi.first.wpilibj.command.Command; -public abstract class CommandBase extends Command{ - protected static Encoderbase encoderbase = new Encoderbase(); - protected static Drivebase drivebase = new Drivebase(); +public abstract class CommandBase extends Command { + protected static Encoderbase encoderbase = new Encoderbase(); + protected static Drivebase drivebase = new Drivebase(); } // vim: sw=2:ts=2:sts=2 diff --git a/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java b/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java index 5ec7352..53188df 100644 --- a/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java +++ b/src/org/usfirst/frc/team2059/robot/commands/LogEncoder.java @@ -1,5 +1,6 @@ package org.usfirst.frc.team2059.robot.commands; import org.usfirst.frc.team2059.robot.commands.CommandBase; +import org.usfirst.frc.team2059.robot.structs.EncoderValues; public class LogEncoder extends CommandBase { public LogEncoder() { requires(encoderbase); @@ -7,9 +8,19 @@ public class LogEncoder extends CommandBase { protected void initialize() { } protected boolean isFinished() { - return false; + //TODO: Not sure if isFinished() is checked before execute() + //assuming it is not, + return true; } protected void execute() { + EncoderValues values = encoderbase.getValues(); + System.out.println("==== Encoder log ===="); + System.out.println("Count : " + values.getCount()); + System.out.println("Distance : " + values.getDistance()); + System.out.println("Period : " + values.getPeriod()); + System.out.println("Rate : " + values.getRate()); + System.out.println("Direction : " + values.getDirection()); + System.out.println("Stopped : " + values.getStopped()); } protected void end() { }