Go to file
Chris e73d8ca330 Moved pindefs for examples to GLOBALS.php 2014-06-13 14:04:04 +02:00
docs Fixed headers, added docs 2014-06-12 14:22:37 +02:00
examples Moved pindefs for examples to GLOBALS.php 2014-06-13 14:04:04 +02:00
lib Added bugfix to prevent access errors on newly exported pin control files 2014-06-13 12:01:36 +00:00
.gitignore Initial commit 2014-06-05 02:20:22 +02:00
LICENSE Initial commit 2014-06-05 02:20:22 +02:00
README.md Implemented the tick handler 2014-06-12 18:14:51 +02:00
composer.json Added branch alias 2014-06-12 16:13:45 +02:00
composer.lock Added exceptions to gpio class 2014-06-12 01:21:08 +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


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.
    ->setHandler(function() { ... });

while (..) {

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


$gpio = new Gpio();

$gpiotick = new GpioTickHandler();

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


$lcd = new NoccyLabs\Gpio\Device\Display\Pcd8544Device;
// Set I/O pins
$lcd->res = $gpio[4];
$lcd->dc  = $gpio[8];
// Activate the device
// Clear and draw text
$lcd->writeAt(0,0,"Hello World");
echo $lcd->getRows(); // 5
echo $lcd->getCols(); // 19

LCD Bridge

The LCD bridge will be able to bridge any device class implementing LcdDeviceInterface to stdin or a named pipe. This basically creates a user-space daemon to interface with the display without having to fiddle with bits.

$ lcdbridge -t pcd8544 --stdin
LOC 0 0
OUT Hello World

Commands should include:

  • CLR clears the display (LcdDeviceInterface#clear())
  • LOC n m moves the cursor to line n column m (0-indexed) (LcdDeviceInterface#setCursorPos(n,m))
  • FONT n loads the default font (0) or a custom font file (LcdDeviceInterface#setFont())
  • OUT Write text to the display (LcdDeviceInterface#write())