mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 02:54:01 +08:00
version: dragonpilot v2022.09.07 release for EON/C2
date: 2022-09-07T07:01:54
dp-dev(priv2) beta2 commit: 30a852791f
15 lines
470 B
Python
15 lines
470 B
Python
def gpio_init(pin: int, output: bool) -> None:
|
|
try:
|
|
with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
|
|
f.write(b"out" if output else b"in")
|
|
except Exception as e:
|
|
print(f"Failed to set gpio {pin} direction: {e}")
|
|
|
|
|
|
def gpio_set(pin: int, high: bool) -> None:
|
|
try:
|
|
with open(f"/sys/class/gpio/gpio{pin}/value", 'wb') as f:
|
|
f.write(b"1" if high else b"0")
|
|
except Exception as e:
|
|
print(f"Failed to set gpio {pin} value: {e}")
|