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