From cdb8edd4e09238221eafbe646c61b12e9055df18 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Thu, 12 Jun 2014 01:21:08 +0200 Subject: [PATCH] Added exceptions to gpio class --- composer.lock | 3 ++- examples/basic.php | 4 ++-- lib/Exception/HardwareException.php | 9 +++++++++ lib/Gpio.php | 12 ++++++++++++ lib/GpioPin.php | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 lib/Exception/HardwareException.php diff --git a/composer.lock b/composer.lock index 5cdc18d..4d8d571 100644 --- a/composer.lock +++ b/composer.lock @@ -1,7 +1,8 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" ], "hash": "6ede4cbc5ab4ef05b58811c306b5376f", "packages": [ diff --git a/examples/basic.php b/examples/basic.php index b970d0e..36d1798 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -23,7 +23,7 @@ $led = $gpio[0] ->setLabel("red led") ->dumpStatus(true); -$btn = $gpio[1] +$btn1 = $gpio[1] ->setDirection("input") ->setValue(0) ->setEdge("rising") @@ -31,7 +31,7 @@ $btn = $gpio[1] ->setLabel("button 1") ->dumpStatus(true); -$gpio[2] +$btn2 = $gpio[2] ->setDirection("input") ->setValue(0) ->setEdge("rising") diff --git a/lib/Exception/HardwareException.php b/lib/Exception/HardwareException.php new file mode 100644 index 0000000..ea78718 --- /dev/null +++ b/lib/Exception/HardwareException.php @@ -0,0 +1,9 @@ +pin} \e[0m\n"; + $status = "\e[44;37;1m GPIO{$this->pin} \e[0m\n"; $direction = "\e[36;1m". ($this->direction=="input"?(CS::chr(0x2190)):(CS::chr(0x2192))). "\e[0m ".$this->direction;