本文整理汇总了Java中com.pi4j.io.gpio.GpioPinDigitalMultipurpose类的典型用法代码示例。如果您正苦于以下问题:Java GpioPinDigitalMultipurpose类的具体用法?Java GpioPinDigitalMultipurpose怎么用?Java GpioPinDigitalMultipurpose使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GpioPinDigitalMultipurpose类属于com.pi4j.io.gpio包,在下文中一共展示了GpioPinDigitalMultipurpose类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: digitalWrite
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public static final void digitalWrite(int pinNum, boolean value) {
GpioPinDigitalMultipurpose pin = pins[pinNum-1];
if (pin == null) {
pinMode(pinNum,value ? OUTPUT_HIGH : OUTPUT_LOW);
} else {
if (value) {
pin.high();
} else {
pin.low();
}
}
}
示例2: digitalRead
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public static final boolean digitalRead(int pinNum) {
GpioPinDigitalMultipurpose pin = pins[pinNum-1];
if (pin == null) {
pinMode(pinNum,INPUT);
return pins[pinNum-1].getState().isHigh();
} else {
return pin.getState().isHigh();
}
}
示例3: setUp
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
@Before
public void setUp(){
PowerMockito.mockStatic(Gpio.class);
PowerMockito.mockStatic(TimeUnit.class);
mocked_ADC_CS = mock(GpioPinDigitalOutput.class);
mocked_ADC_CLK = mock(GpioPinDigitalOutput.class);
mocked_ADC_DIO = mock(GpioPinDigitalMultipurpose.class);
sketch = new Ex02_LinearHall(mocked_gpioController);
}
示例4: setUp
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
@Before
@Category(FastTest.class)
public void setUp(){
PowerMockito.mockStatic(Gpio.class);
PowerMockito.mockStatic(TimeUnit.class);
mocked_ADC_CS = mock(GpioPinDigitalOutput.class);
mocked_ADC_CLK = mock(GpioPinDigitalOutput.class);
mocked_ADC_DIO = mock(GpioPinDigitalMultipurpose.class);
sketch = new Ex02_03_LinearHall(mocked_gpioController);
}
示例5: initialize
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
@Before
public void initialize() {
mExecutor = new ExecutorForTesting();
int[] mapping = new int[]{4};
mGpioController = mock(GpioController.class);
mPin = mock(GpioPinDigitalMultipurpose.class);
when(mGpioController.provisionDigitalMultipurposePin(any(Pin.class), any(PinMode.class)))
.thenReturn(mPin);
mPhotoCellController =
new PhotoCellControllerImpl(mapping, mGpioController, mExecutor, 0 /* Don't sleep */);
}
示例6: main
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
System.out.println("<--Pi4J--> GPIO Multipurpose Pin Example ... started.");
// create gpio controller
final GpioController gpio = GpioFactory.getInstance();
// provision gpio pin #02 as an multi-purpose pin configured as an input
// pin by default with its internal pull down resistor enabled
final GpioPinDigitalMultipurpose pin = gpio.provisionDigitalMultipurposePin(RaspiPin.GPIO_02, PinMode.DIGITAL_INPUT, PinPullResistance.PULL_DOWN);
// create and register gpio pin listener
pin.addListener(new GpioPinListenerDigital() {
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
// display pin state on console
System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = " + event.getState());
}
});
System.out.println(" ... complete the GPIO #02 circuit and see the listener feedback here in the console.");
// keep program running until user aborts (CTRL-C)
while(true){
Thread.sleep(5000);
// here we want to control the multi-purpose GPIO pin
// so we must reconfigure the pin mode first
pin.setMode(PinMode.DIGITAL_OUTPUT);
// perform the pin output operation
System.out.println(" --> GPIO PIN - RECONFIGURED AS OUPUT PIN");
pin.pulse(1000, true);
// reconfigure the pin back to an input pin
pin.setMode(PinMode.DIGITAL_INPUT);
System.out.println(" --> GPIO PIN - RECONFIGURED AS INPUT PIN");
}
// stop all GPIO activity/threads by shutting down the GPIO controller
// (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
// gpio.shutdown(); <--- implement this method call if you wish to terminate the Pi4J GPIO controller
}
示例7: provisionDigitalMultipurposePin
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
@Override
public GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, String name, PinMode mode) {
return delegate.provisionDigitalMultipurposePin(provider, pin, name, mode);
}
示例8: main
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
System.out.println("<--Pi4J--> GPIO Multipurpose Pin Example ... started.");
// create gpio controller
final GpioController gpio = GpioFactory.getInstance();
// provision gpio pin #02 as an multi-purpose pin configured as an input
// pin by default with its internal pull down resistor enabled
final GpioPinDigitalMultipurpose pin = gpio.provisionDigitalMultipurposePin(RaspiPin.GPIO_02, PinMode.DIGITAL_INPUT, PinPullResistance.PULL_DOWN);
// create and register gpio pin listener
pin.addListener(new GpioPinListenerDigital() {
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
// display pin state on console
System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = " + event.getState());
}
});
System.out.println(" ... complete the GPIO #02 circuit and see the listener feedback here in the console.");
// keep program running until user aborts (CTRL-C)
for (;;) {
Thread.sleep(5000);
// here we want to control the multi-purpose GPIO pin
// so we must reconfigure the pin mode first
pin.setMode(PinMode.DIGITAL_OUTPUT);
// perform the pin output operation
System.out.println(" --> GPIO PIN - RECONFIGURED AS OUPUT PIN");
pin.pulse(1000, true);
// reconfigure the pin back to an input pin
pin.setMode(PinMode.DIGITAL_INPUT);
System.out.println(" --> GPIO PIN - RECONFIGURED AS INPUT PIN");
}
// stop all GPIO activity/threads by shutting down the GPIO controller
// (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
// gpio.shutdown(); <--- implement this method call if you wish to terminate the Pi4J GPIO controller
}
示例9: setGpioPin
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public void setGpioPin(GpioPinDigitalMultipurpose b) {
gpioPin = b;
}
示例10: getGpioPin
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public GpioPinDigitalMultipurpose getGpioPin() {
return gpioPin;
}
示例11: testGPIOOutput
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public void testGPIOOutput() {
GpioPinDigitalMultipurpose pin = gpio.provisionDigitalMultipurposePin(RaspiPin.GPIO_02, PinMode.DIGITAL_INPUT, PinPullResistance.PULL_DOWN);
log.info("Pin: {}", pin);
}
示例12: provisionDigitalMultipurposePin
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, String name, PinMode mode,
PinPullResistance resistance) {
return gpioController.provisionDigitalMultipurposePin(provider, pin, name, mode, resistance);
}
示例13: provisionDigitalMultipurposePin
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
@Override
public GpioPinDigitalMultipurpose provisionDigitalMultipurposePin(GpioProvider provider, Pin pin, String name, PinMode mode,
PinPullResistance resistance) {
return null;
}
示例14: testGPIOOutput
import com.pi4j.io.gpio.GpioPinDigitalMultipurpose; //导入依赖的package包/类
public void testGPIOOutput() {
GpioPinDigitalMultipurpose pin = gpio.provisionDigitalMultipurposePin(RaspiPin.GPIO_02, PinMode.DIGITAL_INPUT, PinPullResistance.PULL_DOWN);
}