1 | <?php |
||
17 | class RPiAdapter implements AdapterInterface |
||
18 | { |
||
19 | |||
20 | const GPIO_PATH = "/sys/class/gpio"; |
||
21 | |||
22 | /** |
||
23 | * Set the direction of the pin (input or output) |
||
24 | * |
||
25 | * @param int $pin The BCM pin number |
||
26 | * @param string $direction The type/direction of the pin - Use GPIO::IN and GPIO::OUT |
||
27 | * @param bool $invert Invert the logic so that high->low and low->high |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function setDirection(int $pin, string $direction, bool $invert = false): bool |
||
58 | |||
59 | /** |
||
60 | * Write a value to an output pin. |
||
61 | * |
||
62 | * @param int $pin The BCM pin number. |
||
63 | * @param int $value The output value (0,1) - Use GPIO::HIGH and GPIO::LOW |
||
64 | * @return bool |
||
65 | */ |
||
66 | public function write(int $pin, int $value): bool |
||
78 | |||
79 | /** |
||
80 | * Read the value of an input/output pin. |
||
81 | * |
||
82 | * @param int $pin The BCM pin number |
||
83 | * @return int The current value of the pin. |
||
84 | * @throws GPIOException |
||
85 | */ |
||
86 | public function read(int $pin): int |
||
93 | |||
94 | /** |
||
95 | * Exports the Pin (enabling it's use) |
||
96 | * |
||
97 | * @param int $pin The pin to export/enable. |
||
98 | * @return bool |
||
99 | */ |
||
100 | private function export(int $pin) |
||
109 | } |