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


Java SPI类代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.SPI的典型用法代码示例。如果您正苦于以下问题:Java SPI类的具体用法?Java SPI怎么用?Java SPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: NavX

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public NavX() {
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); // Use SPI!!!
         //ahrs = new AHRS(I2C.Port.kMXP);
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
开发者ID:cyborgs3335,项目名称:STEAMworks,代码行数:20,代码来源:NavX.java

示例2: IMU

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public IMU() {
 	try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP);
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:19,代码来源:IMU.java

示例3: 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

示例4: 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

示例5: SpatialAwarenessSubsystem

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public SpatialAwarenessSubsystem() {
  super("SpatialAwarenessSubsystem");

  cameraServer = CameraServer.getInstance();
  gearCamera = cameraServer.startAutomaticCapture(0);
  gearCamera.setResolution(IMG_WIDTH, IMG_HEIGHT);
  gearCamera.setFPS(30);
  gearCamera.setBrightness(7);
  gearCamera.setExposureManual(30);
  gearVideo = cameraServer.getVideo(gearCamera);

  visionProcessing = new VisionProcessing();

  leftUltrasonic = new AnalogInput(RobotMap.ANALOG_ULTRASONIC_LEFT);
  rightUltrasonic = new AnalogInput(RobotMap.ANALOG_ULTRASONIC_RIGHT);

  leftUltrasonicKalman = new SimpleKalman(1.4d, 64d, leftUltrasonic.getAverageVoltage() * ULTRASONIC_VOLTS_TO_METERS);
  rightUltrasonicKalman = new SimpleKalman(1.4d, 64d, rightUltrasonic.getAverageVoltage() * ULTRASONIC_VOLTS_TO_METERS);

  navX = new AHRS(SPI.Port.kMXP);

  System.out.println("SpatialAwarenessSubsystem constructor finished");
}
 
开发者ID:FRC-1294,项目名称:frc2017,代码行数:24,代码来源:SpatialAwarenessSubsystem.java

示例6: initialize

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public static void initialize()
{
	if (!initialized) {
			
		System.out.println("NavXSensor::initialize() called...");
		
		try {
			ahrs = new AHRS(SPI.Port.kMXP);     
		} catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
        }

		reset();
		
		initialized = true;
	}
}
 
开发者ID:MTHSRoboticsClub,项目名称:FRC-2017,代码行数:18,代码来源:NavXSensor.java

示例7: Robot

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public Robot() {
     myRobot = new RobotDrive(0, 1);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:22,代码来源:Robot.java

示例8: Robot

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public Robot() {
     myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
     		frontRightChannel, rearRightChannel);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:23,代码来源:Robot.java

示例9: Robot

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public Robot() {
    myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
    		frontRightChannel, rearRightChannel);
    myRobot.setExpiration(0.1);
    stick = new Joystick(0);
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
  	  ahrs = new AHRS(SPI.Port.kMXP); 
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:23,代码来源:Robot.java

示例10: Robot

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public Robot() {
    myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel, 
		 frontRightChannel, rearRightChannel);
    myRobot.setExpiration(0.1);
    stick = new Joystick(0);
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
        ahrs = new AHRS(SPI.Port.kMXP); 
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:23,代码来源:Robot.java

示例11: Robot

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public Robot() {
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP);
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:20,代码来源:Robot.java

示例12: robotInit

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public void robotInit() {

	// Create subsystems
	drive = new Drive();
	intake = new Intake();
	arm = new Arm();
	shooter = new Shooter();
	hanger = new Hanger();

	oi = new OI();

	// Create motion profiles
	crossLowBar = new Profile(AutoMap.crossLowBar);
	reach = new Profile(AutoMap.reach);
	toShoot = new Profile(AutoMap.toShoot);
	toLowGoal = new Profile(AutoMap.toLowGoal);

	// Pick an auto
	chooser = new SendableChooser();
	chooser.addDefault("Do Nothing", new DoNothing());
	chooser.addObject("Low Bar", new LowBarRawtonomous());
	chooser.addObject("Low Bar (profile)", new CrossLowBar(crossLowBar));
	chooser.addObject("Reach", new Reach(reach));
	chooser.addObject("Forward Rawto", new ForwardRawtonomous());
	chooser.addObject("Backward Rawto", new BackwardRawtonomous());
	chooser.addObject("Shoot", new AutoShoot());
	SmartDashboard.putData("Auto mode", chooser);

	// Start camera stream
	camera = new USBCamera();
	server = CameraServer.getInstance();
	server.setQuality(40);
	server.startAutomaticCapture(camera);

	// Start compressor
	compressor = new Compressor();
	compressor.start();

	navx = new AHRS(SPI.Port.kMXP);
    }
 
开发者ID:Team236,项目名称:2016-Robot-Final,代码行数:41,代码来源:Robot.java

示例13: 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

示例14: DotStarsLEDStrip

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
/**
 * Constructor for led strip class
 * 
 * @param numLEDs number of LED's in the total strip.
 */
public DotStarsLEDStrip(int numLEDs) {

    // Number of bytes in color buffer needed - each LED has 4 bytes (1 brightness, then 1 for
    // RGB each),
    // plus the start and end frame.
    num_leds = numLEDs;
    int num_bytes_for_strip = 4 * numLEDs + startFrame.length + endFrame.length;
    endFrameOffset = 4 * numLEDs + startFrame.length;

    // Initialize color buffer
    ledBuffer = new byte[num_bytes_for_strip];

    // Write in the start/end buffers
    for (int i = 0; i < startFrame.length; i++)
        ledBuffer[i] = startFrame[i];
    for (int i = 0; i < endFrame.length; i++)
        ledBuffer[i + endFrameOffset] = endFrame[i];

    // mark buffer as not-yet-written-to-the-LEDs
    newBuffer = true;

    // Initialize SPI coms on the Offboard port
    spi = new SPI(SPI.Port.kMXP);
    spi.setMSBFirst();
    spi.setClockActiveLow();
    spi.setClockRate(SPI_CLK_RATE);
    spi.setSampleDataOnFalling();
    timerThread = new java.util.Timer("DotStar LED Strip Control");
    timerThread.schedule(new DotStarsTask(this), (long) (m_update_period_ms), (long) (m_update_period_ms));

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

示例15: Sensors

import edu.wpi.first.wpilibj.SPI; //导入依赖的package包/类
public Sensors() {
	ahrs = new AHRS(SPI.Port.kMXP);
	ahrs.reset();
	intakeLidar = new AnalogInput(RobotMap.INTAKE_LIDAR_PORT);
	longLidar = new AnalogInput(RobotMap.LONG_LIDAR_PORT);
	table = NetworkTable.getTable("SmartDashboard");
}
 
开发者ID:SouthEugeneRoboticsTeam,项目名称:Stronghold-2016,代码行数:8,代码来源:Sensors.java


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