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


Java SPI.Port方法代码示例

本文整理汇总了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);
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:29,代码来源:ADXRS453_Gyro.java

示例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();


}
 
开发者ID:RobotCasserole1736,项目名称:CasseroleLib,代码行数:29,代码来源:ADXRS453_Gyro.java

示例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;
    }
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:18,代码来源:MappedAHRS.java

示例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();
}
 
开发者ID:nerdherd,项目名称:Stronghold2016,代码行数:22,代码来源:AHRS.java

示例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();
}
 
开发者ID:FRC4131,项目名称:FRCStronghold2016,代码行数:29,代码来源:AHRS.java

示例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);
}
 
开发者ID:strongback,项目名称:strongback-java,代码行数:14,代码来源:Hardware.java

示例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();
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:8,代码来源:TurtleFakeNavX.java

示例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);
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:10,代码来源:TurtleNavX.java

示例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));
}
 
开发者ID:strongback,项目名称:strongback-java,代码行数:10,代码来源:Hardware.java


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