Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4484

General programming discussion • How to use "pinctrl poll" in bash script?

$
0
0
Hi all

I use bash for my hardware projects because it is the only "language" i know.
To query a switch for example i use something like this:

Code:

while true; doif [ "$(pinctrl lev ${SWITCHPIN})" = "0" ]; then  echo "switch pressed!"fisleep 0.1done
I know it is ugly but it works. ;)
I ask me if there is a better way by using "pinctrl poll" option?
Something like:

Code:

while [ "$(pinctrl poll ${SWITCHPIN})" = "?" ]; do  echo "switch pressed!"done
Does anyone have any ideas on how this could be implemented?
Does it even make sense to change this (for example to save resources?).

Many thanks and greetings.

Statistics: Posted by The_Raven — Fri Dec 13, 2024 1:45 pm — Replies 0 — Views 16



Viewing all articles
Browse latest Browse all 4484

Trending Articles