本文整理汇总了Java中edu.wpi.first.wpilibj.DigitalOutput类的典型用法代码示例。如果您正苦于以下问题:Java DigitalOutput类的具体用法?Java DigitalOutput怎么用?Java DigitalOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DigitalOutput类属于edu.wpi.first.wpilibj包,在下文中一共展示了DigitalOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
@Override
public void perform() {
terminal.writer().println();
terminal.writer().println(Messages.bold(NAME));
terminal.writer().println("pulseLength = 0.25, pulse width = 144 µsec");
terminal.writer().println("pulseLength = 0.50, pulse width = 32 µsec");
terminal.writer().println("pulseLength = 1.00, pulse width = 64 µsec");
terminal.writer().println("pulseLength = 2.00, pulse width = 128 µsec");
terminal.writer().println("pulseLength = 4.00, pulse width = 256 µsec");
terminal.writer().println("pulseLength = 8.00, pulse width = 256 µsec");
terminal.writer().println();
DigitalOutput digitalOutput = dioSet.getDigitalOutput();
if (digitalOutput == null) {
terminal.writer().println(Messages.boldRed("no digital output selected selected"));
return;
}
pulse(digitalOutput, 0.25);
pulse(digitalOutput, 0.5);
pulse(digitalOutput, 1);
pulse(digitalOutput, 2);
pulse(digitalOutput, 4);
pulse(digitalOutput, 8);
}
示例2: selectDigitalOutput
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
void selectDigitalOutput(int channel) {
clearSelectedOutput();
removeInput(channel);
digitalOutput = new DigitalOutput(channel);
outputs.add(channel); // outputs can't be inputs
telemetryService.stop();
for (Item item : telemetryService.getItems()) {
if (item instanceof DigitalInputItem && item.deviceId() == channel) {
telemetryService.remove(item);
break;
}
}
telemetryService.register(new DigitalOutputItem(digitalOutput));
telemetryService.start();
logger.info("initialized output {} and restarted TelemetryService", channel);
}
示例3: perform
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
@Override
public void perform() {
terminal.writer().println();
terminal.writer().println(Messages.bold(NAME));
terminal.writer().println();
DigitalOutput digitalOutput = dioSet.getDigitalOutput();
if (digitalOutput == null) {
terminal.writer().println(Messages.boldRed("no digital output selected"));
return;
}
digitalOutput.disablePWM();
digitalOutput.enablePWM(0.25);
Timer.delay(SLEEP_SEC);
digitalOutput.updateDutyCycle(0.5);
Timer.delay(SLEEP_SEC);
digitalOutput.updateDutyCycle(0.75);
Timer.delay(SLEEP_SEC);
digitalOutput.updateDutyCycle(1.0);
}
示例4: FrcDigitalRGB
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
public FrcDigitalRGB(
final String instanceName, int redChannel, int greenChannel, int blueChannel)
{
super(instanceName);
if (debugEnabled)
{
dbgTrace = new TrcDbgTrace(
moduleName + "." + instanceName,
false,
TrcDbgTrace.TraceLevel.API,
TrcDbgTrace.MsgLevel.INFO);
}
redLight = new DigitalOutput(redChannel);
greenLight = new DigitalOutput(greenChannel);
blueLight = new DigitalOutput(blueChannel);
}
示例5: Shooter
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
public Shooter() {
arduinoPins = new DigitalOutput[3];
arduinoPins[0] = new DigitalOutput(RobotMap.SHOOTER_ARDUINO_PIN1);
arduinoPins[1] = new DigitalOutput(RobotMap.SHOOTER_ARDUINO_PIN2);
arduinoPins[2] = new DigitalOutput(RobotMap.SHOOTER_ARDUINO_PIN3);
angleEncoder.setReverseDirection(true);
angleEncoder.setDistancePerPulse(1);
angleEncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance);
angleEncoder.start();
//SmartDashboard.putBoolean("Shooter Angle PID", true);
anglePID.setInputRange(0, 1400);
anglePID.setPercentTolerance(1);
anglePID.setContinuous(true);
angleSetToPoint(new ShooterPoint("FULL_DOWN"));
photocoder.start(); // ADDED
photocoderPower.set(true);
}
示例6: USensor
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的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();
});
}
示例7: pulse
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
private static void pulse(DigitalOutput digitalOutput, double length) {
while (digitalOutput.isPulsing()) {
try {
Thread.sleep(0, 500_000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
digitalOutput.pulse(length);
}
示例8: perform
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
@Override
public void perform() {
if (dioSet.getDigitalOutput() == null) {
terminal.writer().println(Messages.boldRed("no digital output selected selected"));
return;
}
terminal.writer().println(Messages.bold("Enter duty cycle, press <enter> to go back"));
while (true) {
String line;
try {
line = reader.readLine(Messages.prompt("number or <return> to exit> ")).trim();
} catch (EndOfFileException | UserInterruptException e) {
continue;
}
if (line.isEmpty()) {
return;
}
double setpoint;
try {
setpoint = Double.valueOf(line);
} catch (NumberFormatException nfe) {
help();
continue;
}
terminal.writer().print(Messages.bold(String.format("pulsing for %.2f%n", setpoint)));
DigitalOutput digitalOutput = dioSet.getDigitalOutput();
digitalOutput.disablePWM();
digitalOutput.enablePWM(setpoint);
}
}
示例9: robotInit
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit()
{
// PWM's
mTestMotor1 = new Talon(0);
mTestMotor2 = new Jaguar(1);
mServo = new Servo(2);
// Digital IO
mDigitalOutput = new DigitalOutput(0);
mRightEncoder = new Encoder(4, 5);
mLeftEncoder = new Encoder(1, 2);
mUltrasonic = new Ultrasonic(7, 6);
// Analog IO
mAnalogGryo = new AnalogGyro(0);
mPotentiometer = new AnalogPotentiometer(1);
// Solenoid
mSolenoid = new Solenoid(0);
// Relay
mRelay = new Relay(0);
// Joysticks
mJoystick1 = new Joystick(0);
mJoystick2 = new XboxController(1);
// SPI
mSpiGryo = new ADXRS450_Gyro();
// Utilities
mTimer = new Timer();
mPDP = new PowerDistributionPanel();
Preferences.getInstance().putDouble("Motor One Speed", .5);
}
示例10: Robot
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
public Robot() {
stick = new Joystick(0);
try {
/* Construct Digital I/O Objects */
pwm_out_9 = new Victor( getChannelFromPin( PinType.PWM, 9 ));
pwm_out_8 = new Jaguar( getChannelFromPin( PinType.PWM, 8 ));
dig_in_7 = new DigitalInput( getChannelFromPin( PinType.DigitalIO, 7 ));
dig_in_6 = new DigitalInput( getChannelFromPin( PinType.DigitalIO, 6 ));
dig_out_5 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 5 ));
dig_out_4 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO, 4 ));
enc_3and2 = new Encoder( getChannelFromPin( PinType.DigitalIO, 3 ),
getChannelFromPin( PinType.DigitalIO, 2 ));
enc_1and0 = new Encoder( getChannelFromPin( PinType.DigitalIO, 1 ),
getChannelFromPin( PinType.DigitalIO, 0 ));
/* Construct Analog I/O Objects */
/* NOTE: Due to a board layout issue on the navX MXP board revision */
/* 3.3, there is noticeable crosstalk between AN IN pins 3, 2 and 1. */
/* For that reason, use of pin 3 and pin 2 is NOT RECOMMENDED. */
an_in_1 = new AnalogInput( getChannelFromPin( PinType.AnalogIn, 1 ));
an_trig_0 = new AnalogTrigger( getChannelFromPin( PinType.AnalogIn, 0 ));
an_trig_0_counter = new Counter( an_trig_0 );
an_out_1 = new AnalogOutput( getChannelFromPin( PinType.AnalogOut, 1 ));
an_out_0 = new AnalogOutput( getChannelFromPin( PinType.AnalogOut, 0 ));
/* Configure I/O Objects */
pwm_out_9.setSafetyEnabled(false); /* Disable Motor Safety for Demo */
pwm_out_8.setSafetyEnabled(false); /* Disable Motor Safety for Demo */
/* Configure Analog Trigger */
an_trig_0.setAveraged(true);
an_trig_0.setLimitsVoltage(MIN_AN_TRIGGER_VOLTAGE, MAX_AN_TRIGGER_VOLTAGE);
} catch (RuntimeException ex ) {
DriverStation.reportError( "Error instantiating MXP pin on navX MXP: "
+ ex.getMessage(), true);
}
}
示例11: initBus
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
/**
* Initialize SPI bus<br>
* Only call this method once in the program
*
* @param clk The digital output for the clock signal.
* @param mosi The digital output for the written data to the slave
* (master-out slave-in).
* @param miso The digital input for the input data from the slave
* (master-in slave-out).
*/
public static void initBus(final DigitalOutput clk, final DigitalOutput mosi, final DigitalInput miso) {
if (spi == null) {
spi = new tSPI();
}
else {
throw new BadSPIConfigException("The SPI bus can only be initialized once");
}
clkChannel = clk;
mosiChannel = mosi;
misoChannel = miso;
tSPI.writeChannels_SCLK_Module(clk.getModuleForRouting());
tSPI.writeChannels_SCLK_Channel(clk.getChannelForRouting());
if (mosi != null) {
tSPI.writeChannels_MOSI_Module(mosi.getModuleForRouting());
tSPI.writeChannels_MOSI_Channel(mosi.getChannelForRouting());
} else {
tSPI.writeChannels_MOSI_Module(0);
tSPI.writeChannels_MOSI_Channel(0);
}
if (miso != null) {
tSPI.writeChannels_MISO_Module(miso.getModuleForRouting());
tSPI.writeChannels_MISO_Channel(miso.getChannelForRouting());
tSPI.writeConfig_WriteOnly(false);//TODO check these are right
} else {
tSPI.writeChannels_MISO_Module(0);
tSPI.writeChannels_MISO_Channel(0);
tSPI.writeConfig_WriteOnly(true);
}
tSPI.writeChannels_SS_Module(0);
tSPI.writeChannels_SS_Channel(0);
tSPI.strobeReset();
tSPI.strobeClearReceivedData();
}
示例12: SPIDevice
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
/**
* Create a new device on the SPI bus
*
* @param cs The digital output for the device's chip select pin
* @param csActiveHigh If the chip select line should be high or low when
* @param createdChannel If the free method should free the cs DigitalOutput
* the device is selected is being selected
*/
private SPIDevice(DigitalOutput cs, boolean csActiveHigh, boolean createdChannel) {
if (spi == null) {
throw new RuntimeException("must call SPI.init first");
}
this.createdChannel = createdChannel;
this.cs = cs;
this.csActiveHigh = csActiveHigh;
cs.set(!csActiveHigh);
}
示例13: AccelerometerSPIExample
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
/**
* Constructor.
*
* @param cs the chip select line for the SPI bus
* @param range The range (+ or -) that the accelerometer will measure.
*/
public AccelerometerSPIExample(DigitalOutput cs, AccelerometerSPIExample.DataFormat_Range range) {
spi = new SPIDevice(cs, SPIDevice.CS_ACTIVE_HIGH);
spi.setBitOrder(SPIDevice.BIT_ORDER_MSB_FIRST);
spi.setClockPolarity(SPIDevice.CLOCK_POLARITY_ACTIVE_LOW);
spi.setDataOnTrailing(SPIDevice.DATA_ON_LEADING_EDGE);
// Turn on the measurements
spi.transfer((kPowerCtlRegister << 8) | kPowerCtl_Measure, 16);
// Specify the data format to read
spi.transfer((kDataFormatRegister << 8) | kDataFormat_FullRes | range.value, 16);
}
示例14: WsDigitalOutput
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
public WsDigitalOutput(String name, int channel) {
this.digitalValue = new BooleanSubject(name + ":DigitalOutput" + channel);
startState = new BooleanConfigFileParameter(
this.getClass().getName() + "." + name, "startState", false);
this.output = new DigitalOutput(channel);
digitalValue.setValue(startState.getValue());
}
示例15: ArduinoLights
import edu.wpi.first.wpilibj.DigitalOutput; //导入依赖的package包/类
public ArduinoLights(Sensors sensors) {
//initializing everything
arduinoSignal = new DigitalOutput(5); //data line
arduinoSignifier = new DigitalOutput(6);//tells arduino when to read data
driverStation = DriverStation.getInstance();
this.sensors = sensors;
Timer.delay(.5);
}