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 |
||
47 | |||
48 | /** |
||
49 | * Write a value to an output pin. |
||
50 | * |
||
51 | * @param int $pin The BCM pin number. |
||
52 | * @param int $value The output value (0,1) - Use GPIO::HIGH and GPIO::LOW |
||
53 | * @return bool |
||
54 | */ |
||
55 | public function write(int $pin, int $value): bool |
||
69 | |||
70 | /** |
||
71 | * Read the value of an input/output pin. |
||
72 | * |
||
73 | * @param int $pin The BCM pin number |
||
74 | * @return int The current value of the pin. |
||
75 | * @throws GPIOException |
||
76 | */ |
||
77 | public function read(int $pin): int |
||
84 | |||
85 | /** |
||
86 | * Exports the Pin (enabling it's use) |
||
87 | * |
||
88 | * @param int $pin The pin to export/enable. |
||
89 | * @return bool |
||
90 | */ |
||
91 | private function export(int $pin) |
||
99 | } |