예제 #1
0
 public function __construct(Board $board)
 {
     $this->board = $board;
     $this->pins = [];
     $this->observer = new Observer($board->getLoop());
     $this->observer->on(Observer::EVENT_MODIFY, [$this, 'eventDetect']);
     $this->observer->watch(sprintf('%s/gpio*/value', SysFS::PATH_BASE));
 }
예제 #2
0
파일: PWM.php 프로젝트: calcinai/phpi
 public function __construct(Board $board, $pwm_number)
 {
     $this->board = $board;
     $this->pwm_register = $board->getPWMRegister();
     $this->pwm_number = $pwm_number;
     $this->is_active = false;
     $this->frequency = self::DEFAULT_FREQUENCY;
     $this->setDutyCycle(self::DEFAULT_DUTY_CYCLE);
     $this->setRange(self::DEFAULT_RANGE);
     $this->setEnableMS(false);
 }
예제 #3
0
파일: info.php 프로젝트: calcinai/phpi
/**
 * @param \Calcinai\PHPi\Board $board
 * @param $gpio_number
 * @return stdClass
 */
function getPinAttributes($board, $gpio_number)
{
    $attributes = new stdClass();
    //So it can be rendered anyway
    if ($gpio_number === null) {
        $attributes->function = null;
        $attributes->level = null;
    } else {
        $pin = $board->getPin($gpio_number);
        $attributes->function = $pin->getFunctionName();
        $attributes->level = $pin->getLevel();
    }
    return $attributes;
}
예제 #4
0
 private function start()
 {
     if ($this->isActive()) {
         $this->stop();
     }
     $this->timer = $this->board->getLoop()->addPeriodicTimer($this->poll_interval, [$this, 'checkStatusRegisters']);
 }
예제 #5
0
파일: Pin.php 프로젝트: calcinai/phpi
 public function eventListenerRemoved()
 {
     //If it's the last event, there's the internal one for change->high/low so this is 1
     if ($this->countListeners() === 1) {
         $this->board->getEdgeDetector()->removePin($this);
         $this->removeAllListeners();
     }
 }
예제 #6
0
파일: SPI.php 프로젝트: calcinai/phpi
 public function __construct(Board $board, $spi_number)
 {
     $this->board = $board;
     $this->spi_number = $spi_number;
     $this->spi_register = $board->getSPIRegister();
 }