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

项目:RobotCode2014    文件:BlackBoxSubPacket.java   
private static byte [] createRelayPacket(int module) {
        byte [] data = new byte[3 + headerSize];
        generateHeader(data, 0, headerSize, 4);
        data[headerSize] = (byte)(module+1);
        for (int i = 0; i < 8; i++) {
            byte bit = (byte)(DigitalModule.getInstance(module+1).getRelayForward(i+1) ? 1:0);
            if (bit == 0) bit = (byte)(DigitalModule.getInstance(module+1).getRelayReverse(i+1) ? 2:0);
//          byte bit = (byte)new Random().nextInt(3);
            if (bit == 1) {
                data[headerSize+1] ^= 1 << 7 - i;
            } else if (bit == 2) {
                data[headerSize+1] ^= 1 << 7 - i;
                data[headerSize+2] ^= 1 << 7 - i;
            }
        }
        return data;
    }
项目:RobotCode2013    文件:BlackBoxSubPacket.java   
private static byte [] createRelayPacket(int module) {
        byte [] data = new byte[3 + headerSize];
        generateHeader(data, 0, headerSize, 4);
        data[headerSize] = (byte)(module+1);
        for (int i = 0; i < 8; i++) {
            byte bit = (byte)(DigitalModule.getInstance(module+1).getRelayForward(i+1) ? 1:0);
            if (bit == 0) bit = (byte)(DigitalModule.getInstance(module+1).getRelayReverse(i+1) ? 2:0);
//          byte bit = (byte)new Random().nextInt(3);
            if (bit == 1) {
                data[headerSize+1] ^= 1 << 7 - i;
            } else if (bit == 2) {
                data[headerSize+1] ^= 1 << 7 - i;
                data[headerSize+2] ^= 1 << 7 - i;
            }
        }
        return data;
    }
项目:RobotCode2014    文件:BlackBoxSubPacket.java   
private static byte [] createDigitalPacket(int module) {
    byte [] data = new byte[3 + headerSize];
    generateHeader(data, 0, headerSize, 2);
    data[headerSize] = (byte)(module+1);
    for (int i = 0; i < 14; i++) {
        if (!DigitalModule.getInstance(module+1).getDIO(i)) continue;
        if (i < 8)
            data[headerSize+1] ^= (byte)(1 << (7-i));
        else
            data[headerSize+2] ^= (byte)(1 << 7-(i-8));
    }
    return data;
}
项目:RobotCode2014    文件:BlackBoxSubPacket.java   
private static byte [] createPWMPacket(int module) {
        byte [] data = new byte[11 + headerSize];
        generateHeader(data, 0, headerSize, 3);
        data[headerSize] = (byte)(module+1);
        for (int i = 0; i < 10; i++) {
            data[i+headerSize+1] = (byte)DigitalModule.getInstance(module+1).getPWM(i+1);
//          data[i+headerSize+1] = (byte)0x80;
        }
        return data;
    }
