当前位置: 首页>>代码示例>>Java>>正文


Java I2C.Port方法代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.I2C.Port方法的典型用法代码示例。如果您正苦于以下问题:Java I2C.Port方法的具体用法?Java I2C.Port怎么用?Java I2C.Port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.wpi.first.wpilibj.I2C的用法示例。


在下文中一共展示了I2C.Port方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BNO055

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Instantiates a new BNO055 class.
 *
 * @param port the physical port the sensor is plugged into on the roboRio
 * @param address the address the sensor is at (0x28 or 0x29)
 */
private BNO055(I2C.Port port, byte address) {
	imu = new I2C(port, address);
	
	executor = new java.util.Timer();
	executor.schedule(new BNO055UpdateTask(this), 0L, THREAD_PERIOD);
}
 
开发者ID:Team334,项目名称:R2017,代码行数:13,代码来源:BNO055.java

示例2: getInstance

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Get an instance of the IMU object.
 * 
 * @param mode the operating mode to run the sensor in.
 * @param port the physical port the sensor is plugged into on the roboRio
 * @param address the address the sensor is at (0x28 or 0x29)
 * @return the instantiated BNO055 object
 */
public static BNO055 getInstance(opmode_t mode, vector_type_t vectorType,
		I2C.Port port, byte address) {
	if(instance == null) {
		instance = new BNO055(port, address);
	}
	requestedMode = mode;
	requestedVectorType = vectorType;
	return instance;
}
 
开发者ID:Team334,项目名称:R2017,代码行数:18,代码来源:BNO055.java

示例3: BNO055

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Instantiates a new BNO055 class.
 *
 * @param port the physical port the sensor is plugged into on the roboRio
 * @param address the address the sensor is at (0x28 or 0x29)
 */
