added bitmappedgpio class to map several gpio in one byte

This commit is contained in:
2014-06-12 18:31:39 +02:00
parent d7cfbcaf28
commit 477ea2605d
2 changed files with 70 additions and 0 deletions

24
examples/bitmap.php Normal file
View File

@ -0,0 +1,24 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
/*
* This example demonstrates mapping GpioPins to bit values and writing bits
* in parallel.
*
*/
use NoccyLabs\Gpio\Gpio;
use NoccyLabs\Gpio\Util\BitmappedGpio;
use NoccyLabs\Gpio\GpioMapper\WiringPiMapper;
$gpio = new Gpio();
$gpio->setMapper( new WiringPiMapper(2) );
$par = new BitmappedGpio();
for($n = 0; $n < 7; $n++) {
$par->setGpioPin($n,$gpio[$n]);
}
$par->write(0xFF);
$par->write(0x00);