2014-06-06 18:32:40 +00:00
|
|
|
<?php
|
|
|
|
|
2014-06-12 12:22:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014, NoccyLabs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
|
2014-06-06 18:32:40 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|