本文整理汇总了Java中edu.wpi.first.wpilibj.SPI.Port方法的典型用法代码示例。如果您正苦于以下问题:Java SPI.Port方法的具体用法?Java SPI.Port怎么用?Java SPI.Port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.SPI
的用法示例。
在下文中一共展示了SPI.Port方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ADXRS453_Gyro
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param port
* (the SPI port that the gyro is connected to)
*/
public ADXRS453_Gyro(SPI.Port port) {
m_spi = new SPI(port);
m_spi.setClockRate(3000000);
m_spi.setMSBFirst();
m_spi.setSampleDataOnRising();
m_spi.setClockActiveHigh();
m_spi.setChipSelectActiveLow();
/** Validate the part ID */
if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
m_spi.free();
m_spi = null;
DriverStation.reportError("Could not find ADXRS453 gyro on SPI port " + port.value, false);
return;
}
m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c00000E, 0x04000000, 10, 16, true, true);
calibrate();
LiveWindow.addSensor("ADXRS453_Gyro", port.value, this);
}
示例2: ADXRS453_Gyro
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param port
* (the SPI port that the gyro is connected to)
*/
public ADXRS453_Gyro(SPI.Port port) {
m_spi = new SPI(port);
m_spi.setClockRate(3000000);
m_spi.setMSBFirst();
m_spi.setSampleDataOnRising();
m_spi.setClockActiveHigh();
m_spi.setChipSelectActiveLow();
/** Validate the part ID */
if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
m_spi.free();
m_spi = null;
DriverStation.reportError("Could not find ADXRS453 gyro on SPI port " + port.name(), false);
return;
}
m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c00000E, 0x04000000, 10, 16, true, true);
calibrate();
}
示例3: MappedAHRS
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Default constructor.
*
* @param port The port the NavX is plugged into. It seems like only kMXP (the port on the RIO) works.
* @param invertYaw Whether or not to invert the yaw axis. Defaults to true.
*/
@JsonCreator
public MappedAHRS(@JsonProperty(required = true) SPI.Port port,
Boolean invertYaw) {
this.ahrs = new AHRS(port);
ahrs.reset();
if (invertYaw == null || invertYaw) {
this.invertYaw = -1;
} else {
this.invertYaw = 1;
}
}
示例4: AHRS
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Constructs the AHRS class using SPI 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 SPI.
* <p>
* Note that increasing the update rate may increase the CPU utilization.
* <p>
*
* @param spi_port_id
* SPI Port to use
* @param update_rate_hz
* Custom Update Rate (Hz)
*/
public AHRS(SPI.Port spi_port_id, byte update_rate_hz) {
commonInit(update_rate_hz);
io = new RegisterIO(new RegisterIO_SPI(new SPI(spi_port_id)), update_rate_hz, io_complete_sink,
board_capabilities);
io_thread.start();
}
示例5: AHRS
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* The AHRS class provides an interface to AHRS capabilities
* of the KauaiLabs navX Robotics Navigation Sensor via SPI, I2C and
* Serial (TTL UART and USB) communications interfaces on the RoboRIO.
*
* The AHRS class enables access to basic connectivity and state information,
* as well as key 6-axis and 9-axis orientation information (yaw, pitch, roll,
* compass heading, fused (9-axis) heading and magnetic disturbance detection.
*
* Additionally, the ARHS class also provides access to extended information
* including linear acceleration, motion detection, rotation detection and sensor
* temperature.
*
* If used with the navX Aero, the AHRS class also provides access to
* altitude, barometric pressure and pressure sensor temperature data
*
* This constructor allows the specification of a custom SPI bitrate, in bits/second.
*
* @param spi_port_id SPI Port to use
* @param spi_bitrate SPI bitrate (Maximum: 2,000,000)
* @param update_rate_hz Custom Update Rate (Hz)
*/
public AHRS(SPI.Port spi_port_id, int spi_bitrate, byte update_rate_hz) {
commonInit(update_rate_hz);
io = new RegisterIO(new RegisterIO_SPI(new SPI(spi_port_id), spi_bitrate), update_rate_hz, io_complete_sink, board_capabilities);
io_thread.start();
}
示例6: accelerometer
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Create a new {@link ThreeAxisAccelerometer} for the ADXL345 with the desired range using the specified SPI port.
*
* @param port the SPI port used by the accelerometer
* @param range the desired range of the accelerometer
* @return the accelerometer; never null
*/
public static ThreeAxisAccelerometer accelerometer(SPI.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_SPI accel = new ADXL345_SPI(port, range);
return ThreeAxisAccelerometer.create(accel::getX, accel::getY, accel::getZ);
}
示例7: TurtleFakeNavX
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Create NavX with specified SPI port (MXP only)
* @param spiPort
*/
public TurtleFakeNavX(SPI.Port spiPort) {
this();
}
示例8: TurtleNavX
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Create NavX with specified SPI port (MXP only)
*
* @param spiPort
*/
public TurtleNavX(SPI.Port spiPort) {
navX = new AHRS(spiPort);
registerCallback(dataSubscriber, this);
}
示例9: gyroscope
import edu.wpi.first.wpilibj.SPI; //导入方法依赖的package包/类
/**
* Create a {@link Gyroscope} that uses a WPILib {@link ADXRS450_Gyro} on the specified SPI bus port.
*
* @param port the port on SPI bus into which the digital ADXRS450 gyroscope is connected
* @return the gyroscope; never null
*/
public static Gyroscope gyroscope(SPI.Port port) {
return gyroscope(new ADXRS450_Gyro(port));
}