Fixed typos, added pinmap example to dump map
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								examples/pinmap.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								examples/pinmap.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
require_once __DIR__."/../vendor/autoload.php";
 | 
			
		||||
 | 
			
		||||
use NoccyLabs\Gpio\GpioMapper\WiringPiMapper;
 | 
			
		||||
use NoccyLabs\Gpio\Exception\GpioException;
 | 
			
		||||
 | 
			
		||||
$mapper = new WiringPiMapper(2);
 | 
			
		||||
 | 
			
		||||
$pin = 0;
 | 
			
		||||
try {
 | 
			
		||||
	while (($gpio = $mapper->mapLogicalToGpioPin($pin))) {
 | 
			
		||||
		printf(" %3d = GPIO%d \n", $pin, $gpio);
 | 
			
		||||
		$pin++;
 | 
			
		||||
	}
 | 
			
		||||
} catch (GpioException $e) {
 | 
			
		||||
}
 | 
			
		||||
@@ -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");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user