Example #1
0
 public function removePin(Pin $pin)
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     list($bank, $mask, $shift) = $pin->getAddressMask();
     unset($this->pins[$bank][$shift]);
     $this->updateDetectRegisters();
 }
Example #2
0
 public function pulse($iterations = null, $interval = 1, $duty = 0.5)
 {
     $this->on();
     $on_time = $interval * $duty;
     $this->pin->getBoard()->getLoop()->addTimer($on_time, [$this, 'off'])->getLoop()->addPeriodicTimer($interval, function (TimerInterface $timer) use(&$iterations, $on_time) {
         if ($iterations !== null && --$iterations === 0) {
             $timer->cancel();
             return;
         }
         $this->on();
         $timer->getLoop()->addTimer($on_time, [$this, 'off']);
     });
 }
Example #3
0
 public function __construct(Pin $pin)
 {
     $this->pin = $pin;
     $pin->setFunction(Pin\PinFunction::INPUT);
 }
Example #4
0
 public function reverse()
 {
     $this->pin_a->low();
     $this->pin_b->high();
 }
Example #5
0
 public function isExported(Pin $pin)
 {
     return file_exists(sprintf('%s/gpio%s', self::PATH_BASE, $pin->getPinNumber()));
 }