本文整理汇总了Java中edu.wpi.first.wpilibj.DigitalModule类的典型用法代码示例。如果您正苦于以下问题:Java DigitalModule类的具体用法?Java DigitalModule怎么用?Java DigitalModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DigitalModule类属于edu.wpi.first.wpilibj包,在下文中一共展示了DigitalModule类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRelayPacket
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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;
}
示例2: createDigitalPacket
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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;
}
示例3: createPWMPacket
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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;
}
示例4: init
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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();
}
示例5: setupCompass
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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;
}
示例6: setupGyro
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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;
}
示例7: setupAccel
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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;
}
示例8: SwerveDrive
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
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();
}
示例9: Bling
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
public Bling() {
//DigitalModule::GetI2C(UINT32,address);
DigitalModule digiMod = DigitalModule.getInstance(1);
chat = digiMod.getI2C(8);
chat.setCompatabilityMode(true);
}
示例10: InsightLT
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
public InsightLT(int option)
{
module = DigitalModule.getInstance(1);
setupHelper();
config(option);
}
示例11: MessageHandler
import edu.wpi.first.wpilibj.DigitalModule; //导入依赖的package包/类
public MessageHandler() {
//Get ourselves an i2c instance to send out some data.
i2c = new I2C(DigitalModule.getInstance(1), 0x52 << 1);
}