edu.wpi.first.wpilibj.DigitalOutput的实例源码

项目:thirdcoast    文件DemopulseDigitalOutputCommand.java   
@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);
}
项目:thirdcoast    文件dioSet.java   
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);
}
项目:thirdcoast    文件DemoPwmDigitalOutputCommand.java   
@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);
}
项目:Frc2016FirstStronghold    文件FrcDigitalRGB.java   
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);
}
项目:Frc2017FirstSteamWorks    文件FrcDigitalRGB.java   
public FrcDigitalRGB(
        final String instanceName,TrcDbgTrace.MsgLevel.INFO);
    }

    redLight = new DigitalOutput(redChannel);
    greenLight = new DigitalOutput(greenChannel);
    blueLight = new DigitalOutput(blueChannel);
}
项目:RobotCode2013    文件Shooter.java   
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);
}
项目:FRC6414program    文件USensor.java   
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();
    });
}
项目:thirdcoast    文件DemopulseDigitalOutputCommand.java   
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);
}
项目:thirdcoast    文件PwmDigitalOutputCommand.java   
@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);
  }
}
项目:snobot-2017    文件Snobot.java   
/**
 * 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);
}
项目:turtleshell    文件Robot.java   
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 ),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);
    }
}
项目:Team3310FRC2014    文件SPIDevice.java   
/**
 * 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();
}
项目:Team3310FRC2014    文件SPIDevice.java   
/**
 * 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);
}
项目:Team3310FRC2014    文件AccelerometerSPIExample.java   
/**
 * 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);
}
项目:2013_drivebase_proto    文件WsDigitalOutput.java   
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());
}
项目:FRC2014    文件ArduinoLights.java   
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);
}
项目:2014_software    文件WsDigitalOutput.java   
public WsDigitalOutput(String name,false);

    this.output = new DigitalOutput(channel);

    digitalValue.setValue(startState.getValue());
}
项目:2014_Main_Robot    文件ArduinoInterface.java   
/**
 * Ensure nobody can call the constructor on this class directly.
 */
private ArduinoInterface() {
    pin1 = new DigitalOutput(RobotMap.arduinopin1.getInt());
    pin2 = new DigitalOutput(RobotMap.arduinopin2.getInt());
    pin3 = new DigitalOutput(RobotMap.arduinopin3.getInt());
    pin4 = new DigitalOutput(RobotMap.arduinopin4.getInt());

    //Initialize outputs to off state.
    reset();
}
项目:BadRobot2013    文件DecorativeLights.java   
private DecorativeLights()
{
    redChannel = new DigitalOutput(BadRobotMap.redChannel);
    greenChannel = new DigitalOutput(BadRobotMap.greenChannel);
    blueChannel = new DigitalOutput(BadRobotMap.blueChannel);

    redChannel.enablePWM(0);
    greenChannel.enablePWM(0);
    blueChannel.enablePWM(0);
}
项目:wpilib-java    文件FakeEncoderSource.java   
public void run()
{

    DigitalOutput lead,lag;

    m_encoder.m_outputA.set(false);
    m_encoder.m_outputB.set(false);

    if (m_encoder.isForward())
    {
        lead = m_encoder.m_outputA;
        lag = m_encoder.m_outputB;
    } else
    {
        lead = m_encoder.m_outputB;
        lag = m_encoder.m_outputA;
    }

    try
    {
        for (int i = 0; i < m_encoder.m_count; i++)
        {
            lead.set(true);
            Thread.sleep(m_encoder.m_mSec);
            lag.set(true);
            Thread.sleep(m_encoder.m_mSec);
            lead.set(false);
            Thread.sleep(m_encoder.m_mSec);
            lag.set(false);
            Thread.sleep(m_encoder.m_mSec);
        }
    } catch (InterruptedException e)
    {
    }
}
项目:wpilib-java    文件FakeEncoderSource.java   
public FakeEncoderSource(int slotA,int portA,int slotB,int portB)
{
    m_outputA = new DigitalOutput(slotA,portA);
    m_outputB = new DigitalOutput(slotB,portB);
    allocatedOutputs = true;
    initQuadEncoder();
}
项目:wpilib-java    文件FakeEncoderSource.java   
public FakeEncoderSource(int portA,int portB)
{
    m_outputA = new DigitalOutput(portA);
    m_outputB = new DigitalOutput(portB);
    allocatedOutputs = true;
    initQuadEncoder();
}
项目:wpilib-java    文件FakeEncoderSource.java   
public FakeEncoderSource(DigitalOutput iA,DigitalOutput iB)
{
    m_outputA = iA;
    m_outputB = iB;
    allocatedOutputs = false;
    initQuadEncoder();
}
项目:2013_robot_software    文件WsDigitalOutput.java   
public WsDigitalOutput(String name,false);

    this.output = new DigitalOutput(channel);

    digitalValue.setValue(startState.getValue());
}
项目:2013-robot    文件SPIDevice.java   
/**
 * 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 createdChannel) {
    if (spi == null) {
        throw new RuntimeException("must call SPI.init first");
    }
    this.createdChannel = createdChannel;
    this.cs = cs;
    this.csActiveHigh = csActiveHigh;
    cs.set(!csActiveHigh);
}
项目:RA17_RobotCode    文件Scopetoggler.java   
/**
 * Creates new Scopetoggler
 * @param togglePort int DigitalOutput port for toggles
 * @param highLow int DigitalOutput port for high/low cycle
 */