项目:aerbot-champs    文件:AccelerometerSystem.java   
public void init(Environment environment) {
  accel = new ADXL345_I2C(RobotMap.ACCELEROMETER_PORT, ADXL345_I2C.DataFormat_Range.k4G);
  i2c = new I2C(DigitalModule.getInstance(1), DEVICE_ADDRESS);
  i2c.setCompatabilityMode(true);
  timer = new Timer();
  timer.start();
}
项目:Robotics2014    文件:GY85_I2C.java   
public void setupCompass() {
    if(clear){
        clear = false;
        cwrite = new I2C(DigitalModule.getInstance(1), 0x3C);
        cread = new I2C(DigitalModule.getInstance(1), 0x3D);

        cwrite.write(0, 88);
        cwrite.write(1, 64);
        cwrite.write(2, 0);
    }
    clear = true;
}
项目:Robotics2014    文件:GY85_I2C.java   
public void setupGyro() {
    if(clear){
        clear = false;
        gwrite = new I2C(DigitalModule.getInstance(1), 0xD1);
        gread = new I2C(DigitalModule.getInstance(1), 0xD0);

        gwrite.write(21, Wiring.SAMPLE_RATE);
        gwrite.write(22, 0x1A);
    }
    clear = true;
}
项目:Robotics2014    文件:GY85_I2C.java   
public void setupAccel() {
    if(clear){
        clear = false;
        awrite = new I2C(DigitalModule.getInstance(1), 0xA6);
        aread = new I2C(DigitalModule.getInstance(1), 0xA7);

        awrite.write(44, 0x0A);
        awrite.write(45, 0x08);
        awrite.write(49, 0x08);
    }
    clear = true;
}
项目:SwerveDriveTest    文件:SwerveDrive.java   
public SwerveDrive() {
    frontRight.setContinuous(RobotMap.CONTINUOUS);
    frontLeft.setContinuous(RobotMap.CONTINUOUS);
    rearRight.setContinuous(RobotMap.CONTINUOUS);
    rearLeft.setContinuous(RobotMap.CONTINUOUS);

    frontRight.setAbsoluteTolerance(RobotMap.TOLERANCE);
    frontLeft.setAbsoluteTolerance(RobotMap.TOLERANCE);
    rearRight.setAbsoluteTolerance(RobotMap.TOLERANCE);
    rearLeft.setAbsoluteTolerance(RobotMap.TOLERANCE);

    frontRight.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);
    frontLeft.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);
    rearRight.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);
    rearLeft.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);

    frontRight.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);
    frontLeft.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);
    rearRight.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);
    rearLeft.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);

    positionFL.start();
    positionFR.start();
    positionRL.start();
    positionRR.start();

    frontLeft.enable();
    frontRight.enable();
    rearLeft.enable();
    rearRight.enable();

    i2c = DigitalModule.getInstance(1).getI2C(0x04 << 1);
    retrieveOffsets();
}
项目:MOEnarch-Drive    文件:SwerveDrive.java   
public SwerveDrive() {
    frontRight.setContinuous(RobotMap.CONTINUOUS);
    frontLeft.setContinuous(RobotMap.CONTINUOUS);
    rearRight.setContinuous(RobotMap.CONTINUOUS);
    rearLeft.setContinuous(RobotMap.CONTINUOUS);

    frontRight.setAbsoluteTolerance(RobotMap.TOLERANCE);
    frontLeft.setAbsoluteTolerance(RobotMap.TOLERANCE);
    rearRight.setAbsoluteTolerance(RobotMap.TOLERANCE);
    rearLeft.setAbsoluteTolerance(RobotMap.TOLERANCE);

    frontRight.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);
    frontLeft.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);
    rearRight.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);
    rearLeft.setInputRange(RobotMap.POTMIN, RobotMap.POTMAX);

    frontRight.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);
    frontLeft.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);
    rearRight.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);
    rearLeft.setOutputRange(-RobotMap.STEERPOW, RobotMap.STEERPOW);

    positionFL.start();
    positionFR.start();
    positionRL.start();
    positionRR.start();

    frontLeft.enable();
    frontRight.enable();
    rearLeft.enable();
    rearRight.enable();

    i2c = DigitalModule.getInstance(1).getI2C(0x04 << 1);
    retrieveOffsets();
}
项目:RobotCode2013    文件:BlackBoxSubPacket.java   
private static byte [] createDigitalPacket(int module) {
    byte [] data = new byte[3 + headerSize];
    generateHeader(data, 0, headerSize, 2);
    data[headerSize] = (byte)(module+1);
    for (int i = 0; i < 14; i++) {
        if (!DigitalModule.getInstance(module+1).getDIO(i)) continue;
        if (i < 8)
            data[headerSize+1] ^= (byte)(1 << (7-i));
        else
            data[headerSize+2] ^= (byte)(1 << 7-(i-8));
    }
    return data;
}
项目:RobotCode2013    文件:BlackBoxSubPacket.java   
private static byte [] createPWMPacket(int module) {
        byte [] data = new byte[11 + headerSize];
        generateHeader(data, 0, headerSize, 3);
        data[headerSize] = (byte)(module+1);
        for (int i = 0; i < 10; i++) {
            data[i+headerSize+1] = (byte)DigitalModule.getInstance(module+1).getPWM(i+1);
//          data[i+headerSize+1] = (byte)0x80;
        }
        return data;
    }
项目:RKellyBot    文件:Bling.java   
public Bling() {
    //DigitalModule::GetI2C(UINT32,address);
    DigitalModule digiMod = DigitalModule.getInstance(1);
    chat = digiMod.getI2C(8);

    chat.setCompatabilityMode(true);
}
项目:Woodchuck-2013    文件:InsightLT.java   
public InsightLT(int option)
{

    module = DigitalModule.getInstance(1);  
    setupHelper();      
    config(option);
}
项目:2013_drivebase_proto    文件:WsLED.java   
public MessageHandler() {
    //Get ourselves an i2c instance to send out some data.
    i2c = new I2C(DigitalModule.getInstance(1), 0x52 << 1);
}
项目:2014_software    文件:LED.java   
public MessageHandler() {
    //Get ourselves an i2c instance to send out some data.
    i2c = new I2C(DigitalModule.getInstance(1), 0x52 << 1);
}
项目:Woodchuck-2013    文件:InsightLT.java   
public InsightLT()
{
    module = DigitalModule.getInstance(1);
    setupHelper();        
    config(ONE_TWO_LINE_ZONE);        
}
项目:Woodchuck-2013    文件:InsightLT.java   
public InsightLT(int option, char moduleNumber)
{       
    module = DigitalModule.getInstance(moduleNumber);
    setupHelper();        
    config(option);
}
项目:2013_robot_software    文件:WsLED.java   
public MessageHandler() {
    //Get ourselves an i2c instance to send out some data.
    i2c = new I2C(DigitalModule.getInstance(1), 0x52 << 1);
}