From 755552a9a6c180c146a71e5c609fd27f21fcf475 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Thu, 12 Jun 2014 20:38:46 +0000 Subject: [PATCH] Bugfixed gpio, improved bitmap example script --- examples/bitmap.php | 8 ++++++-- lib/GpioPin.php | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/bitmap.php b/examples/bitmap.php index 3945f71..3dcd504 100644 --- a/examples/bitmap.php +++ b/examples/bitmap.php @@ -20,5 +20,9 @@ for($n = 0; $n < 7; $n++) { $par->setGpioPin($n,$gpio[$n]); } -$par->write(0xFF); -$par->write(0x00); +for($n = 0; $n < 10; $n++) { + $par->write(0xFF); + usleep(500000); + $par->write(0x00); + usleep(500000); +} diff --git a/lib/GpioPin.php b/lib/GpioPin.php index f5d2664..ea97252 100644 --- a/lib/GpioPin.php +++ b/lib/GpioPin.php @@ -76,7 +76,9 @@ class GpioPin public function __destruct() { - fclose($this->fd); + if ($this->fd) { + fclose($this->fd); + } } public function setDirection($direction)