本文整理汇总了Java中edu.wpi.first.wpilibj.hal.DIOJNI类的典型用法代码示例。如果您正苦于以下问题:Java DIOJNI类的具体用法?Java DIOJNI怎么用?Java DIOJNI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DIOJNI类属于edu.wpi.first.wpilibj.hal包,在下文中一共展示了DIOJNI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initRelay
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Common relay initialization method. This code is common to all Relay
* constructors and initializes the relay and reserves all resources that need
* to be locked. Initially the relay is set to both lines at 0v.
*/
private void initRelay() {
SensorBase.checkRelayChannel(m_channel);
try {
if (m_direction == Direction.kBoth || m_direction == Direction.kForward) {
relayChannels.allocate(m_channel * 2);
UsageReporting.report(tResourceType.kResourceType_Relay, m_channel);
}
if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) {
relayChannels.allocate(m_channel * 2 + 1);
UsageReporting.report(tResourceType.kResourceType_Relay, m_channel + 128);
}
} catch (CheckedAllocationException e) {
throw new AllocationException("Relay channel " + m_channel + " is already allocated");
}
m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));
m_safetyHelper = new MotorSafetyHelper(this);
m_safetyHelper.setSafetyEnabled(false);
LiveWindow.addActuator("Relay", m_channel, this);
}
示例2: initDigitalPort
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
protected void initDigitalPort(int channel, boolean input) {
m_channel = channel;
checkDigitalChannel(m_channel);
try {
channels.allocate(m_channel);
} catch (CheckedAllocationException ex) {
throw new AllocationException("Digital input " + m_channel + " is already allocated");
}
long port_pointer = DIOJNI.getPort((byte) channel);
m_port = DIOJNI.initializeDigitalPort(port_pointer);
DIOJNI.allocateDIO(m_port, input);
}
示例3: initPWM
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Initialize PWMs given a channel.
*
* This method is private and is the common path for all the constructors for
* creating PWM instances. Checks channel value ranges and allocates the
* appropriate channel. The allocation is only done to help users ensure that
* they don't double assign channels.
*$
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
* MXP port
*/
private void initPWM(final int channel) {
checkPWMChannel(channel);
m_channel = channel;
m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));
if (!PWMJNI.allocatePWMChannel(m_port)) {
throw new AllocationException("PWM channel " + channel + " is already allocated");
}
PWMJNI.setPWM(m_port, (short) 0);
m_eliminateDeadband = false;
UsageReporting.report(tResourceType.kResourceType_PWM, channel);
}
示例4: free
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
@Override
public void free() {
if (m_direction == Direction.kBoth || m_direction == Direction.kForward) {
relayChannels.free(m_channel * 2);
}
if (m_direction == Direction.kBoth || m_direction == Direction.kReverse) {
relayChannels.free(m_channel * 2 + 1);
}
RelayJNI.setRelayForward(m_port, false);
RelayJNI.setRelayReverse(m_port, false);
DIOJNI.freeDIO(m_port);
DIOJNI.freeDigitalPort(m_port);
m_port = 0;
}
示例5: DigitalOutput
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Create an instance of a digital output. Create an instance of a digital output given a
* channel.
*
* @param channel the DIO channel to use for the digital output. 0-9 are on-board, 10-25 are on
* the MXP
*/
public DigitalOutput(int channel) {
checkDigitalChannel(channel);
m_channel = channel;
m_handle = DIOJNI.initializeDIOPort(DIOJNI.getPort((byte)channel), false);
HAL.report(tResourceType.kResourceType_DigitalOutput, channel);
}
示例6: free
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Free the resources associated with a digital output.
*/
@Override
public void free() {
// disable the pwm only if we have allocated it
if (m_pwmGenerator != invalidPwmGenerator) {
disablePWM();
}
DIOJNI.freeDIOPort(m_handle);
m_handle = 0;
}
示例7: pulse
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* @param channel Unused
* @param pulseLength The length of the pulse.
* @deprecated Generate a single pulse. Write a pulse to the specified digital output channel.
* There can only be a single pulse going at any time.
*/
@Deprecated
@SuppressWarnings("PMD.UnusedFormalParameter")
public void pulse(final int channel, final int pulseLength) {
double convertedPulse = pulseLength / 1.0e9 * (DIOJNI.getLoopTiming() * 25);
System.err
.println("You should use the double version of pulse for portability. This is deprecated");
DIOJNI.pulse(m_handle, convertedPulse);
}
示例8: disablePWM
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Change this line from a PWM output back to a static Digital Output line.
*
* <p>Free up one of the 6 DO PWM generator resources that were in use.
*/
public void disablePWM() {
if (m_pwmGenerator == invalidPwmGenerator) {
return;
}
// Disable the output by routing to a dead bit.
DIOJNI.setDigitalPWMOutputChannel(m_pwmGenerator, kDigitalChannels);
DIOJNI.freeDigitalPWM(m_pwmGenerator);
m_pwmGenerator = invalidPwmGenerator;
}
示例9: checkDigitalChannel
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Check that the digital channel number is valid. Verify that the channel number is one of the
* legal channel numbers. Channel numbers are 0-based.
*
* @param channel The channel number to check.
*/
protected static void checkDigitalChannel(final int channel) {
if (!DIOJNI.checkDIOChannel(channel)) {
StringBuilder buf = new StringBuilder();
buf.append("Requested DIO channel is out of range. Minimum: 0, Maximum: ")
.append(kDigitalChannels)
.append(", Requested: ")
.append(channel);
throw new IndexOutOfBoundsException(buf.toString());
}
}
示例10: DigitalInput
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Create an instance of a Digital Input class. Creates a digital input given a channel.
*
* @param channel the DIO channel for the digital input 0-9 are on-board, 10-25 are on the MXP
*/
public DigitalInput(int channel) {
checkDigitalChannel(channel);
m_channel = channel;
m_handle = DIOJNI.initializeDIOPort(DIOJNI.getPort((byte)channel), true);
LiveWindow.addSensor("DigitalInput", channel, this);
HAL.report(tResourceType.kResourceType_DigitalInput, channel);
}
示例11: free
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Frees the resources for this output.
*/
public void free() {
if (m_interrupt != 0) {
cancelInterrupts();
}
DIOJNI.freeDIOPort(m_handle);
}
示例12: free
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
@Override
public void free() {
channels.free(m_channel);
DIOJNI.freeDIO(m_port);
DIOJNI.freeDigitalPort(m_port);
m_port = 0;
m_channel = 0;
}
示例13: pulse
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* @deprecated Generate a single pulse. Write a pulse to the specified digital
* output channel. There can only be a single pulse going at any
* time.
*
* @param channel The channel to pulse.
* @param pulseLength The length of the pulse.
*/
@Deprecated
public void pulse(final int channel, final int pulseLength) {
float convertedPulse =
(float) (pulseLength / 1.0e9 * (DIOJNI.getLoopTiming() * 25));
System.err
.println("You should use the float version of pulse for portability. This is deprecated");
DIOJNI.pulse(m_port, convertedPulse);
}
示例14: free
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Free the PWM channel.
*
* Free the resource associated with the PWM channel and set the value to 0.
*/
public void free() {
if (m_port == 0) return;
PWMJNI.setPWM(m_port, (short) 0);
PWMJNI.freePWMChannel(m_port);
PWMJNI.freeDIO(m_port);
DIOJNI.freeDigitalPort(m_port);
m_port = 0;
}
示例15: setBounds
import edu.wpi.first.wpilibj.hal.DIOJNI; //导入依赖的package包/类
/**
* Set the bounds on the PWM pulse widths. This sets the bounds on the PWM
* values for a particular type of controller. The values determine the upper
* and lower speeds as well as the deadband bracket.
*$
* @param max The max PWM pulse width in ms
* @param deadbandMax The high end of the deadband range pulse width in ms
* @param center The center (off) pulse width in ms
* @param deadbandMin The low end of the deadband pulse width in ms
* @param min The minimum pulse width in ms
*/
protected void setBounds(double max, double deadbandMax, double center, double deadbandMin,
double min) {
double loopTime =
DIOJNI.getLoopTiming() / (kSystemClockTicksPerMicrosecond * 1e3);
m_maxPwm = (int) ((max - kDefaultPwmCenter) / loopTime + kDefaultPwmStepsDown - 1);
m_deadbandMaxPwm =
(int) ((deadbandMax - kDefaultPwmCenter) / loopTime + kDefaultPwmStepsDown - 1);
m_centerPwm = (int) ((center - kDefaultPwmCenter) / loopTime + kDefaultPwmStepsDown - 1);
m_deadbandMinPwm =
(int) ((deadbandMin - kDefaultPwmCenter) / loopTime + kDefaultPwmStepsDown - 1);
m_minPwm = (int) ((min - kDefaultPwmCenter) / loopTime + kDefaultPwmStepsDown - 1);
}