Extracted lcdbridge and added first signs of RPI B+ to pi mapper

master
Noccy 9 years ago
parent 1449ec643f
commit ec4e5bd6ab

@ -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

@ -1,10 +0,0 @@
#!/usr/bin/env php
<?php
require_once __DIR__."/../vendor/autoload.php";
NoccyLabs\LcdBridge\LcdBridgeApplication::main();

@ -1,23 +0,0 @@
<?php
namespace NoccyLabs\LcdBridge;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class DaemonCommand extends Command
{
protected function configure()
{
$this
->setName("daemon")
->setDescription("Spawn a new daemon")
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
}
}

@ -1,17 +0,0 @@
<?php
namespace NoccyLabs\LcdBridge;
use Symfony\Component\Console\Application as ConsoleApplication;
class LcdBridgeApplication extends ConsoleApplication
{
public static function main()
{
$app = new self("lcdbridge", "0.1");
$app->add( new DaemonCommand );
$app->run();
}
}

@ -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 == self::REV_BPLUS) {
switch ($gpio) {
case 27: return 2;
case 2: return 8;
case 3: return 9;
}
} elseif ($this->version == 1) {
} 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;

@ -0,0 +1,12 @@
<?php
namespace NoccyLabs\LinuxGpio;
class InterruptHandler
{
public function setInterrupt(Gpio $pin, $edge = null, callable $handler = null)
{
}
}

@ -0,0 +1,7 @@
<phpunit bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="linux-gpio">
<directory suffix="Test.php">tests/src/</directory>
</testsuite>
</testsuites>
</phpunit>

@ -0,0 +1,3 @@
<?php
require_once __DIR__."/../vendor/autoload.php";

@ -0,0 +1,34 @@
<?php
namespace NoccyLabs\Gpio;
class GpioTest extends \PhpUnit_Framework_TestCase
{
protected $gpio;
public function setup()
{
// dummy gpio
$this->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);
}
}
Loading…
Cancel
Save