Hey, cylon example! Awesome

This commit is contained in:
Chris 2014-06-14 01:10:39 +00:00
parent cdffd77a38
commit 093f164121
2 changed files with 62 additions and 2 deletions

9
composer.lock generated
View File

@ -15,9 +15,14 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "http://satis.noccylabs.info/packages/php-crap.git", "url": "http://satis.noccylabs.info/packages/php-crap.git",
"reference": "846708ec6f1b6c53dd95871d19590557675ed026" "reference": "f17cd1ce2933870c30e1311b466d3d5e900066c4"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"NoccyLabs\\Crap\\": "lib/" "NoccyLabs\\Crap\\": "lib/"
@ -33,7 +38,7 @@
} }
], ],
"description": "Crap is an exception/error/assertion handling library", "description": "Crap is an exception/error/assertion handling library",
"time": "2014-06-13 22:18:38" "time": "2014-06-13 23:33:50"
}, },
{ {
"name": "noccylabs/sansi", "name": "noccylabs/sansi",

55
examples/cylon.php Normal file
View File

@ -0,0 +1,55 @@
<?php
require_once __DIR__."/../vendor/autoload.php";
require_once __DIR__."/GLOBALS.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 < 6; $n++) {
$pin = $gpio[$n]->setDirection("out");
$par->setGpioPin($n,$pin);
}
$aa = array(
0b0000000,
0b0000000,
0b0000000,
0b0000000,
0b0000001,
0b0000011,
0b0000111,
0b0001111,
0b0011110,
0b0111100,
0b1111000,
0b1110000,
0b1100000,
0b1000000,
0b0000000,
);
$ab = array_reverse($aa);
for($x=0;$x<50;$x++) {
foreach($aa as $n) {
$par->write($n);
usleep(50000);
}
foreach($ab as $n) {
$par->write($n);
usleep(50000);
}
}
$par->write(0);