36 lines
		
	
	
		
			763 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			763 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
require_once __DIR__."/../vendor/autoload.php";
 | 
						|
 | 
						|
use NoccyLabs\Gpio\Gpio;
 | 
						|
use NoccyLabs\Gpio\GpioMapper\WiringPiMapper;
 | 
						|
 | 
						|
try {
 | 
						|
    $gpio = new Gpio(true);
 | 
						|
} catch (Gpio\Exception $e) {
 | 
						|
    error_log("Error: {$e}");
 | 
						|
}
 | 
						|
 | 
						|
// The mapper translates GPIO to logical pins and vice versa
 | 
						|
$gpio->setMapper( new WiringPiMapper(2) );
 | 
						|
 | 
						|
// Access logical pin 0, since we got a mapper assigned. Otherwise this would
 | 
						|
// be the actual GPIO0 pin.
 | 
						|
$led = $gpio[0]
 | 
						|
    ->export()
 | 
						|
    ->setDirection("input")
 | 
						|
    ->setEdge("rising")
 | 
						|
    ->setHandler(function($e) use($gpio) {
 | 
						|
        
 | 
						|
    })
 | 
						|
    ->setLabel("rfint")
 | 
						|
    ->dumpStatus(true);
 | 
						|
 | 
						|
for($n = 1; $n < 5; $n++) {
 | 
						|
    $gpio[$n]
 | 
						|
        ->setDirection("input")
 | 
						|
        ->setLabel("rfbt{$n}")
 | 
						|
        ->dumpStatus(true);
 | 
						|
}
 | 
						|
 |