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


Java Gpio.wiringPiISR方法代码示例

本文整理汇总了Java中com.pi4j.wiringpi.Gpio.wiringPiISR方法的典型用法代码示例。如果您正苦于以下问题:Java Gpio.wiringPiISR方法的具体用法?Java Gpio.wiringPiISR怎么用?Java Gpio.wiringPiISR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.pi4j.wiringpi.Gpio的用法示例。


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

示例1: test

import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
public void test(int gpio) {
	int status = Gpio.wiringPiSetupGpio();
	if (status != 0) {
		throw new RuntimeException("Error initialising wiringPi: " + status);
	}
	Gpio.pinMode(gpio, Gpio.INPUT);
	Gpio.pullUpDnControl(gpio, Gpio.PUD_UP);
	int delay = 20;
	System.out.println("Waiting " + delay + "s for events..., thread name=" + Thread.currentThread().getName());
	if (Gpio.wiringPiISR(gpio, Gpio.INT_EDGE_BOTH, this) != 1) {
		System.out.println("Error in wiringPiISR");
	} else {
		System.out.println("Sleeping for " + delay + "s");
		SleepUtil.sleepSeconds(delay);
	}
	
	GpioUtil.unexport(gpio);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:19,代码来源:ButtonTestWiringPi.java

示例2: gpioIsrSetup

import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
private static void gpioIsrSetup() {
    wiringPiSetup();
    
    Gpio.pinMode(btnPin, Gpio.INPUT);
    Gpio.pullUpDnControl(btnPin, Gpio.PUD_UP);
    
    Gpio.pinMode(ledPin, Gpio.OUTPUT);
    Gpio.pullUpDnControl(ledPin, Gpio.PUD_DOWN);
    Gpio.digitalWrite(ledPin, false);
    
    Gpio.wiringPiISR(btnPin, Gpio.INT_EDGE_FALLING, new GpioInterruptCallback() {
        private final long debounceTime = 200;
        @Override
        public void callback(int pin) {
            Gpio.delay(10);
            long currentTime = System.currentTimeMillis();
            if(currentTime > lastTime+debounceTime){
                Gpio.digitalWrite(ledPin, Gpio.digitalRead(ledPin)==0?1:0);                
                logger.debug("GPIO PIN 0 detected. Led state: "+Gpio.digitalRead(ledPin));
            }else{
                logger.debug("Discard event "+currentTime);
            }              
            lastTime=currentTime;
        }
    });
}
 
开发者ID:marcandreuf,项目名称:sunfounder-sensors-raspi-4j,代码行数:27,代码来源:Ex13_ButtonISR.java

示例3: enableListener

import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
@Override
public void enableListener() {
	// TODO Validate that wiringPi actually works this way, i.e. supports separate callbacks for rising and falling
	// Note it looks easier to use GpioInterrupt but this will be less efficient
	// due to its use of Vectors to support multiple listeners and cloning on every event
	Gpio.wiringPiISR(gpio, edge, this);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:8,代码来源:WiringPiDigitalInputDevice.java

示例4: setup

import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
@Override
protected void setup(String[] args) {
    wiringPiSetup();
    if(Gpio.wiringPiISR(isrPin, Gpio.INT_EDGE_FALLING, new MyISR()) == -1){
        logger.error("Setup ISR failed !");
        throw new ExceptionInInitializerError("Setup ISR failed !");
    }
    logger.debug("Infrared receiver sensor ready!");           
}
 
开发者ID:marcandreuf,项目名称:sunfounder-sensors-raspi-4j,代码行数:10,代码来源:Ex29_IrRecv.java

示例5: disableListener

import com.pi4j.wiringpi.Gpio; //导入方法依赖的package包/类
@Override
public void disableListener() {
	// TODO Is this correct?
	Gpio.wiringPiISR(gpio, edge, null);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:6,代码来源:WiringPiDigitalInputDevice.java


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