mirror of
https://github.com/JDM170/orangepi_coolfan
synced 2025-12-10 05:57:21 +07:00
Update script, added script with using wiringOP
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
|
||||
# Physical | V | Mode | Name | wPi | GPIO
|
||||
# 8 | 0 | OUT | TXD.3 | 3 | 13
|
||||
readonly FAN_PIN=13
|
||||
readonly FAN_PIN="13"
|
||||
readonly FAN_PATH=/sys/class/gpio/gpio${FAN_PIN}
|
||||
|
||||
readonly MSG_ON='Fan ON!'
|
||||
readonly MSG_OFF='Fan OFF!'
|
||||
readonly MSG_ON="Fan ON!"
|
||||
readonly MSG_OFF="Fan OFF!"
|
||||
old_state=$(cat $FAN_PATH/value)
|
||||
|
||||
initialize()
|
||||
setup()
|
||||
{
|
||||
echo $FAN_PIN > /sys/class/gpio/export
|
||||
echo 'out' > $FAN_PATH/direction
|
||||
echo "out" > $FAN_PATH/direction
|
||||
echo 0 > $FAN_PATH/value
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ cleanup()
|
||||
|
||||
trap cleanup 15
|
||||
|
||||
/usr/bin/coolfan-control initialize
|
||||
/usr/bin/coolfan-control setup
|
||||
|
||||
while :; do
|
||||
echo $$ > /var/run/coolfan.pid
|
||||
46
using_wiringOP/coolfan-control
Normal file
46
using_wiringOP/coolfan-control
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Physical | V | Mode | Name | wPi | GPIO
|
||||
# 8 | 0 | OUT | TXD.3 | 3 | 13
|
||||
readonly FAN_PIN="3"
|
||||
|
||||
readonly MSG_ON="Fan ON!"
|
||||
readonly MSG_OFF="Fan OFF!"
|
||||
|
||||
setup()
|
||||
{
|
||||
gpio export $FAN_PIN
|
||||
gpio mode $FAN_PIN out
|
||||
gpio write $FAN_PIN 0
|
||||
old_state=$(gpio read $FAN_PIN)
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
gpio write $FAN_PIN 0
|
||||
gpio unexport $FAN_PIN
|
||||
}
|
||||
|
||||
on()
|
||||
{
|
||||
gpio write $FAN_PIN 1
|
||||
}
|
||||
|
||||
off()
|
||||
{
|
||||
gpio write $FAN_PIN 0
|
||||
}
|
||||
|
||||
case $1 in
|
||||
on|off) "$1";;
|
||||
esac
|
||||
|
||||
cur_state=$(gpio read $FAN_PIN)
|
||||
|
||||
if [ "$old_state" != "$cur_state" ] && [ -z "$2" ]; then
|
||||
if [ "$cur_state" = 0 ]; then
|
||||
echo $MSG_OFF
|
||||
else
|
||||
echo $MSG_ON
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user