-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstfx.config
More file actions
executable file
·140 lines (122 loc) · 4.54 KB
/
Copy pathstfx.config
File metadata and controls
executable file
·140 lines (122 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/vi
#
# stfx.config - sample template for site-specific customised routines.
# Copyright (C) 2014 Phill W.J. Rogers
# PhillRogers_at_JerseyMail.co.uk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Please see stfx.sh for more info.
# Consider:
# add more I/O: 433MHz, 17.5-18.5kHz, PiFm, espeak/festival
#
repeats=off
vlc_http_password=$(awk -F= '/http-password/{print $2}' public/VLCPortable/Data/settings/vlcrc)
fn_init() {
# set all interfaces to initial state
[ ! -w /dev/i2c-0 -o ! -w /dev/i2c-1 ] && gpio load i2c
[ ! -w /dev/spidev0.0 -o ! -w /dev/spidev0.1 ] && gpio load spi
./led_strip_grey 0 >/dev/null
p=25 ; gpio -g mode $p out ; gpio -g write $p 0
p=4 ; gpio -g mode $p out ; gpio -g write $p 0
amixer cset numid=3 1 > /dev/null 2>&1 # force effects sounds to analogue
./led_strip_grey 0 >/dev/null
ps -ef | egrep -q "servo[d]" || sudo servod --pcm --min=0% --max=100% --p1pins=12 2>/dev/null
# Note that servod must not be allowed to grab all the pins if there are other peripherals
sudo sh -c "TERM=linux setterm -foreground black >/dev/tty0"
sudo sh -c "TERM=linux setterm -cursor off -clear >/dev/tty0"
cat /dev/zero > /dev/fb0 2>/dev/null
}
fn_cleanup() {
# set all interfaces to clean state
./led_strip_grey 0 >/dev/null
p=25 ; gpio -g write $p 0 ; mode $p in ; gpio unexport $p
p=4 ; gpio -g write $p 0 ; mode $p in ; gpio unexport $p
cat /dev/zero > /dev/fb0 2>/dev/null
sudo sh -c "TERM=linux setterm -foreground white -cursor on -clear >/dev/tty0"
# rm -f *.jpg *.cache
}
fn_action() {
set $*
# printf "=>%s<=\n" "$*" >> debug.log
if [ "$1" = "secondscreen" ] ; then
# write directly to frame buffer using pre-cached blobs as its the only way fast enough
if [ "$2" = "image" ] ; then
# secondscreen image seconds MyImage.jpg
s=$3
f=cache/image-"${4}".fb
[ -f "${f}" ] && ( cat "${f}" > /dev/fb0 ; sleep $s ; cat /dev/zero > /dev/fb0 2>/dev/null ) &
fi
if [ "$2" = "text" ] ; then
# secondscreen text seconds Meanwhile, back in Sanfrancisco!
s=$3 ; shift ; shift ; shift ; m="$*"
(
f=cache/text-$(echo $m | cksum | cut -d' ' -f1).fb
[ -f "${f}" ] && ( cat "${f}" > /dev/fb0 ; sleep $s ; cat /dev/zero > /dev/fb0 2>/dev/null )
) &
fi
fi
if [ "$1" = "spoons" ] ; then
p=4; gpio -g mode $p out; l=$(expr $2 + $(date +"%s"))
while expr $(date +"%s") \<= $l >/dev/null; do gpio -g write $p 1; sleep 0.4; gpio -g write $p 0; sleep 0.2; done &
fi
if [ "$1" = "beep" ] ; then
loop=$(expr 0 + $2)
while expr $loop \> 0 >/dev/null ; do
( p=25 ; gpio -g mode $p out; gpio -g write $p 1; sleep 0.1; gpio -g write $p 0 )
loop=$(expr $loop - 1)
done &
fi
if [ "$1" = "aerosol" ] ; then
p=12; gpio mode $p out; # servoblaster uses P1-headder numbers
# send PWM to servo to depress the aerosol
( echo "P1-$p=2000us" > /dev/servoblaster ; sleep $2 ; echo "P1-$p=1500us" > /dev/servoblaster ) &
fi
if [ "$1" = "aerosol-test" ] ; then
p=12; gpio mode $p out; # servoblaster uses P1-headder numbers
# send PWM to servo to just wave and not depress the aerosol
( echo "P1-$p=1000us" > /dev/servoblaster ; sleep $2 ; echo "P1-$p=1500us" > /dev/servoblaster ) &
fi
if [ "$1" = "leds" ] ; then
if [ "$2" = "grey" ] ; then
./led_strip_grey $3 &
fi
[ "$2" = "fuzz" ] && ./led_strip_car-fuzz1 &
[ "$2" = "plod" ] && ./led_strip_car-plod1 &
[ "$2" = "knightrider" ] && ./led_strip_car-knightrider &
fi
if [ "$1" = "subwoofer" ] ; then
play -q -n synth $2 sin 34 fade t 1 0 1 2>/dev/null &
fi
if [ "$1" = "fan" ] ; then
( p=22; gpio -g mode $p out; gpio -g write $p 1; sleep $2; gpio -g write $p 0 ) &
fi
if [ "$1" = "raspistill" ] ; then
(
ts=$(date +"%Y%m%d-%H%M%S")
raspistill -o $ts.jpg -w 1920 -h 1080 -q 100 -t 1 -n
) &
fi
if [ "$1" = "raspivid" ] ; then
(
ts=$(date +"%Y%m%d-%H%M%S")
ms=$(expr 1000 \* $2)
raspivid -o $ts.mp4 -n -t $ms 2>/dev/null
) &
fi
if [ "$1" = "repeats" ] ; then
[ "$2" = "on" ] && repeats=on
[ "$2" = "off" ] && repeats=off
fi
}