From 17dd85f828086f0f396c80e98938ea55ce929243 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Fri, 13 Jun 2014 00:02:39 +0000 Subject: [PATCH] Fixed typos, added pinmap example to dump map --- examples/bitmap.php | 14 +++++++++++--- examples/pinmap.php | 17 +++++++++++++++++ lib/GpioMapper/WiringPiMapper.php | 3 ++- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 examples/pinmap.php diff --git a/examples/bitmap.php b/examples/bitmap.php index 3dcd504..f2cfca5 100644 --- a/examples/bitmap.php +++ b/examples/bitmap.php @@ -17,12 +17,20 @@ $gpio->setMapper( new WiringPiMapper(2) ); $par = new BitmappedGpio(); for($n = 0; $n < 7; $n++) { - $par->setGpioPin($n,$gpio[$n]); + $pin = $gpio[$n]->setDirection("out"); + $par->setGpioPin($n,$pin); } -for($n = 0; $n < 10; $n++) { +for($n = 0; $n < 5; $n++) { $par->write(0xFF); - usleep(500000); + usleep(300000); $par->write(0x00); + usleep(300000); +} + +for($n = 1; $n < 16; $n++) { + $par->write($n); usleep(500000); } + +$par->write(0); diff --git a/examples/pinmap.php b/examples/pinmap.php new file mode 100644 index 0000000..d6af948 --- /dev/null +++ b/examples/pinmap.php @@ -0,0 +1,17 @@ +mapLogicalToGpioPin($pin))) { + printf(" %3d = GPIO%d \n", $pin, $gpio); + $pin++; + } +} catch (GpioException $e) { +} diff --git a/lib/GpioMapper/WiringPiMapper.php b/lib/GpioMapper/WiringPiMapper.php index cfc82bd..40a934a 100644 --- a/lib/GpioMapper/WiringPiMapper.php +++ b/lib/GpioMapper/WiringPiMapper.php @@ -20,6 +20,7 @@ namespace NoccyLabs\Gpio\GpioMapper; use NoccyLabs\Gpio\GpioMapperInterface; +use NoccyLabs\Gpio\Exception\GpioException; class WiringPiMapper implements GpioMapperInterface { @@ -107,7 +108,7 @@ class WiringPiMapper implements GpioMapperInterface case 19: return 30; case 20: return 31; } - throw new GpioException("Unable to map logicak {$logical} to GPIO pin"); + throw new GpioException("Unable to map logical pin {$logical} to GPIO pin"); } }