build some test apparati to understand how the fuck raspi gpio works

This commit is contained in:
Shoofle 2024-08-04 13:12:16 -04:00
parent 03c3f1a9f1
commit 996f417185
3 changed files with 70 additions and 1 deletions

View File

@ -7,6 +7,7 @@ name = "pypi"
opencv-python = "*"
wakepy = "*"
numpy = "*"
gpiod = "*"
[dev-packages]

25
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "7b5a783544ab25fe0461f649a9e204e85f0fae1e9864e057c5ce075d5cb63eca"
"sha256": "e78ccaf8491e77e82aac4cd05d50a028edc6c8e458f5a6da1d3dc50fc63a1591"
},
"pipfile-spec": 6,
"requires": {
@ -16,6 +16,29 @@
]
},
"default": {
"gpiod": {
"hashes": [
"sha256:01e8bd567288ecc0eb306d8a345e0bf3c3f0478310acc06cd4af778375a7ce1c",
"sha256:2c797213031d7c6751b7d7674c3ce6965e1af157cbcf2b435b4652f156f1a7d4",
"sha256:51ba8e0e92e9b986b1d7aa4071617b3948d4fc69bfdef68e7d8b94aec8e56e54",
"sha256:5fd077dc8933eeb1be2da78980aa4c53812119a6773d73060c7b5a1e30886373",
"sha256:60ae4f307a5e138854c012df31c58b9d9405b932cdc6c65c62734a0c57d4ef46",
"sha256:63f2466d04bd275ff669a3c47517d24e9cbbcbf0ef11af540de6e5cbe6d6ad36",
"sha256:71700d4d2eb7d3b573a01ea7a05a676538fa19d2cf1eab9e4f1f56feceda2754",
"sha256:76a766d5f17d4be82c973b04af918c32006a92524461124f7cfe0ae1c5ec5075",
"sha256:802dad3a89016339a231c462c6da2d56c820f5fb11519728ff86cdff0a16da96",
"sha256:8680647c289f27c05d64a8efe06d8cb0f664b3b7de1f9c6438bbf73f60601133",
"sha256:872637851ecfb6fe04483913a2f173150fa46f3b23f72fa7a1739857893eaed0",
"sha256:9c84efbd9c79be7cc48cbe51eedf266c7ff705adfe748f7f0345a1ce616ab1bf",
"sha256:aa4e2651cd501402b022958fa73fa211876b8dc8ac799c2e9c429f48469d1f01",
"sha256:bd0d34a2ad82f81a799d47e22060b51f6687c43d84fed1f58ebc0d1be73b341a",
"sha256:db7ed970ada7f62e3f9049ba36b12922a08199c1e04674ba6a28b11a5aa35695",
"sha256:e2d5dca742f6da10236cb73c3754b65899d3ed377951b4878d307a71e1038751",
"sha256:fae5130a0b7130923c4996e48a151ab1da622ded40c44fe840384ad21478e39f"
],
"index": "pypi",
"version": "==2.2.1"
},
"jeepney": {
"hashes": [
"sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806",

45
lines_test.py Normal file
View File

@ -0,0 +1,45 @@
import gpiod, time
from gpiod.line import Direction, Value
#lines_test.py
lines = {
"five_second": 2,
"thirty_second": 3,
"five_minute": 4,
"twelve_hour": 5,
"twenty_four_hour": 6
}
def tellme(iolines, label):
value = iolines.get_value(lines[label])
if not value:
print(f"{label} is inactive with value {value}")
return True
return False
#with keep.presenting():
with gpiod.request_lines(
"/dev/gpiochip4",
consumer="mirror-to-yesterday",
config={
lines["five_second"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["thirty_second"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["five_minute"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["twelve_hour"]: gpiod.LineSettings(direction=Direction.INPUT),
lines["twenty_four_hour"]: gpiod.LineSettings(direction=Direction.INPUT)
}
) as io_lines:
while True:
if tellme(io_lines, "five_second"):
pass
elif tellme(io_lines, "thirty_second"):
pass
elif tellme(io_lines, "five_minute"):
pass
elif tellme(io_lines, "twelve_hour"):
pass
elif tellme(io_lines, "twenty_four_hour"):
pass
else:
print("none are active")
time.sleep(0.5)