php-linux-gpio/lib/Device/Device.php

76 lines
1.3 KiB
PHP
Raw Normal View History

2014-06-06 18:32:40 +00:00
<?php
namespace NoccyLabs\Gpio\Device;
abstract class Device implements GpioAwareInterface
{
protected $name;
protected $gpio;
protected $pins = array();
protected function configure()
{
// call on ->addGpioPin etc here
}
public function setGpio(Gpio $gpio=null)
{
$this->gpio = $gpio;
}
public function getGpio()
{
return $this->gpio;
}
public function setName($name)
{}
public function getName()
{}
public function setDescription($description)
{}
public function getDescription()
{}
public function addGpioPin($gpio, $name, $description=null)
{
$pin = new GpioPin($gpio);
$pin->setLabel($description);
$this->pins[$name] = $pin;
}
public function addLogicalPin($logical, $name, $description=null)
{
$pin = $this->gpio[$logical];
$pin->setLabel($description);
$this->pins[$name] = $pin;
}
public function getPins()
{
return $this->pins;
}
public function getPin($name)
{
return $this->pins[$name];
}
public function delayMillis($ms)
{}
public function delayMicros($us)
{}
public function __get($pin_name)
{
return $this->getPin($pin_name);
}
}