本文整理汇总了Java中edu.wpi.first.wpilibj.Counter.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Counter.reset方法的具体用法?Java Counter.reset怎么用?Java Counter.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.Counter
的用法示例。
在下文中一共展示了Counter.reset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbsoluteAnalogEncoder
import edu.wpi.first.wpilibj.Counter; //导入方法依赖的package包/类
public AbsoluteAnalogEncoder(int channel, double minVoltage, double maxVoltage, double offsetDegrees) {
super(channel);
if (minVoltage >= maxVoltage) throw new IllegalArgumentException("Minimum voltage must be less than maximum voltage");
if (offsetDegrees < 0 || offsetDegrees > 360) throw new IllegalArgumentException("Offset must be between 0 and 360 degrees");
_channel = channel;
_minVoltage = minVoltage;
_maxVoltage = maxVoltage;
_offsetDegrees = offsetDegrees;
// Turn counter only ever stores 0 //
_turnCounter = new Counter();
_turnCounter.reset();
_turnCounter.stop();
}
示例2: USensor
import edu.wpi.first.wpilibj.Counter; //导入方法依赖的package包/类
public USensor() {
leftPulse = new DigitalOutput(RobotMap.LEFT_PULSE);
left = new Counter(RobotMap.LEFT_ECHO);
left.setMaxPeriod(1);
left.setSemiPeriodMode(true);
left.reset();
rightPulse = new DigitalOutput(RobotMap.RIGHT_PULSE);
right = new Counter(RobotMap.RIGHT_ECHO);
right.setMaxPeriod(1);
right.setSemiPeriodMode(true);
right.reset();
threadInit(() -> {
leftPulse.pulse(RobotMap.US_PULSE);
rightPulse.pulse(RobotMap.US_PULSE);
do {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (left.get() < 2 || right.get() < 2);
leftDistant = left.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;
rightDistant = right.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;
SmartDashboard.putNumber("left dis", leftDistant);
SmartDashboard.putNumber("right dis", rightDistant);
left.reset();
right.reset();
});
}
示例3: isSwitchPressed
import edu.wpi.first.wpilibj.Counter; //导入方法依赖的package包/类
/**
* Measures a physical switch press and translates it to virtual meaning. If
* the winder motor is moving in the negative direction, the mechanism is
* unwinding and so the switch press count should decrease, and if the motor
* is moving in the positive direction, the mechanism is winding, and thus
* the switch press count should increase.
*
* @param counter The Counter object that represents the physical limit
* switch virtually. A physical switch press increments the counter value
* twice: once on the press (by 4 - 10) and once on the release (by 1 - 3).
* The code only acknowledges the presses by ignoring all increases that are
* less than 4.
*/
private void isSwitchPressed(Counter counter) {
if (counter.get() > 3) {
if (winderL.get() <= -0.1) {
currentClick--;
} else if (winderL.get() >= 0.1) {
currentClick++;
} else {
System.out.println("The switch should not have been pressed.");
}
clickTime = Timer.getFPGATimestamp();
}
counter.reset();
}
示例4: ClimbingSystem
import edu.wpi.first.wpilibj.Counter; //导入方法依赖的package包/类
public ClimbingSystem(RobotTemplate robo)
{
try
{
up = new Solenoid(Wiring.CLIMB_SOLENOID_UP);
down = new Solenoid(Wiring.CLIMB_SOLENOID_DOWN);
forward = new Solenoid(Wiring.CLIMBING_SOLENOID_FORWARD);
back = new Solenoid(Wiring.CLIMBING_SOLENOID_BACKWARD);
home = new DigitalInput(Wiring.CYLINDER_HOME);
part = new DigitalInput(Wiring.CYLINDER_PART);
max = new DigitalInput(Wiring.CYLINDER_MAX);
winch = new CANJaguar(Wiring.WINCH_MOTOR);
countPart = new Counter(part);
countPart.setUpSourceEdge(true, false);
countPart.reset();
countPart.start();
winch.configMaxOutputVoltage(6.0);
forward.set(true);
back.set(false);
this.robo = robo;
time.start();
typicalCurrent = 0;
}
catch (CANTimeoutException ex)
{
ex.printStackTrace();
}
}
示例5: counterInit
import edu.wpi.first.wpilibj.Counter; //导入方法依赖的package包/类
/**
* Initializes the counter object.
*
* @param counter The counter reference.
*/
private void counterInit(Counter counter) {
counter.start();
counter.reset();
}