diff --git a/README.md b/README.md index f9b0446..bce359d 100644 --- a/README.md +++ b/README.md @@ -109,48 +109,4 @@ be portable/supported/efficient/a good idea): echo $lcd->getCols(); // 19 -### LCD Bridge - -The LCD bridge will be able to bridge any device class implementing `LcdDeviceInterface` -to stdin or a named pipe. This basically creates a user-space daemon to interface with -the display without having to fiddle with bits. - - $ lcdbridge -t pcd8544 --stdin - CLR - LOC 0 0 - FONT 0 - MODE +BR - OUT "Hello World" - ^C - $ - -Commands should include: - - * `CLR` - clears the display (`LcdDeviceInterface#clear()`) - * `LOC n m` - moves the cursor to line n column m (0-indexed) (`LcdDeviceInterface#setCursorPos(n,m)`) - * `FONT n` - loads the default font (0) or a custom font file (`LcdDeviceInterface#setFont()`) - * `OUT s` - Write text to the display (`LcdDeviceInterface#write()`) - * `MODE s` - Set text modes (`LcdDeviceInterface#setTextMode()`) - - -#### Modes - -As supported: - - * `+R`/`-R` - Set/clear inverse - * `+B`/`-B` - Set/clear bold - - -#### Fonts - - - -#### Location and write - -Location is maintained and incremented after writes. - - LOC 0 0 - OUT "12345" - OUT "67890" <-- continued at 0 5 - diff --git a/bin/lcdbridge b/bin/lcdbridge deleted file mode 100755 index 1d87401..0000000 --- a/bin/lcdbridge +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env php -setName("daemon") - ->setDescription("Spawn a new daemon") - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - - } -} diff --git a/lcdbridge/LcdBridgeApplication.php b/lcdbridge/LcdBridgeApplication.php deleted file mode 100644 index 84d59aa..0000000 --- a/lcdbridge/LcdBridgeApplication.php +++ /dev/null @@ -1,17 +0,0 @@ -add( new DaemonCommand ); - - $app->run(); - } -} diff --git a/lib/GpioMapper/WiringPiMapper.php b/lib/GpioMapper/WiringPiMapper.php index 40a934a..5fa3c4f 100644 --- a/lib/GpioMapper/WiringPiMapper.php +++ b/lib/GpioMapper/WiringPiMapper.php @@ -24,11 +24,15 @@ use NoccyLabs\Gpio\Exception\GpioException; class WiringPiMapper implements GpioMapperInterface { + const REV_A = 1; + const REV_B = 2; + const REV_BPLUS = 3; + protected $version; public function __construct($version=1) { - $this->version = (int)$version; + $this->version = $version; } /** {@inheritdoc} */ @@ -54,13 +58,19 @@ class WiringPiMapper implements GpioMapperInterface case 30: return 19; case 31: return 20; } - if ($this->version == 2) { + if ($this->version == self::REV_B) { switch ($gpio) { case 27: return 2; case 2: return 8; case 3: return 9; } - } elseif ($this->version == 1) { + } elseif ($this->version == self::REV_BPLUS) { + switch ($gpio) { + case 27: return 2; + case 2: return 8; + case 3: return 9; + } + } elseif ($this->version == self::REV_A) { switch ($gpio) { case 21: return 2; case 9: return 8; @@ -77,7 +87,8 @@ class WiringPiMapper implements GpioMapperInterface case 0: return 17; case 1: return 18; case 2: - if ($this->version == 2) { + if (($this->version == self::REV_B) + ||($this->version == self::REV_BPLUS)) { return 27; } return 21; @@ -87,12 +98,14 @@ class WiringPiMapper implements GpioMapperInterface case 6: return 25; case 7: return 11; case 8: - if ($this->version == 2) { + if (($this->version == self::REV_B) + ||($this->version == self::REV_BPLUS)) { return 2; } return 0; case 9: - if ($this->version == 2) { + if (($this->version == self::REV_B) + ||($this->version == self::REV_BPLUS)) { return 3; } return 1; diff --git a/lib/InterruptHandler.php b/lib/InterruptHandler.php new file mode 100644 index 0000000..3387eb4 --- /dev/null +++ b/lib/InterruptHandler.php @@ -0,0 +1,12 @@ + + + + tests/src/ + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..8bb7710 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,3 @@ +gpio = new Gpio(true); + } + + public function testAccessingGpioPins() + { + $pin0 = $this->gpio[0]; + $this->assertInstanceOf('NoccyLabs\Gpio\GpioPin', $pin0); + $pin1 = $this->gpio[1]; + $this->assertInstanceOf('NoccyLabs\Gpio\GpioPin', $pin1); + $this->assertNotEquals($pin0, $pin1); + } + + public function testAccessingGpioPinsViaMapper() + { + $this->gpio->setMapper( new GpioMapper\WiringPiMapper ); + $pin0 = $this->gpio[0]; + $this->assertInstanceOf('NoccyLabs\Gpio\GpioPin', $pin0); + $pin1 = $this->gpio[1]; + $this->assertInstanceOf('NoccyLabs\Gpio\GpioPin', $pin1); + $this->assertNotEquals($pin0, $pin1); + } +} +