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[0][i] = new JoystickButton(joysticks[0], i + 1);
|
||||||
joystickButtons[1][i] = new JoystickButton(joysticks[1], i + 1);
|
joystickButtons[1][i] = new JoystickButton(joysticks[1], i + 1);
|
||||||
}
|
}
|
||||||
// Start logging with button1, stop with button2
|
// Print log when button 1 pressed
|
||||||
Command logEncoder = new LogEncoder();
|
joystickButtons[0][0].whenPressed(new LogEncoder());
|
||||||
joystickButtons[0][0].whenPressed(logEncoder);
|
|
||||||
joystickButtons[0][1].cancelWhenPressed(logEncoder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// vim: sw=2:ts=2:sts=2
|
// vim: sw=2:ts=2:sts=2
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.usfirst.frc.team2059.robot.commands;
|
package org.usfirst.frc.team2059.robot.commands;
|
||||||
import org.usfirst.frc.team2059.robot.commands.CommandBase;
|
import org.usfirst.frc.team2059.robot.commands.CommandBase;
|
||||||
|
import org.usfirst.frc.team2059.robot.structs.EncoderValues;
|
||||||
public class LogEncoder extends CommandBase {
|
public class LogEncoder extends CommandBase {
|
||||||
public LogEncoder() {
|
public LogEncoder() {
|
||||||
requires(encoderbase);
|
requires(encoderbase);
|
||||||
@ -7,9 +8,19 @@ public class LogEncoder extends CommandBase {
|
|||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
}
|
}
|
||||||
protected boolean isFinished() {
|
protected boolean isFinished() {
|
||||||
return false;
|
//TODO: Not sure if isFinished() is checked before execute()
|
||||||
|
//assuming it is not,
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
protected void execute() {
|
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() {
|
protected void end() {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user