Added comments to device classes
This commit is contained in:
parent
551b9529cc
commit
3713efa6cc
@ -55,6 +55,10 @@ abstract class Device implements GpioAwareInterface
|
||||
public function getDescription()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Allocate a GPIO (as defined in hardware) pin to the device.
|
||||
*
|
||||
*/
|
||||
public function addGpioPin($gpio, $name, $description=null)
|
||||
{
|
||||
$pin = new GpioPin($gpio);
|
||||
@ -62,6 +66,10 @@ abstract class Device implements GpioAwareInterface
|
||||
$this->pins[$name] = $pin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a logical (wiring-pi 0-based pin number) pin to the device.
|
||||
*
|
||||
*/
|
||||
public function addLogicalPin($logical, $name, $description=null)
|
||||
{
|
||||
$pin = $this->gpio[$logical];
|
||||
@ -69,15 +77,32 @@ abstract class Device implements GpioAwareInterface
|
||||
$this->pins[$name] = $pin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all allocated pins
|
||||
*
|
||||
*/
|
||||
public function getPins()
|
||||
{
|
||||
return $this->pins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pin by the name specified when allocating it
|
||||
*
|
||||
*/
|
||||
public function getPin($name)
|
||||
{
|
||||
return $this->pins[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pin as a property from its name
|
||||
*
|
||||
*/
|
||||
protected function __get($pin_name)
|
||||
{
|
||||
return $this->getPin($pin_name);
|
||||
}
|
||||
|
||||
public function delayMillis($ms)
|
||||
{}
|
||||
@ -85,8 +110,4 @@ abstract class Device implements GpioAwareInterface
|
||||
public function delayMicros($us)
|
||||
{}
|
||||
|
||||
public function __get($pin_name)
|
||||
{
|
||||
return $this->getPin($pin_name);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class Pcd8544Device extends Device
|
||||
->addLogicalPin(1, "sce", "chip select")
|
||||
->addLogicalPin(2, "scl", "clock")
|
||||
->addLogicalPin(3, "sda", "data")
|
||||
->addLogicalPin(4, "res", "reset")
|
||||
->addLogicalPin(9, "bl", "backlight")
|
||||
;
|
||||
}
|
||||
@ -43,6 +44,6 @@ class Pcd8544Device extends Device
|
||||
|
||||
public function setBacklightState($state)
|
||||
{
|
||||
$this->bl->write((int)$state);
|
||||
$this->bl->setValue((bool)$state);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user