*/ namespace NoccyLabs\Gpio; class Gpio implements \ArrayAccess { protected $gpio = array(); /** @var NoccyLabs\Gpio\GpioMapperInterface */ protected $mapper; public function refresh() { $read = $this->fd_gpio; $write = array(); $except = $read; select($read, $write, $except, 0); foreach($except as $fd) { $pin = $this->getPinFromFd($fd); $pin->doInterrupt(); } } public function setMapper(GpioMapperInterface $mapper=null) { $this->mapper = $mapper; return $this; } public function offsetGet($index) { if ($this->mapper) { $index = $this->mapper->mapLogicalToGpioPin($index); } if (empty($this->gpio[$index])) { $this->gpio[$index] = new GpioPin($index); } return $this->gpio[$index]; } public function offsetExists($index) { return array_key_exists($index, $this->gpio); } public function offsetSet($index,$value) { throw new \Exception(); } public function offsetUnset($index) { unset($this->gpio[$index]); } }