微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,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,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);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。