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

项目: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;
}
项目:RobotCode2014    文件:BlackBoxSubPacket.java   
private static byte [] createAnalogPacket(int module) {
        byte [] data = new byte[9 + headerSize];
        generateHeader(data, 0, headerSize, 1);
        data[headerSize] = (byte)module;
        for (int i = 0; i < 8; i++) {
            data[i+headerSize+1] = (byte)(5 / AnalogModule.getInstance(module).getVoltage(i+1) * 255);
//          data[i+headerSize+1] = 0;
        }
        return data;
    }
项目:RobotCode2013    文件:BlackBoxSubPacket.java   
private static byte [] createAnalogPacket(int module) {
        byte [] data = new byte[9 + headerSize];
        generateHeader(data, 0, headerSize, 1);
        data[headerSize] = (byte)module;
        for (int i = 0; i < 8; i++) {
            data[i+headerSize+1] = (byte)(5 / AnalogModule.getInstance(module).getVoltage(i+1) * 255);
//          data[i+headerSize+1] = 0;
        }
        return data;
    }
项目:2012    文件:UltraSonicSensor.java   
/**
 * Constructor that uses the default module slot
 * 
 * @param analogChannel channel the ultrasonic sensor is connected to on the
 *                      cRIO 9201 module.
 */
public UltraSonicSensor(int analogChannel)
{
    channel = analogChannel;
    ultrasonicSensor =  AnalogModule.getInstance(1);
}
项目:2013    文件:Ultrasonic.java   
/**
 * Constructor that uses the default module slot
 *
 * @param analogChannel channel the ultrasonic sensor is connected to on the
 * cRIO 9201 module.
 */
public Ultrasonic(int analogChannel) {
    channel = analogChannel;
    ultrasonicSensor = AnalogModule.getInstance(1);
}