76 lines
1.3 KiB
PHP
76 lines
1.3 KiB
PHP
|
<?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);
|
||
|
}
|
||
|
}
|