From 093f164121376b43719b4dbb613f227fc184aa59 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Sat, 14 Jun 2014 01:10:39 +0000 Subject: [PATCH] Hey, cylon example! Awesome --- composer.lock | 9 ++++++-- examples/cylon.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 examples/cylon.php diff --git a/composer.lock b/composer.lock index 8e42691..3ad0934 100644 --- a/composer.lock +++ b/composer.lock @@ -15,9 +15,14 @@ "source": { "type": "git", "url": "http://satis.noccylabs.info/packages/php-crap.git", - "reference": "846708ec6f1b6c53dd95871d19590557675ed026" + "reference": "f17cd1ce2933870c30e1311b466d3d5e900066c4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + }, "autoload": { "psr-4": { "NoccyLabs\\Crap\\": "lib/" @@ -33,7 +38,7 @@ } ], "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", diff --git a/examples/cylon.php b/examples/cylon.php new file mode 100644 index 0000000..44f6933 --- /dev/null +++ b/examples/cylon.php @@ -0,0 +1,55 @@ +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);