*/ 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() {} /** * Allocate a GPIO (as defined in hardware) pin to the device. * */ public function addGpioPin($gpio, $name, $description=null) { $pin = new GpioPin($gpio); $pin->setLabel($description); $this->pins[$name] = $pin; } /** * Allocate a logical (wiring-pi 0-based pin number) pin to the device. * */ public function addLogicalPin($logical, $name, $description=null) { $pin = $this->gpio[$logical]; $pin->setLabel($description); $this->pins[$name] = $pin; } /** * Get all allocated pins * */ public function getPins() { return $this->pins; } /** * Get a pin by the name specified when allocating it * */ public function getPin($name) { return $this->pins[$name]; } /** * Get a pin as a property from its name * */ protected function __get($pin_name) { return $this->getPin($pin_name); } public function delayMillis($ms) {} public function delayMicros($us) {} }