• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GpioUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.pi4j.wiringpi.GpioUtil的典型用法代码示例。如果您正苦于以下问题:Java GpioUtil类的具体用法?Java GpioUtil怎么用?Java GpioUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GpioUtil类属于com.pi4j.wiringpi包,在下文中一共展示了GpioUtil类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test

import com.pi4j.wiringpi.GpioUtil; //导入依赖的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: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String[] args) throws PlatformAlreadyAssignedException {

        // Default platform is Raspberry -> Explicit assign the target platform
        // TODO : Use PI4J_PLATFORM env variable ??
        PlatformManager.setPlatform(Platform.ODROID);

        // PI4J Init
        if (Gpio.wiringPiSetup() == -1) {
            log.error(" ==>> GPIO SETUP FAILED");
            return;
        }

        // GPIO 1 init as Output
        GpioUtil.export(1, GpioUtil.DIRECTION_OUT);
        Gpio.pinMode (1, Gpio.OUTPUT) ;
        // Force low state for GPIO 1
        Gpio.digitalWrite(1, Gpio.LOW);

        // Vertx event timer
        Vertx.vertx().setPeriodic(1000, l -> {
            // Blink led every seconds
            if (Gpio.digitalRead(1) != Gpio.LOW) {
                log.info("Switch off ...");
                Gpio.digitalWrite(1, Gpio.LOW);
            }
            else {
                log.info("Switch on ...");
                Gpio.digitalWrite(1, Gpio.HIGH);
            }
        });

    }
 
开发者ID:lhuet,项目名称:vertxOnRpiAndOdroid,代码行数:33,代码来源:VertxHelloWorld.java


示例3: WiringPiDigitalOutputDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
WiringPiDigitalOutputDevice(String key, DeviceFactoryInterface deviceFactory, int gpio, boolean initialValue) throws RuntimeIOException {
	super(key, deviceFactory);
	
	this.gpio = gpio;
	try {
		if (GpioUtil.isExported(gpio)) {
			GpioUtil.setDirection(gpio, initialValue ? GpioUtil.DIRECTION_HIGH : GpioUtil.DIRECTION_LOW);
		} else {
			GpioUtil.export(gpio, initialValue ? GpioUtil.DIRECTION_HIGH : GpioUtil.DIRECTION_LOW);
		}
		Gpio.pinMode(gpio, Gpio.OUTPUT);
	} catch (RuntimeException re) {
		throw new RuntimeIOException(re);
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:16,代码来源:WiringPiDigitalOutputDevice.java


示例4: WiringPiPwmOutputDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
WiringPiPwmOutputDevice(String key, DeviceFactoryInterface deviceFactory, PwmType pwmType,
		int range, int gpio, float initialValue) throws RuntimeIOException {
	super(key, deviceFactory);
	
	this.pwmType = pwmType;
	this.gpio = gpio;
	this.value = initialValue;
	this.range = range;
	
	switch (pwmType) {
	case HARDWARE:
		if (GpioUtil.isExported(gpio)) {
			GpioUtil.setDirection(gpio, GpioUtil.DIRECTION_OUT);
		} else {
			GpioUtil.export(gpio, GpioUtil.DIRECTION_OUT);
		}
		Gpio.pinMode(gpio, Gpio.PWM_OUTPUT);
		// Have to call this after setting the pin mode! Yuck
		Gpio.pwmSetMode(Gpio.PWM_MODE_MS);
		Gpio.pwmWrite(gpio, Math.round(initialValue * range));
		break;
	case SOFTWARE:
		int status = SoftPwm.softPwmCreate(gpio, Math.round(initialValue * range), range);
		if (status != 0) {
			throw new RuntimeIOException("Error setting up software controlled PWM GPIO on BCM pin " +
					gpio + ", status=" + status);
		}
		break;
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:31,代码来源:WiringPiPwmOutputDevice.java


示例5: closeDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
@Override
protected void closeDevice() throws RuntimeIOException {
	Logger.debug("closeDevice()");
	switch (pwmType) {
	case HARDWARE:
		GpioUtil.unexport(gpio);
	case SOFTWARE:
		SoftPwm.softPwmStop(gpio);
		GpioUtil.unexport(gpio);
		break;
	default:
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:14,代码来源:WiringPiPwmOutputDevice.java


示例6: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String[] args) {
	if (args.length < 1) {
		System.out.println("Usage: " + WiringPiRawPerfTest.class.getName() + " <pin-number> [<iterations>]");
		System.exit(1);
	}
	
	final int pin = Integer.parseInt(args[0]);
	final int iterations = args.length > 1 ? Integer.parseInt(args[1]) : DEFAULT_ITERATIONS;
	
	Gpio.wiringPiSetupGpio();
	if (GpioUtil.isExported(pin)) {
		GpioUtil.setDirection(pin, GpioUtil.DIRECTION_OUT);
	} else {
		GpioUtil.export(pin, GpioUtil.DIRECTION_OUT);
	}
	Gpio.pinMode(pin, Gpio.OUTPUT);

	for (int j=0; j<5; j++) {
		long start_nano = System.nanoTime();
		for (int i=0; i<iterations; i++) {
			Gpio.digitalWrite(pin, true);
			Gpio.digitalWrite(pin, false);
		}
		long duration_ns = (System.nanoTime() - start_nano);
		System.out.format("Duration for %d iterations: %.4fs%n",
				Integer.valueOf(iterations), Float.valueOf(((float)duration_ns) / 1000 / 1000 / 1000));
	}
	
	GpioUtil.unexport(pin);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:31,代码来源:WiringPiRawPerfTest.java


示例7: closeDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
@Override
protected void closeDevice() {
	Logger.debug("closeDevice()");
	//GpioFactory.getInstance().unprovisionPin(pwmOutputPin);
	switch (pwmType) {
	case HARDWARE:
		GpioUtil.unexport(gpio);
	case SOFTWARE:
		SoftPwm.softPwmStop(gpio);
		GpioUtil.unexport(gpio);
		break;
	default:
	}
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:15,代码来源:Pi4jPwmOutputDevice.java


示例8: test

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public void test(int gpio) {
	GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING));
	GpioController gpio_controller = GpioFactory.getInstance();
	Pin pin = RaspiBcmPin.getPinByAddress(gpio);
	GpioPinDigitalInput digitalInputPin = gpio_controller.provisionDigitalInputPin(pin,
			"Digital Input for BCM GPIO " + gpio, PinPullResistance.PULL_UP);
	GpioUtil.setEdgeDetection(pin.getAddress(), PinEdge.BOTH.getValue());
	digitalInputPin.addListener(this);
	System.out.println("Waiting 20s for events..., thread name=" + Thread.currentThread().getName());
	SleepUtil.sleepSeconds(20);
	gpio_controller.unprovisionPin(digitalInputPin);
	gpio_controller.shutdown();
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:14,代码来源:ButtonTestPi4j.java


示例9: MCP23017Binding

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public MCP23017Binding() {
    try {
        // ask for non privileged access (run without root)
        GpioUtil.enableNonPrivilegedAccess();
    } catch (UnsatisfiedLinkError e) {
        logger.error("MCP23017 Binding needs to be run a Raspberry Pi - deactivating it here.");
        gpio = null;
        return;
    }
    // now create a controller
    gpio = GpioFactory.getInstance();
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:13,代码来源:MCP23017Binding.java


示例10: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
    int pin;
    int dataPtr;
    int l, s, d;

    System.out.println("<--Pi4J--> GPIO test program");

    // setup wiringPi
    if (Gpio.wiringPiSetup() == -1) {
        System.out.println(" ==>> GPIO SETUP FAILED");
        return;
    }

    // set GPIO 4 as the input trigger
    GpioUtil.export(7, GpioUtil.DIRECTION_IN);
    GpioUtil.setEdgeDetection(7, GpioUtil.EDGE_BOTH);
    Gpio.pinMode (7, Gpio.INPUT) ;
    Gpio.pullUpDnControl(7, Gpio.PUD_DOWN);

    // set all other GPIO as outputs
    for (pin = 0; pin < 7; ++pin) {
        // export all the GPIO pins that we will be using
        GpioUtil.export(pin, GpioUtil.DIRECTION_OUT);
        Gpio.pinMode(pin, Gpio.OUTPUT);
    }

    dataPtr = 0;
    while (true) {
        l = data[dataPtr++]; // LED
        s = data[dataPtr++]; // State
        d = data[dataPtr++]; // Duration (10ths)

        if ((l + s + d) == 27) {
            dataPtr = 0;
            continue;
        }

        Gpio.digitalWrite(l, s);

        if (Gpio.digitalRead(7) == 1) // Pressed as our switch shorts to ground
            Gpio.delay(d * 10); // Faster!
        else
            Gpio.delay(d * 100);
    }
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:46,代码来源:WiringPiGpioExample.java


示例11: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {

        System.out.println("<--Pi4J--> Non-Privileged GPIO Example ... started.");

        // we can use this utility method to pre-check to determine if
        // privileged access is required on the running system
        if(GpioUtil.isPrivilegedAccessRequired()){
            System.err.println("*****************************************************************");
            System.err.println("Privileged access is required on this system to access GPIO pins!");
            System.err.println("*****************************************************************");
            return;
        }

        // ----------------------
        // ATTENTION
        // ----------------------
        // YOU CANNOT USE ANY HARDWARE PWM OR CLOCK FUNCTIONS WHILE ACCESSING NON-PRIVILEGED GPIO.
        // THIS METHOD MUST BE INVOKED BEFORE CREATING A GPIO CONTROLLER INSTANCE.
        GpioUtil.enableNonPrivilegedAccess();

        // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();

        // ------------
        // OUTPUT PIN
        // ------------

        // provision gpio pin #01 as an output pin and blink it
        final GpioPinDigitalOutput output = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01);

        // set shutdown state for the output pin (and un-export the pin)
        output.setShutdownOptions(true, PinState.LOW);

        // blink output pin every one second
        output.blink(1000);

        // display info to user
        System.out.println("Pin [" + output.getName() + "] should be blinking/toggling every 1 second.");

        // ------------
        // INPUT PIN
        // ------------

        // provision gpio pin #02 as an input pin with its internal pull down resistor enabled
        final GpioPinDigitalInput input = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02, PinPullResistance.PULL_DOWN);

        // set shutdown state for the input pin (and un-export the pin)
        input.setShutdownOptions(true);

        // create and register gpio pin listener
        input.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());
            }
        });

        // display info to user
        System.out.println("You can connect pin [" + input.getName() + "] to +3VDC to capture input state changes.");

        // ----------------
        // WAIT & SHUTDOWN
        // ----------------

        // sleep for 1 minute, then shutdown
        Thread.sleep(60000);

        // 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();

        System.out.println("Exiting NonPrivilegedGpioExample");
    }
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:75,代码来源:NonPrivilegedGpioExample.java


示例12: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {

        System.out.println("<--Pi4J--> GPIO INTERRUPT test program");

        // create and add GPIO listener
        GpioInterrupt.addListener(new GpioInterruptListener() {
            @Override
            public void pinStateChange(GpioInterruptEvent event) {
                System.out.println("Raspberry Pi PIN [" + event.getPin() +"] is in STATE [" + event.getState() + "]");

                if(event.getPin() == 7) {
                    Gpio.digitalWrite(6, event.getStateValue());
                }
                if(event.getPin() == 0) {
                    Gpio.digitalWrite(5, event.getStateValue());
                }
            }
        });

        // setup wiring pi
        if (Gpio.wiringPiSetup() == -1) {
            System.out.println(" ==>> GPIO SETUP FAILED");
            return;
        }

        // export all the GPIO pins that we will be using
        GpioUtil.export(0, GpioUtil.DIRECTION_IN);
        GpioUtil.export(7, GpioUtil.DIRECTION_IN);
        GpioUtil.export(5, GpioUtil.DIRECTION_OUT);
        GpioUtil.export(6, GpioUtil.DIRECTION_OUT);

        // set the edge state on the pins we will be listening for
        GpioUtil.setEdgeDetection(0, GpioUtil.EDGE_BOTH);
        GpioUtil.setEdgeDetection(7, GpioUtil.EDGE_BOTH);

        // configure GPIO pins 5, 6 as an OUTPUT;
        Gpio.pinMode(5, Gpio.OUTPUT);
        Gpio.pinMode(6, Gpio.OUTPUT);

        // configure GPIO 0 as an INPUT pin; enable it for callbacks
        Gpio.pinMode(0, Gpio.INPUT);
        Gpio.pullUpDnControl(0, Gpio.PUD_DOWN);
        GpioInterrupt.enablePinStateChangeCallback(0);

        // configure GPIO 7 as an INPUT pin; enable it for callbacks
        Gpio.pinMode(7, Gpio.INPUT);
        Gpio.pullUpDnControl(7, Gpio.PUD_DOWN);
        GpioInterrupt.enablePinStateChangeCallback(7);

        // continuously loop to prevent program from exiting
        while (true) {
            Thread.sleep(5000);
        }
    }
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:55,代码来源:WiringPiGpioInterruptExample.java


示例13: closeDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
@Override
protected void closeDevice() {
	Logger.debug("closeDevice()");
	GpioUtil.unexport(gpio);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:6,代码来源:WiringPiDigitalOutputDevice.java


示例14: WiringPiDigitalInputDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public WiringPiDigitalInputDevice(String key, DeviceFactoryInterface deviceFactory, int gpio,
		GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException {
	super(key, deviceFactory);
	
	this.gpio = gpio;
	switch (trigger) {
	case RISING:
		edge = Gpio.INT_EDGE_RISING;
		break;
	case FALLING:
		edge = Gpio.INT_EDGE_FALLING;
		break;
	case BOTH:
	default:
		edge = Gpio.INT_EDGE_BOTH;
		break;
	}
	
	try {
		// Note calling this method will automatically export the pin and set the pin direction to INPUT
		if (!GpioUtil.setEdgeDetection(gpio, edge)) {
			throw new RuntimeIOException("Error setting edge detection (" + edge + ") for pin " + gpio);
		}
	} catch (RuntimeException re) {
		throw new RuntimeIOException(re);
	}

	int wpi_pud;
	switch (pud) {
	case PULL_DOWN:
		wpi_pud = Gpio.PUD_DOWN;
		break;
	case PULL_UP:
		wpi_pud = Gpio.PUD_UP;
		break;
	case NONE:
	default:
		wpi_pud = Gpio.PUD_OFF;
		break;
	}
	Gpio.pullUpDnControl(gpio, wpi_pud);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:43,代码来源:WiringPiDigitalInputDevice.java


示例15: closeDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
@Override
protected void closeDevice() {
	Logger.debug("closeDevice()");
	removeListener();
	GpioUtil.unexport(gpio);
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:7,代码来源:WiringPiDigitalInputDevice.java


示例16: Pi4jDigitalInputDevice

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
Pi4jDigitalInputDevice(String key, DeviceFactoryInterface deviceFactory, GpioController gpioController,
		int gpio, GpioPullUpDown pud, GpioEventTrigger trigger) {
	super(key, deviceFactory);
	
	Pin pin = RaspiBcmPin.getPinByAddress(gpio);
	if (pin == null) {
		throw new IllegalArgumentException("Illegal GPIO number: " + gpio);
	}
	
	this.gpio = gpio;
	
	PinPullResistance ppr;
	switch (pud) {
	case PULL_DOWN:
		ppr = PinPullResistance.PULL_DOWN;
		break;
	case PULL_UP:
		ppr = PinPullResistance.PULL_UP;
		break;
	case NONE:
	default:
		ppr = PinPullResistance.OFF;
	}

	/*
	PinEdge edge;
	switch (trigger) {
	case FALLING:
		edge = PinEdge.FALLING;
		break;
	case RISING:
		edge = PinEdge.RISING;
		break;
	case NONE:
		edge = PinEdge.NONE;
		break;
	case BOTH:
	default:
		edge = PinEdge.BOTH;
		break;
	}
	*/
	
	// Note configuring GPIO event trigger values (rising / falling / both) via the provision APIs isn't possible in Pi4j
	digitalInputPin = gpioController.provisionDigitalInputPin(
			pin, "Digital Input for BCM GPIO " + gpio, ppr);
	
	// RaspiGpioProvider.export() calls this for all input pins:
	if (! GpioUtil.setEdgeDetection(pin.getAddress(), PinEdge.BOTH.getValue())) {
		throw new RuntimeIOException("Error setting edge detection");
	}
	//GpioUtil.setEdgeDetection(pin.getAddress(), edge.getValue());
}
 
开发者ID:mattjlewis,项目名称:diozero,代码行数:54,代码来源:Pi4jDigitalInputDevice.java


示例17: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
    int pin;
    int dataPtr;
    int l, s, d;
    
    System.out.println("<--Pi4J--> GPIO test program");

    // setup wiringPi
    if (Gpio.wiringPiSetup() == -1) {
        System.out.println(" ==>> GPIO SETUP FAILED");
        return;
    }

    // set GPIO 4 as the input trigger 
    GpioUtil.export(7, GpioUtil.DIRECTION_IN);
    GpioUtil.setEdgeDetection(7, GpioUtil.EDGE_BOTH);
    Gpio.pinMode (7, Gpio.INPUT) ;  
    Gpio.pullUpDnControl(7, Gpio.PUD_DOWN);        

    // set all other GPIO as outputs
    for (pin = 0; pin < 7; ++pin) {
        // export all the GPIO pins that we will be using
        GpioUtil.export(pin, GpioUtil.DIRECTION_OUT);            
        Gpio.pinMode(pin, Gpio.OUTPUT);
    }
    
    dataPtr = 0;
    for (;;) {
        l = data[dataPtr++]; // LED
        s = data[dataPtr++]; // State
        d = data[dataPtr++]; // Duration (10ths)

        if ((l + s + d) == 27) {
            dataPtr = 0;
            continue;
        }

        Gpio.digitalWrite(l, s);
        
        if (Gpio.digitalRead(7) == 1) // Pressed as our switch shorts to ground
            Gpio.delay(d * 10); // Faster!
        else
            Gpio.delay(d * 100);
    }
}
 
开发者ID:iot-labs,项目名称:communication,代码行数:46,代码来源:WiringPiGpioExample.java


示例18: main

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
    
    System.out.println("<--Pi4J--> GPIO INTERRUPT test program");
    
    // create and add GPIO listener 
    GpioInterrupt.addListener(new GpioInterruptListener() {
        @Override
        public void pinStateChange(GpioInterruptEvent event) {
            System.out.println("Raspberry Pi PIN [" + event.getPin() +"] is in STATE [" + event.getState() + "]");
            
            if(event.getPin() == 7) {
                Gpio.digitalWrite(6, event.getStateValue());
            }
            if(event.getPin() == 0) {
                Gpio.digitalWrite(5, event.getStateValue());
            }
        }
    });
    
    // setup wiring pi
    if (Gpio.wiringPiSetup() == -1) {
        System.out.println(" ==>> GPIO SETUP FAILED");
        return;
    }

    // export all the GPIO pins that we will be using
    GpioUtil.export(0, GpioUtil.DIRECTION_IN);
    GpioUtil.export(7, GpioUtil.DIRECTION_IN);
    GpioUtil.export(5, GpioUtil.DIRECTION_OUT);
    GpioUtil.export(6, GpioUtil.DIRECTION_OUT);
    
    // set the edge state on the pins we will be listening for
    GpioUtil.setEdgeDetection(0, GpioUtil.EDGE_BOTH);
    GpioUtil.setEdgeDetection(7, GpioUtil.EDGE_BOTH);
    
    // configure GPIO pins 5, 6 as an OUTPUT;
    Gpio.pinMode(5, Gpio.OUTPUT);
    Gpio.pinMode(6, Gpio.OUTPUT);

    // configure GPIO 0 as an INPUT pin; enable it for callbacks
    Gpio.pinMode(0, Gpio.INPUT);
    Gpio.pullUpDnControl(0, Gpio.PUD_DOWN);        
    GpioInterrupt.enablePinStateChangeCallback(0);
    
    // configure GPIO 7 as an INPUT pin; enable it for callbacks
    Gpio.pinMode(7, Gpio.INPUT);
    Gpio.pullUpDnControl(7, Gpio.PUD_DOWN);        
    GpioInterrupt.enablePinStateChangeCallback(7);

    // continuously loop to prevent program from exiting
    for (;;) {
        Thread.sleep(5000);
    }
}
 
开发者ID:iot-labs,项目名称:communication,代码行数:55,代码来源:WiringPiGpioInterruptExample.java


示例19: MCP3424Binding

import com.pi4j.wiringpi.GpioUtil; //导入依赖的package包/类
public MCP3424Binding() {
    // ask for non privileged access (run without root)
    GpioUtil.enableNonPrivilegedAccess();
    // now create a controller
    gpio = GpioFactory.getInstance();
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:7,代码来源:MCP3424Binding.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServiceMessage类代码示例发布时间:2022-05-22
下一篇:
Java CircuitPathChooser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap