Java 类edu.wpi.first.wpilibj.AnalogTriggerOutput 实例源码

项目:SwerveDrive    文件:AbsoluteAnalogEncoder.java   
public AbsoluteAnalogEncoder(int channel, double minVoltage, double maxVoltage, double offsetDegrees, int analogSampleRate, double analogTriggerThresholdDifference) { //TODO: Implement direction
    super(channel);
    _channel = 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");

    // Initialize analog trigger //
    _analogTrigger = new AnalogTrigger(channel);
    _analogTrigger.setFiltered(true);
    _analogTrigger.setLimitsVoltage(minVoltage + analogTriggerThresholdDifference, maxVoltage - analogTriggerThresholdDifference);
    AnalogTriggerOutput _analogTriggerFalling = new AnalogTriggerOutput(_analogTrigger, AnalogTriggerOutput.Type.kFallingPulse);
    AnalogTriggerOutput _analogTriggerRising = new AnalogTriggerOutput(_analogTrigger, AnalogTriggerOutput.Type.kRisingPulse);

    // Set analog module sampling rate //        
    AnalogModule module = (AnalogModule) Module.getModule(ModulePresence.ModuleType.kAnalog, DEFAULT_ANALOG_MODULE);
    module.setSampleRate(analogSampleRate);

    // Initialize turn counter //
    _turnCounter = new Counter();
    _turnCounter.setUpDownCounterMode();
    _turnCounter.setUpSource(_analogTriggerRising);
    _turnCounter.setDownSource(_analogTriggerFalling);
    _turnCounter.start();

    _minVoltage = minVoltage;
    _maxVoltage = maxVoltage;
    _offsetDegrees = offsetDegrees;
}
项目:SwerveDriveTest    文件:AnalogChannelVolt.java   
public AnalogChannelVolt(int moduleNumber, int channel) {
    super(moduleNumber, channel);

    this.getModule().setSampleRate(1000);

    m_trig = new AnalogTrigger(moduleNumber, channel);
    m_trig.setFiltered(true);
    m_trig.setLimitsVoltage(1.35, 3.65);

    m_count = new Counter();
    m_count.setUpDownCounterMode();
    m_count.setUpSource(m_trig, AnalogTriggerOutput.Type.kFallingPulse);
    m_count.setDownSource(m_trig, AnalogTriggerOutput.Type.kRisingPulse);
    m_count.start();
}
项目:MOEnarch-Drive    文件:AnalogChannelVolt.java   
public AnalogChannelVolt(int moduleNumber, int channel) {
    super(moduleNumber, channel);

    this.getModule().setSampleRate(1000);

    m_trig = new AnalogTrigger(moduleNumber, channel);
    m_trig.setFiltered(true);
    m_trig.setLimitsVoltage(1.35, 3.65);

    m_count = new Counter();
    m_count.setUpDownCounterMode();
    m_count.setUpSource(m_trig, AnalogTriggerOutput.Type.kFallingPulse);
    m_count.setDownSource(m_trig, AnalogTriggerOutput.Type.kRisingPulse);
    m_count.start();
}