Implemented LogEncoder
This commit is contained in:
parent
089bab94d1
commit
667a528b98
@ -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
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user