Exemple #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));
 }
Exemple #2
0
 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);
 }
Exemple #3
0
/**
 * @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;
}
Exemple #4
0
 private function start()
 {
     if ($this->isActive()) {
         $this->stop();
     }
     $this->timer = $this->board->getLoop()->addPeriodicTimer($this->poll_interval, [$this, 'checkStatusRegisters']);
 }
Exemple #5
0
 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();
     }
 }
Exemple #6
0
 public function __construct(Board $board, $spi_number)
 {
     $this->board = $board;
     $this->spi_number = $spi_number;
     $this->spi_register = $board->getSPIRegister();
 }