Go to file
2014-06-12 14:22:37 +02:00
docs Fixed headers, added docs 2014-06-12 14:22:37 +02:00
examples Updated basic example 2014-06-12 12:19:22 +00:00
lib Fixed headers, added docs 2014-06-12 14:22:37 +02:00
.gitignore Initial commit 2014-06-05 02:20:22 +02:00
composer.json Implemented base of GpioMapperInterface with WiringPiMapper 2014-06-06 19:50:17 +02:00
composer.lock Added exceptions to gpio class 2014-06-12 01:21:08 +02:00
LICENSE Initial commit 2014-06-05 02:20:22 +02:00
README.md Fixed headers, added docs 2014-06-12 14:22:37 +02:00

Linux Userspace GPIO Library

  • Export and Unexport GPIO pins
  • Interrupt support (*)
  • Hardware-neutral rewrite of NoccyLabs RaspIO
  • Compatible with psr/logs LoggerInterface for logging

Interrupts

NOTE: Not implemented!

For interrupts to work, you need to first bind the interrupt handler, and then make sure to call on Gpio#refresh() every cycle to poll the interrupt flag on the selected pins. This is because the select() function is used.

$gpio = new Gpio();

// Set the handler on the Gpio object
$gpio->setInterruptHandler($gpio[4], function() { ... });
// Or like this on the GpioPin.
$gpio[4]
    ->setEdge("rising")
    ->setHandler(function() { ... });

while (..) {
    ..
    $gpio->refresh();
}

You can also be risky and use php ticks and timerfuncs (although that might not be portable/supported/efficient/a good idea):

declare(ticks=5);

$gpio = new Gpio();

$gpiotick = new GpioTickHandler();
$gpiotick->registerGpio($gpio);

// The interrupts will now be polled approx every 5th php vm "tick"