本文整理汇总了Java中edu.wpi.first.wpilibj.Relay.Value方法的典型用法代码示例。如果您正苦于以下问题:Java Relay.Value方法的具体用法?Java Relay.Value怎么用?Java Relay.Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.Relay
的用法示例。
在下文中一共展示了Relay.Value方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tick
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
@Override
public void tick() {
double horizontalRotationDegrees = (double) this.getDataKey(CameraSubsystemDataKey.HORIZONTAL_ROTATION_DEGREES);
double verticalRotationDegrees = (double) this.getDataKey(CameraSubsystemDataKey.VERTICAL_ROTATION_DEGREES);
double horizontalValue = WarriorMath.map(horizontalDegrees[1], horizontalDegrees[0], horizontalRotationDegrees, 0.0, 1.0);
double verticalValue = WarriorMath.map(verticalDegrees[1], verticalDegrees[0], verticalRotationDegrees, 0.0, 1.0);
Relay.Value lightsValue = null;
if((boolean) this.getDataKey(CameraSubsystemDataKey.LIGHTS) == true) {
lightsValue = Relay.Value.kOn;
} else {
lightsValue = Relay.Value.kOff;
}
this._horizontal.set(horizontalValue);
this._vertical.set(verticalValue);
this._lights.set(lightsValue);
}
示例2: setForward
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
/**
* Set the state of the forward channel.
* The innermost pin (A) on the Relay connector is "forward".
* This method will not affect the state of the reverse channel.
*
* @param val true if on, false if off
*/
public void setForward(boolean fwdVal) {
Relay.Value currentValue = this.get(),
newValue = currentValue;
if(currentValue == Relay.Value.kForward) {
if(!fwdVal)
newValue = Relay.Value.kOff;
} else if(currentValue == Relay.Value.kOff) {
if(fwdVal)
newValue = Relay.Value.kForward;
} else if(currentValue == Relay.Value.kOn) {
if(!fwdVal)
newValue = Relay.Value.kReverse;
} else if(currentValue == Relay.Value.kReverse) {
if(fwdVal)
newValue = Relay.Value.kOn;
}
this.set(newValue);
}
示例3: setReverse
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
/**
* Set the state of the reverse channel.
* The center pin (B) on the Relay connector is "reverse".
* This method will not affect the state of the forward channel.
*
* @param val true if on, false if off
*/
public void setReverse(boolean revVal) {
Relay.Value currentValue = this.get(),
newValue = currentValue;
if(currentValue == Relay.Value.kForward) {
if(revVal)
newValue = Relay.Value.kOn;
} else if(currentValue == Relay.Value.kOff) {
if(revVal)
newValue = Relay.Value.kReverse;
} else if(currentValue == Relay.Value.kOn) {
if(!revVal)
newValue = Relay.Value.kForward;
} else if(currentValue == Relay.Value.kReverse) {
if(!revVal)
newValue = Relay.Value.kOff;
}
this.set(newValue);
}
示例4: set
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
public void set(boolean pRelayState) {
boolean leftRelayState;
boolean rightRelayState;
Relay.Value currentValue = relay.get();
/* Get left and right relay states */
if (relaySide == LEFT_RELAY) {
leftRelayState = pRelayState;
rightRelayState = (currentValue.equals(Relay.Value.kOn) || currentValue.equals(Relay.Value.kReverse));
}
else {
leftRelayState = (currentValue.equals(Relay.Value.kOn) || currentValue.equals(Relay.Value.kForward));
rightRelayState = pRelayState;
}
/* Set relay to left and right relay states */
if (leftRelayState) {
if (rightRelayState) {
relay.set(Relay.Value.kOn);
}
else {
relay.set(Relay.Value.kForward);
}
}
else if (rightRelayState) {
relay.set(Relay.Value.kReverse);
}
else {
relay.set(Relay.Value.kOff);
}
}
示例5: get
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
public Relay.Value get() {
return relay.get();
}
示例6: setRelayValues
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
/**
* @param set
* relay values
*/
public void setRelayValues(Relay.Value relayOne, Relay.Value relayTwo) {
this.relayOne.set(relayOne);
this.relayTwo.set(relayTwo);
}
示例7: intakeLiftState
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
public Relay.Value intakeLiftState(){
return intakeLift.get();
}
示例8: getPosition
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
/**
* This method no matter what state the switch is in, and uses the values found
* in the
* WPI Relay class' enum "Value" for compatibility. If the state of the first
* port
* the switch is plugged into is "on," and the state of the second port the
* switch is
* plugged into is "off," the method returns the "kForward". If the reverse is
* true,
* the method returns "kReverse". If both are off (the switch is in its center
* position), the method return "kOff". This does not make use of the
* Relay.Value.kOn
* value.
*
* @return The state of the switch. Either "kForward", "kReverse", or "kOff".
* @author Alex Kneipp
* @written Jan 18, 2016
*/
public Relay.Value getPosition ()
{
if (switch1.isOn())
return Relay.Value.kForward;
else if (switch2.isOn())
return Relay.Value.kReverse;
else
return Relay.Value.kOff;
}
示例9: setRelayValues
import edu.wpi.first.wpilibj.Relay; //导入方法依赖的package包/类
/**
* set relay values
* @param relayOne the value to set the first relay to
* @param relayTwo the value to set the second relay to
*/
public void setRelayValues(Relay.Value relayOne, Relay.Value relayTwo) {
this.relayOne.set(relayOne);
this.relayTwo.set(relayTwo);
}