public Scopetoggler(int togglePort,int highLow) {
    toggleOutput = new DigitalOutput(togglePort);
    highLowOutput = new DigitalOutput(highLow);
    oldState = false;
}
项目:thirdcoast    文件dioMenu.java   
@Override
protected String header() {
  DigitalOutput digitalOutput = dioSet.getDigitalOutput();
  String id = digitalOutput != null ? String.valueOf(digitalOutput.getChannel()) : "";
  return Messages.boldGreen("\nDigital Output: " + id + "\n");
}
项目:thirdcoast    文件dioSet.java   
@Nullable
DigitalOutput getDigitalOutput() {
  return digitalOutput;
}
项目:thirdcoast    文件DigitalOutputItem.java   
public DigitalOutputItem(DigitalOutput digitalOutput,String description) {
  super(TYPE,description,MEASURES);
  this.digitalOutput = digitalOutput;
}
项目:thirdcoast    文件DigitalOutputItem.java   
public DigitalOutputItem(DigitalOutput digitalOutput) {
  this(digitalOutput,"Digital Output " + digitalOutput.getChannel());
}
项目:2017-code    文件Light.java   
public Light(String name,int id,int port,Joystick stick) {
    super(name,id);
    this.spike = new DigitalOutput(port);
    this.spike.set(false);
    this.stick = stick;
}
项目:turtleshell    文件LED.java   
/**
 * Create LED with digital port
 */
public LED(int port) {
    output = new DigitalOutput(port);

    set(false);
}
项目:RobotCode2014    文件VisionSubsystem.java   
public VisionSubsystem() {
    ringLight = new Solenoid(RobotMap.VISION_RING_LIGHT);
    hottarget = new DigitalInput(RobotMap.VISION_HOT_TARGET);
    startProcessing = new DigitalOutput(RobotMap.VISION_START_PROCESSING);
    processing = false;
}
项目:Storm2014    文件LEDRing.java   
public LEDRing(){
    _out = new DigitalOutput(RobotMap.PORT_LED_RING);
    _out.setPWMRate(FREQUENCY);
    _out.enablePWM(INIT_DUTY_CYCLE / 100);
}
项目:Storm2014    文件StaticLED.java   
/**
 * @param channel The channel for the DigitalOutput.
 */
public StaticLED(int channel){
    _out = new DigitalOutput(channel);
    initDigitalOutput();
}
项目:Storm2014    文件StaticLED.java   
/**
 * @param module The module for the DigitalOutput.
 * @param channel The channel for the DigitalOutput.
 */
public StaticLED(int module,int channel){
    _out = new DigitalOutput(module,channel);
    initDigitalOutput();
}
项目:frc1675-2013    文件Lights.java   
public Lights(){
    bitOne = new DigitalOutput(RobotMap.LIGHTS_BIT_ONE);
    bitTwo = new DigitalOutput(RobotMap.LIGHTS_BIT_TWO);
    bitThree = new DigitalOutput(RobotMap.LIGHTS_BIT_THREE);
}
项目:wpilib-java    文件FakeCounterSource.java   
/**
 * Create a fake encoder on a given port
 * @param port The port the encoder is supposed to be on
 */
public FakeCounterSource(int port)
{
    m_output = new DigitalOutput(port);
    initEncoder();
}
项目:wpilib-java    文件FakeCounterSource.java   
/**
 * Create a new fake encoder on the indicated slot and port
 * @param slot Slot to create on
 * @param port THe port that the encoder is supposably on
 */
public FakeCounterSource(int slot,int port)
{
    m_output = new DigitalOutput(slot,port);
    initEncoder();
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...