-
Notifications
You must be signed in to change notification settings - Fork 2
/
sstv-threaded.sh
executable file
·78 lines (62 loc) · 1.81 KB
/
sstv-threaded.sh
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
#!/bin/bash
#
# SSTV Daemon
#
# This script will grab an image from a webcam,
# compile it as an SSTV image (Martin 1 or
# Robot 36) and then transmit it using the
# Dorji module.
#
# (C) Andrew Koenig 2014
GPIO=22 # GPIO Pin
PAN=2:0:1 # Left/Right Audio R -> 2:0:1 L -> 2:1:0
TXDELAY=.5 # Time (in seconds)
CYCLE=0 # Cycle time (seconds)
PROTOCOL=r36 # Martin 1 (m1), Robot 36 (r36), Scottie DX (sdx)
WAV=/mnt/ramdisk/image.png.wav
IMG=/mnt/ramdisk/image.png
COUNT=1
while ! [ -f /mnt/ramdisk/kill_sstv ] ; do
# Establish start time
TIME=`date +%s`
# Establish the serial port
SERIAL=`cat /home/pi/balloon/.radio`
/home/pi/balloon/freq.py 144.5000 144.5000 0015 $SERIAL > /dev/null 2>&1
# Send Martin 1 every 5 images
# if [ $(($COUNT % 5)) -eq 0 ] ; then
# PROTOCOL=sdx
# else
# PROTOCOL=r36
# fi
# Take picture
echo -n "Taking picture.. "
fswebcam --top-banner --title "K5UTD High Alt. Balloon" --subtitle 'Now in technicolor!' -S 120 $IMG > /dev/null 2>&1
echo "done!"
# Compile image into SSTV
echo -n "Compiling SSTV wav file... "
sstv -r 22050 -p $PROTOCOL $IMG > /dev/null 2>&1
echo "done!"
# Compile APRS packets while transmitting SSTV
/home/pi/balloon/aprs-threaded-compile.sh &
# Transmit
echo -n "Transmitting... "
echo 0 > /sys/class/gpio/gpio$GPIO/value
sleep $TXDELAY
mplayer $WAV -af pan=$PAN > /dev/null 2>&1
echo 1 > /sys/class/gpio/gpio$GPIO/value
echo "done!"
# Run the APRS script
/home/pi/balloon/freq.py 144.3900 144.3900 0015 $SERIAL > /dev/null 2>&1
/home/pi/balloon/aprs-threaded-transmit.sh
# Counter
COUNT=$(($COUNT + 1))
# Sleep
TIME=$(($(date +%s) - $TIME))
echo Executing took $TIME seconds, iteration number $COUNT
if [ $(($CYCLE - $TIME)) -gt 0 ] ; then
echo Sleeping $(($CYCLE - $TIME)) seconds...
sleep $(($CYCLE - $TIME))
else
echo Not sleeping...
fi
done