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


Java GpioPinDigitalStateChangeEvent.getState方法代码示例

本文整理汇总了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();
        }
    }

}
 
开发者ID:tsoglani,项目名称:SpeechRaspberrySmartHouse,代码行数:23,代码来源:SH.java

示例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 + ".");
}
 
开发者ID:onebeartoe,项目名称:photorama,代码行数:17,代码来源:PhotoBoothButtonTester.java

示例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);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:12,代码来源:Mcp23017Handler.java

示例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;                    
            }
        }
    }
}
 
开发者ID:onebeartoe,项目名称:photorama,代码行数:29,代码来源:FootPedalServlet.java

示例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);
        }
    }
}
 
开发者ID:The-Retired-Programmer,项目名称:gpssurvey,代码行数:41,代码来源:IrListener.java

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

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


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