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; }
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; }
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; }
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(); }
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; }
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; }
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; }
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(); }
public Bling() { //DigitalModule::GetI2C(UINT32,address); DigitalModule digiMod = DigitalModule.getInstance(1); chat = digiMod.getI2C(8); chat.setCompatabilityMode(true); }
public InsightLT(int option) { module = DigitalModule.getInstance(1); setupHelper(); config(option); }
public MessageHandler() { //Get ourselves an i2c instance to send out some data. i2c = new I2C(DigitalModule.getInstance(1), 0x52 << 1); }
public InsightLT() { module = DigitalModule.getInstance(1); setupHelper(); config(ONE_TWO_LINE_ZONE); }
public InsightLT(int option, char moduleNumber) { module = DigitalModule.getInstance(moduleNumber); setupHelper(); config(option); }