PiPHP\GPIO\Interrupt\InterruptWatcher::register PHP Метод

register() публичный Метод

public register ( PiPHP\GPIO\Pin\InputPinInterface $pin, callable $callback )
$pin PiPHP\GPIO\Pin\InputPinInterface
$callback callable
    public function register(InputPinInterface $pin, callable $callback)
    {
        $pinNumber = $pin->getNumber();
        if (!isset($this->streams[$pinNumber])) {
            $file = '/sys/class/gpio/gpio' . $pinNumber . '/value';
            $this->streams[$pinNumber] = $this->fileSystem->open($file, 'r');
            stream_set_blocking($this->streams[$pinNumber], false);
            fread($this->streams[$pinNumber], 1);
            @rewind($this->streams[$pinNumber]);
        }
        $this->pins[$pinNumber] = $pin;
        $this->callbacks[$pinNumber] = $callback;
    }