本文整理汇总了Java中com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent.getState方法的典型用法代码示例。如果您正苦于以下问题:Java GpioPinDigitalStateChangeEvent.getState方法的具体用法?Java GpioPinDigitalStateChangeEvent.getState怎么用?Java GpioPinDigitalStateChangeEvent.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent
的用法示例。
在下文中一共展示了GpioPinDigitalStateChangeEvent.getState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
// display pin state on console
String state = null;
if (event.getState() == PinState.HIGH) {
state = "on";
} else if (event.getState() == PinState.LOW) {
state = "off";
} else {
System.out.println("problem state = " + state);
return;
}
for (int i = 0; i < addresses.size(); i++) {
try {
sendData(command + " " + state, addresses.get(i), port);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
示例2: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event)
{
String s;
PinState state = event.getState();
if(state == PinState.LOW)
{
s = "low: ";
}
else
{
s = "high: ";
}
System.out.println("*Photo booth button pin state changed to " + s + state + ".");
}
示例3: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
GpioPin pin = event.getPin();
OpenClosedType state = OpenClosedType.CLOSED;
if (event.getState() == PinState.LOW) {
state = OpenClosedType.OPEN;
}
ChannelUID channelForPin = pinStateHolder.getChannelForInputPin((GpioPinDigitalInput) pin);
logger.debug("updating channel {} with state {}", channelForPin, state);
updateState(channelForPin, state);
}
示例4: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event)
{
PinState state = event.getState();
if(state == PinState.HIGH)
{
if(takingSnapshot)
{
String message = "The foot pedal was pressed, while already taking a photo.";
System.out.println(message);
}
else
{
ServletContext servletContext = getServletContext();
Camera camera = (Camera) servletContext.getAttribute(CAMERA_KEY);
if(camera == null)
{
System.err.println("The foot pedal servlet did not find the camera.");
}
else
{
takingSnapshot = true;
camera.takeSnapshot();
takingSnapshot = false;
}
}
}
}
示例5: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent gpdsce) {
PinState pinstate = gpdsce.getState();
if (pinstate.isLow()) {
try {
// interrupt is a setting int pin to low (0)
Reporting.report("IR Listener", 3, "Interrupt raised");
byte[] message = new byte[2];
int zcount = device.read(message, 0, 2); // get the reporting message
if (zcount == 2) {
int dev = message[0];
int key = message[1];
switch (dev) {
case INTERRUPT_DEVICE:
Reporting.report("IR Listener", 3, "No message on 0x60");
break;
case BUTTON_DEVICE:
if (key == POWERDOWN_BUTTON) {
Reporting.report("IR Listener", 3, "Received Powerdown button");
MDTService.sendMessage("Controller", Command.BUTTON, Button.POWERDOWN);
}
break;
case IR_DEVICE:
if (key > 0) {
Button b = MAPKEY2BUTTON[key - 1];
Reporting.report("IR Listener", 3, "Received IR message: " + b.toString());
MDTService.sendMessage("Controller", Command.BUTTON, b);
}
break;
default:
throw new IOException("illegal i2c reporting device - " + message[0]);
}
} else {
throw new IOException("illegal i2c message length");
}
} catch (IOException ex) {
MDTService.reportExceptionAndExit(ex, Exitcode.EXIT_PROGFAIL);
}
}
}
示例6: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
/**
* @{inheritDoc}
*/
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
GpioPin pin = event.getPin();
OpenClosedType state = OpenClosedType.CLOSED; // Assume we are high...
if (event.getState() == PinState.LOW) { // To err is human...
state = OpenClosedType.OPEN;
}
this.eventPublisher.postUpdate(pin.getName(), state);
logger.debug("GPIO pin state change: {} = {}", pin, state);
}
示例7: handleGpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; //导入方法依赖的package包/类
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent pEvent) {
int headerPinNumber = mHeader.getHeaderPin(pEvent.getPin().getPin());
PinState state = pEvent.getState();
sendMessage(headerPinNumber, state);
}