Improved sysfs file access code

This commit is contained in:
noccy committed 2014-06-12 02:35:19 +02:00
1 parent 2304372129
commit b53cabec90
5 files changed
+162 -27

No files matched your search

+7 -19
View File
@@ -15,28 +15,16 @@ try {
$gpio->setMapper( new WiringPiMapper(2) );
// Access logical pin 0, since we got a mapper assigned. Otherwise this would
// be the actual GPIO0 pin.
// be the actual GPIO0 pin.
$led = $gpio[0]
->export()
->setDirection("output")
->setValue(0)
->setLabel("red led")
->dumpStatus(true);
$btn1 = $gpio[1]
->setDirection("input")
->setValue(0)
->setEdge("rising")
->setHandler(function() { echo "INTERRUPT!\n"; })
->setLabel("button 1")
->dumpStatus(true);
$btn2 = $gpio[2]
->setDirection("input")
->setValue(0)
->setEdge("rising")
->setHandler(function() { echo "INTERRUPT!\n"; })
->setLabel("button 2")
->dumpStatus(true);
$x = 0;
while(true) {
$x = (int)(!$x);
$led->setValue($x);
usleep(500000);
}