-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The sysfs GPIO ABI has been deprecated in 2015 and Raspberry Pi OS bookworm no longer supports it.
- Loading branch information
1 parent
fffc85a
commit 313116f
Showing
8 changed files
with
50 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
ensure_pigpiod() { | ||
local TRIES | ||
if ! which socat pigpiod pigs >/dev/null; then | ||
echo Please install all of the following packages: | ||
echo sudo apt install socat pigpiod pigpio-tools | ||
exit 1 | ||
fi | ||
socat OPEN:/dev/null TCP6:localhost:8888 2>/dev/null && return | ||
socat OPEN:/dev/null TCP4:localhost:8888 2>/dev/null && return | ||
if ! sudo systemctl start pigpiod.service; then | ||
echo "Could not start pigpiod.service; please fix." | ||
exit 1 | ||
fi | ||
TRIES=15 | ||
while [ $TRIES -gt 0 ]; do | ||
socat OPEN:/dev/null TCP6:localhost:8888,retry=1,interval=0.1 2>/dev/null && break | ||
socat OPEN:/dev/null TCP4:localhost:8888,retry=1,interval=0.1 2>/dev/null && break | ||
TRIES=$((TRIES - 1)) | ||
done | ||
if [ $TRIES -eq 0 ]; then | ||
echo Timed out waiting for pigpiod to start | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -d /sys/class/gpio/gpio25 ] | ||
then | ||
echo "25" > /sys/class/gpio/export | ||
fi | ||
. ./functions.sh | ||
|
||
ensure_pigpiod | ||
pigs modes 25 w write 25 0 | ||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio25/direction | ||
echo 0 > /sys/class/gpio/gpio25/value | ||
sleep 0.1 | ||
echo 1 > /sys/class/gpio/gpio25/value | ||
|
||
pigs write 25 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -d /sys/class/gpio/gpio24 ] | ||
then | ||
echo "24" > /sys/class/gpio/export | ||
fi | ||
. ./functions.sh | ||
|
||
ensure_pigpiod | ||
pigs modes 24 w write 24 0 | ||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio24/direction | ||
echo 0 > /sys/class/gpio/gpio24/value | ||
sleep 0.1 | ||
echo 1 > /sys/class/gpio/gpio24/value | ||
|
||
pigs write 24 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -d /sys/class/gpio/gpio18 ] | ||
then | ||
echo "18" > /sys/class/gpio/export | ||
fi | ||
. ./functions.sh | ||
|
||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio18/direction | ||
echo "1" > /sys/class/gpio/gpio18/value | ||
ensure_pigpiod | ||
pigs modes 18 w write 18 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -d /sys/class/gpio/gpio18 ] | ||
then | ||
echo "18" > /sys/class/gpio/export | ||
fi | ||
. ./functions.sh | ||
|
||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio18/direction | ||
echo "0" > /sys/class/gpio/gpio18/value | ||
ensure_pigpiod | ||
pigs modes 18 w write 18 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
#!/bin/sh | ||
|
||
. ./functions.sh | ||
|
||
if [ "$1" != "0" ] && [ "$1" != "1" ]; then | ||
echo "Needs an argument of 0 or 1" | ||
exit 0 | ||
fi | ||
|
||
if [ ! -d /sys/class/gpio/gpio21 ] | ||
then | ||
echo "21" > /sys/class/gpio/export | ||
fi | ||
|
||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio21/direction | ||
echo $1 > /sys/class/gpio/gpio21/value | ||
ensure_pigpiod | ||
pigs modes 21 w write 21 $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -d /sys/class/gpio/gpio21 ] | ||
then | ||
echo "21" > /sys/class/gpio/export | ||
fi | ||
. ./functions.sh | ||
|
||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio21/direction | ||
echo "0" > /sys/class/gpio/gpio21/value | ||
ensure_pigpiod | ||
pigs modes 21 w write 21 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -d /sys/class/gpio/gpio21 ] | ||
then | ||
echo "21" > /sys/class/gpio/export | ||
fi | ||
. ./functions.sh | ||
|
||
sleep 0.1 | ||
echo "out" > /sys/class/gpio/gpio21/direction | ||
echo "1" > /sys/class/gpio/gpio21/value | ||
ensure_pigpiod | ||
pigs modes 21 w write 21 1 |