本文整理汇总了Java中com.pi4j.io.spi.SpiFactory类的典型用法代码示例。如果您正苦于以下问题:Java SpiFactory类的具体用法?Java SpiFactory怎么用?Java SpiFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpiFactory类属于com.pi4j.io.spi包,在下文中一共展示了SpiFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: BMP280
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public BMP280(Protocol protocol, int deviceID, int i2cBusID) throws Exception {
this.protocol = protocol;
if(protocol == Protocol.I2C) {
I2Cbus = I2CFactory.getInstance(i2cBusID);
I2Cdevice = I2Cbus.getDevice(deviceID);
}
else if(protocol == Protocol.SPI) {
/* Set SPI to run default speed (1Mhz) in default mode (Mode 0) */
SPIdevice = SpiFactory.getInstance(SpiChannel.CS0, SpiDevice.DEFAULT_SPI_SPEED, SpiDevice.DEFAULT_SPI_MODE);
}
else {
throw new Exception("Invalid protocol set: " + protocol);
}
loadCurrentConfigSettingsFromDevice();
loadCompensationValues();
}
开发者ID:whitestripes,项目名称:BMP280,代码行数:19,代码来源:BMP280.java
示例2: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
/**
* Sample SPI Program
*
* @param args (none)
* @throws InterruptedException
* @throws IOException
*/
public static void main(String args[]) throws InterruptedException, IOException {
// print program title/header
console.title("<-- The Pi4J Project -->", "SPI test program using MCP3004/MCP3008 AtoD Chip");
// allow for user to exit program using CTRL-C
console.promptForExit();
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP3004/MCP3008 AtoD Chip.
//
// Please make sure the SPI is enabled on your Raspberry Pi via the
// raspi-config utility under the advanced menu option.
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP3004/MCP3008 chip:
// http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// continue running program until user exits using CTRL-C
while(console.isRunning()) {
read();
Thread.sleep(1000);
}
console.emptyLine();
}
开发者ID:uwigem,项目名称:uwigem2017,代码行数:40,代码来源:SpiExample.java
示例3: MFRC522
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public MFRC522(GpioController gpio,Pin pinNRSTPD,SpiChannel channel) throws IOException {
this.pinNRSTPD = pinNRSTPD;
this.spiChannel = channel;
spi = SpiFactory.getInstance(spiChannel,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
rstOut = gpio.provisionDigitalOutputPin(pinNRSTPD, "RC522RST");
rstOut.setShutdownOptions(true, PinState.HIGH, PinPullResistance.OFF);
rstOut.high();
init();
}
开发者ID:gustavohbf,项目名称:robotoy,代码行数:13,代码来源:MFRC522.java
示例4: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException {
//
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP23S17 I/O Expander.
//
// Please note the following command are required to enable the SPI driver on
// your Raspberry Pi:
// > sudo modprobe spi_bcm2708
// > sudo chown `id -u`.`id -g` /dev/spidev0.*
//
// this source code was adapted from:
// https://github.com/thomasmacpherson/piface/blob/master/python/piface/pfio.py
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP23S17 chip:
// http://ww1.microchip.com/downloads/en/devicedoc/21952b.pdf
System.out.println("<--Pi4J--> SPI test program using MCP3002 AtoD Chip");
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// infinite loop
while(true) {
read();
Thread.sleep(1000);
}
}
开发者ID:iot-labs,项目名称:communication,代码行数:34,代码来源:SpiExample.java
示例5: MCP2515
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public MCP2515(NetworkManager manager, SPIChannel channel, SPIMode mode, int speed) throws IOException {
SpiChannel c = null;
SpiMode m = null;
this.manager = manager;
switch(channel) {
case CE0:
c = SpiChannel.CS0;
break;
case CE1:
c = SpiChannel.CS1;
break;
}
switch(mode) {
case MODE0:
m = SpiMode.MODE_0;
break;
case MODE1:
m = SpiMode.MODE_1;
break;
case MODE2:
m = SpiMode.MODE_2;
break;
case MODE3:
m = SpiMode.MODE_3;
break;
}
driver = SpiFactory.getInstance(c, speed, m);
}
开发者ID:pglotfel,项目名称:ithinkican,代码行数:34,代码来源:MCP2515.java
示例6: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException, PlatformAlreadyAssignedException {
// ####################################################################
//
// since we are not using the default Raspberry Pi platform, we should
// explicitly assign the platform as the OrangePi platform.
//
// ####################################################################
PlatformManager.setPlatform(Platform.ORANGEPI);
// print program title/header
console.title("<-- The Pi4J Project -->", "SPI test program using MCP3004/MCP3008 AtoD Chip");
// allow for user to exit program using CTRL-C
console.promptForExit();
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP3004/MCP3008 AtoD Chip.
//
// Please note the following command are required to enable the SPI driver on
// your BananaPro:
// > sudo modprobe spi-sun7i
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP3004/MCP3008 chip:
// http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// continue running program until user exits using CTRL-C
while(console.isRunning()) {
read();
Thread.sleep(1000);
}
console.emptyLine();
}
开发者ID:uwigem,项目名称:uwigem2017,代码行数:43,代码来源:SpiExample.java
示例7: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException, PlatformAlreadyAssignedException {
// ####################################################################
//
// !!!!! ATTENTION !!!!! ALL GPIO PINS ON ODROID-XU4 ARE 1.8VDC.
// INCLUDING THE SPI PINS
//
// THIS MEANS THAT YOU MUST USE A LEVEL SHIFTER IF USING WITH A 3.3VDC/5VDC CIRCUIT.
// YOU CAN USE THE OPTIONAL ODROID XU4-SHIFTER SHIELD TO PERFORM THE LEVEL SHIFTING:
// http://www.hardkernel.com/main/products/prdt_info.php?g_code=G143556253995
//
// ####################################################################
// ####################################################################
//
// since we are not using the default Raspberry Pi platform, we should
// explicitly assign the platform as the Odroid platform.
//
// ####################################################################
PlatformManager.setPlatform(Platform.ODROID);
// print program title/header
console.title("<-- The Pi4J Project -->", "SPI test program using MCP3004/MCP3008 AtoD Chip");
// allow for user to exit program using CTRL-C
console.promptForExit();
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP3004/MCP3008 AtoD Chip.
//
// Please note the following command are required to enable the SPI driver on
// your Odroid C1/C1+:
// > sudo modprobe spicc
// > sudo modprobe spidev
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP3004/MCP3008 chip:
// http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// !! ATTENTION !! The Odroid implementation of WiringPi does not currently support
// SPI modes other than 0 (zero).
// continue running program until user exits using CTRL-C
while(console.isRunning()) {
read();
Thread.sleep(1000);
}
console.emptyLine();
}
开发者ID:uwigem,项目名称:uwigem2017,代码行数:56,代码来源:SpiExample.java
示例8: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException, PlatformAlreadyAssignedException {
// ####################################################################
//
// since we are not using the default Raspberry Pi platform, we should
// explicitly assign the platform as the Odroid platform.
//
// ####################################################################
PlatformManager.setPlatform(Platform.ODROID);
// print program title/header
console.title("<-- The Pi4J Project -->", "SPI test program using MCP3004/MCP3008 AtoD Chip");
// allow for user to exit program using CTRL-C
console.promptForExit();
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP3004/MCP3008 AtoD Chip.
//
// Please note the following command are required to enable the SPI driver on
// your Odroid C1/C1+:
// > sudo modprobe spicc
// > sudo modprobe spidev
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP3004/MCP3008 chip:
// http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// !! ATTENTION !! The Odroid implementation of WiringPi does not currently support
// SPI modes other than 0 (zero).
// continue running program until user exits using CTRL-C
while(console.isRunning()) {
read();
Thread.sleep(1000);
}
console.emptyLine();
}
开发者ID:uwigem,项目名称:uwigem2017,代码行数:45,代码来源:SpiExample.java
示例9: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException, PlatformAlreadyAssignedException {
// ####################################################################
//
// since we are not using the default Raspberry Pi platform, we should
// explicitly assign the platform as the BananaPro platform.
//
// ####################################################################
PlatformManager.setPlatform(Platform.BANANAPRO);
// print program title/header
console.title("<-- The Pi4J Project -->", "SPI test program using MCP3004/MCP3008 AtoD Chip");
// allow for user to exit program using CTRL-C
console.promptForExit();
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP3004/MCP3008 AtoD Chip.
//
// Please note the following command are required to enable the SPI driver on
// your BananaPro:
// > sudo modprobe spi-sun7i
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP3004/MCP3008 chip:
// http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// continue running program until user exits using CTRL-C
while(console.isRunning()) {
read();
Thread.sleep(1000);
}
console.emptyLine();
}
开发者ID:uwigem,项目名称:uwigem2017,代码行数:43,代码来源:SpiExample.java
示例10: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException, IOException, PlatformAlreadyAssignedException {
// ####################################################################
//
// since we are not using the default Raspberry Pi platform, we should
// explicitly assign the platform as the BananaPi platform.
//
// ####################################################################
PlatformManager.setPlatform(Platform.BANANAPI);
// print program title/header
console.title("<-- The Pi4J Project -->", "SPI test program using MCP3004/MCP3008 AtoD Chip");
// allow for user to exit program using CTRL-C
console.promptForExit();
// This SPI example is using the Pi4J SPI interface to communicate with
// the SPI hardware interface connected to a MCP3004/MCP3008 AtoD Chip.
//
// Please note the following command are required to enable the SPI driver on
// your BananaPi:
// > sudo modprobe spi-sun7i
//
// see this blog post for additional details on SPI and WiringPi
// http://wiringpi.com/reference/spi-library/
//
// see the link below for the data sheet on the MCP3004/MCP3008 chip:
// http://ww1.microchip.com/downloads/en/DeviceDoc/21294E.pdf
// create SPI object instance for SPI for communication
spi = SpiFactory.getInstance(SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE); // default spi mode 0
// continue running program until user exits using CTRL-C
while(console.isRunning()) {
read();
Thread.sleep(1000);
}
console.emptyLine();
}
开发者ID:uwigem,项目名称:uwigem2017,代码行数:42,代码来源:SpiExample.java
示例11: main
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
printCommands();
GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING));
GpioPinDigitalOutput led = GpioFactory.getInstance().provisionDigitalOutputPin(RaspiPin.GPIO_17);
led.setState(PinState.HIGH);
// Initialize SPI and I2C bus:
I2CBus iic1 = I2CFactory.getInstance(I2CBus.BUS_1);
SpiDevice spi0 = SpiFactory.getInstance(
SpiChannel.CS0,
SpiDevice.DEFAULT_SPI_SPEED, // default spi speed 1 MHz
SpiDevice.DEFAULT_SPI_MODE);
rover = new Rover();
// create the concrete instance of the compass chip:
compass = new HMC5883L(iic1.getDevice(0x1e), HMC5883LConfig.Default);
adc = new Mcp3008(spi0);
ir = new Sharp0A41SK(adc, (short) 0);
roverTest();
led.setState(PinState.LOW);
rover.end();
iic1.close();
}
开发者ID:gaelblondelle,项目名称:PSysRoverInitialContrib,代码行数:32,代码来源:RoverRunner.java
示例12: initSpi
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
/**
* Init the SPI controller using Pi4J bindings
* @param spiChannel See https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
* @param spiSpeed speed in hz, see https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
* @param spiMode see https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
* @throws IOException If can't open SPI (not a raspi or not running sudo)
*/
public static void initSpi(SpiChannel spiChannel, int spiSpeed, SpiMode spiMode) throws IOException {
spi = SpiFactory.getInstance(spiChannel, spiSpeed, spiMode);
}
开发者ID:dlopuch,项目名称:apa102-java-rpi,代码行数:11,代码来源:Apa102Output.java
示例13: Adxl362
import com.pi4j.io.spi.SpiFactory; //导入依赖的package包/类
/**
* Creates a new SpiDevice instance
* @param channel - SPI channels are CHANNEL_0 (CS0), CHANNEL_1 (CS1)
* @param frequencyInHz - This will vary according to the peripheral to be interfaced, default should be 1MHz
* @param mode - Modes are MODE_0, MODE_1, MODE_2, MODE_3
* @throws IOException
*/
public Adxl362(SpiChannel channel, int frequencyInHz, SpiMode mode) throws IOException {
spiDevice = SpiFactory.getInstance(channel, frequencyInHz, mode);
}
开发者ID:vishal-android-freak,项目名称:ADXL362-Interfacing-Library,代码行数:12,代码来源:Adxl362.java
注:本文中的com.pi4j.io.spi.SpiFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论