private BNO055(I2C.Port port, byte address) {
    imu = new I2C(port, address);
    this.initialized = false;
    this.state = 0;
    executor = new java.util.Timer();
    executor.schedule(new BNO055UpdateTask(this), 0L, THREAD_PERIOD);
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:14,代码来源:BNO055.java

示例4: getInstance

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Get an instance of the IMU object.
 *
 * @param mode the operating mode to run the sensor in.
 * @param port the physical port the sensor is plugged into on the roboRio
 * @param address the address the sensor is at (0x28 or 0x29)
 * @return the instantiated BNO055 object
 */
public static BNO055 getInstance(opmode_t mode, vector_type_t vectorType,
        I2C.Port port, byte address) {
    if (instance == null) {
        instance = new BNO055(port, address);
    }
    requestedMode = mode;
    return instance;
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:17,代码来源:BNO055.java

示例5: PixyVision

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
public PixyVision(
    final String instanceName, Robot robot, int signature, int brightness, Orientation orientation,
    I2C.Port port, int i2cAddress)
{
    pixyCamera = new FrcPixyCam(instanceName, port, i2cAddress);
    commonInit(robot, signature, brightness, orientation);
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:8,代码来源:PixyVision.java

示例6: FrcPixyCam

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Constructor: Create an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param port specifies the I2C port on the RoboRIO.
 * @param devAddress specifies the I2C address of the device.
 */
public FrcPixyCam(final String instanceName, I2C.Port port, int devAddress)
{
    super(instanceName);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    pixyCam = new FrcI2cDevice(instanceName, port, devAddress);
    start();
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:20,代码来源:FrcPixyCam.java

示例7: ADXL345_I2C_SparkFun

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Constructor.
 * @param port The I2C port the accelerometer is attached to
 * @param range The range (+ or -) that the accelerometer will measure.
 */
public ADXL345_I2C_SparkFun(I2C.Port port, Range range) {
	m_i2c = new I2C(port, kAddress);

	// Turn on the measurements
	m_i2c.write(kPowerCtlRegister, kPowerCtl_Measure);

	setRange(range);

	UsageReporting.report(tResourceType.kResourceType_ADXL345, tInstances.kADXL345_I2C);
	LiveWindow.addSensor("ADXL345_I2C", port.getValue(), this);
}
 
开发者ID:bussell,项目名称:SparkFun6Dof,代码行数:17,代码来源:ADXL345_I2C_SparkFun.java

示例8: GyroITG3200

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/** Default constructor, uses default I2C address.
 * @see ITG3200_DEFAULT_ADDRESS
 */
public GyroITG3200( I2C.Port port )
{
    devAddr = ITG3200_DEFAULT_ADDRESS;

	m_i2c = new I2C(port, devAddr);

	// TODO: This report is incorrect.  Need to create instance for I2C ITG3200 Gyro
	//UsageReporting.report( tResourceType.kResourceType_I2C, tInstances.?? );
	LiveWindow.addSensor( "ITG3200_Gyro_I2C", port.getValue(), this );
}
 
开发者ID:bussell,项目名称:SparkFun6Dof,代码行数:14,代码来源:GyroITG3200.java

示例9: TurtleXtrinsicMagnetometer

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
public TurtleXtrinsicMagnetometer(I2C.Port port, TurtleXtrinsicMagnetometerCalibration calib) {
	updateTimer = new java.util.Timer(true);
	i2c = new I2C(port, address);
	if (i2c == null) {
		System.err.println("Null m_i2c");
	}

	// check to see if the I2C connection is working correctly
	i2c.read(0x07, 1, buffer);
	System.out.println("WHO_AM_I: " + buffer[0]);
	if ((Byte.toUnsignedInt(buffer[0])) != 0xc4) {
		System.out.println("Something has gone terribly wrong.");

	} else {
		System.out.println("Found WHO_AM_I");
	}

	// settings for rate and measuring data
	i2c.write(0x10, 0b00011001);
	i2c.write(0x11, 0b10000000);

	// calibration (done in code, so set to 0)
	i2c.write(0x09, 0b00000000);
	i2c.write(0x0a, 0b00000000);
	i2c.write(0x0b, 0b00000000);
	i2c.write(0x0c, 0b00000000);
	i2c.write(0x0d, 0b00000000);
	i2c.write(0x0e, 0b00000000);

	this.setCalibration(calib);
	// initial update
	rateTimer.start();
	update();

	// Schedule the java.util.Timer to repeatedly update this sensor
	updateTimer.schedule(new TurtleXtrinsicMagnetometerUpdater(), UPDATETIME, UPDATETIME);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:38,代码来源:TurtleXtrinsicMagnetometer.java

示例10: LIDARLite

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Instantiates LIDARLite with given port and update speed
 * 
 * @param port
 * @param updateMillis
 */
public LIDARLite(I2C.Port port, long updateMillis) {
	sensor = new I2C(port, 0x62);

	Timer.delay(1.5);

	// sensor

	SmartDashboard.putBoolean("SensorAddress - false is success", sensor.addressOnly());

	// Configure Sensor. See
	// http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf

	sensor.write(0x02, 0x80); // Maximum number of acquisitions during
								// measurement
	sensor.write(0x04, 0x08); // Acquisition mode control
	sensor.write(0x1c, 0x00); // Peak detection threshold bypass

	reset();

	new java.util.Timer().schedule(new TimerTask() {
		@Override
		public void run() {
			distance = measureDistance();
			velocity = measureVelocity();
			// System.out.println(distance.getInches()+"
			// "+velocity.getValue());
		}
	}, updateMillis, updateMillis);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:36,代码来源:LIDARLite.java

示例11: LIDARSerial

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Instantiates LIDARLite with given port and update speed
 * 
 * @param port
 * @param updateMillis
 */
public LIDARSerial(I2C.Port port, long updateMillis) {
	sensor = new I2C(port, 0x62);
	
	Timer.delay(1.5);

	// sensor

	SmartDashboard.putBoolean("SensorAddress", sensor.addressOnly());

	// Configure Sensor. See
	// http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf

	sensor.write(0x02, 0x80); // Maximum number of acquisitions during
								// measurement
	sensor.write(0x04, 0x08); // Acquisition mode control
	sensor.write(0x1c, 0x00); // Peak detection threshold bypass

	reset();

	t = new java.util.Timer();
	t.schedule(new TimerTask() {
		@Override
		public void run() {
			distance = measureDistance();
			velocity = measureVelocity();
			// System.out.println(distance.getInches()+" "+velocity.getValue());
		}
	}, updateMillis, updateMillis);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:36,代码来源:LIDARSerial.java

示例12: TurtleXtrinsicMagnetometer

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Magnetometer constructor, address is precoded. MAKE SURE TO CALIBRATE
 * BEFORE USING
 */
public TurtleXtrinsicMagnetometer(I2C.Port port) {
	i2c = new I2C(port, address);
	if (i2c == null) {
		System.out.println("Null m_i2c");
	}

	// check to see if the I2C connection is working correctly
	i2c.read(0x07, 1, buffer);
	System.out.println("WHO_AM_I: " + buffer[0]);
	if ((Byte.toUnsignedInt(buffer[0])) != 0xc4) {
		System.out.println("Something has gone terribly wrong.");

	} else {
		System.out.println("Found WHO_AM_I");
	}

	// settings for rate and measuring data
	i2c.write(0x10, 0b00011001);
	i2c.write(0x11, 0b10000000);

	// calibration (done in code, so set to 0)
	i2c.write(0x09, 0b00000000);
	i2c.write(0x0a, 0b00000000);
	i2c.write(0x0b, 0b00000000);
	i2c.write(0x0c, 0b00000000);
	i2c.write(0x0d, 0b00000000);
	i2c.write(0x0e, 0b00000000);

	this.setCalibration(this.generateCalibration());
	// initial update
	update();
	prevAngle = angle = 0;
	rateTimer.start();
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:39,代码来源:TurtleXtrinsicMagnetometer.java

示例13: AHRS

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Constructs the AHRS class using I2C communication, overriding the default
 * update rate with a custom rate which may be from 4 to 60, representing
 * the number of updates per second sent by the sensor.
 * <p>
 * This constructor should be used if communicating via I2C.
 * <p>
 * Note that increasing the update rate may increase the CPU utilization.
 * <p>
 * 
 * @param i2c_port_id
 *            I2C Port to use
 * @param update_rate_hz
 *            Custom Update Rate (Hz)
 */
public AHRS(I2C.Port i2c_port_id, byte update_rate_hz) {
	commonInit(update_rate_hz);
	io = new RegisterIO(new RegisterIO_I2C(new I2C(i2c_port_id, 0x32)), update_rate_hz, io_complete_sink,
			board_capabilities);
	io_thread.start();
}
 
开发者ID:nerdherd,项目名称:Stronghold2016,代码行数:22,代码来源:AHRS.java

示例14: accelerometer

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Create a new {@link ThreeAxisAccelerometer} for the ADXL345 with the desired range using the specified I2C port.
 *
 * @param port the I2C port used by the accelerometer
 * @param range the desired range of the accelerometer
 * @return the accelerometer; never null
 */
public static ThreeAxisAccelerometer accelerometer(I2C.Port port, Range range) {
    if (port == null) throw new IllegalArgumentException("The I2C port must be specified");
    if (range == null) throw new IllegalArgumentException("The accelerometer range must be specified");
    ADXL345_I2C accel = new ADXL345_I2C(port, range);
    return ThreeAxisAccelerometer.create(accel::getX, accel::getY, accel::getZ);
}
 
开发者ID:strongback,项目名称:strongback-java,代码行数:14,代码来源:Hardware.java

示例15: AHRS

import edu.wpi.first.wpilibj.I2C; //导入方法依赖的package包/类
/**
 * Constructs the AHRS class using I2C communication, overriding the 
 * default update rate with a custom rate which may be from 4 to 60, 
 * representing the number of updates per second sent by the sensor.  
 *<p>
 * This constructor should be used if communicating via I2C.
 *<p>
 * Note that increasing the update rate may increase the 
 * CPU utilization.
 *<p>
 * @param i2c_port_id I2C Port to use
 * @param update_rate_hz Custom Update Rate (Hz)
 */
public AHRS(I2C.Port i2c_port_id, byte update_rate_hz) {
    commonInit(update_rate_hz);
    io = new RegisterIO(new RegisterIO_I2C(new I2C(i2c_port_id, 0x32)), update_rate_hz, io_complete_sink, board_capabilities);
    io_thread.start();
}
 
开发者ID:FRC4131,项目名称:FRCStronghold2016,代码行数:19,代码来源:AHRS.java


注:本文中的edu.wpi.first.wpilibj.I2C.Port方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。