master
András Veres-Szentkirályi 2013-10-01 10:16:41 +02:00
commit 9b6264ea6c
2 zmienionych plików z 44 dodań i 0 usunięć

39
beacon.py 100644
Wyświetl plik

@ -0,0 +1,39 @@
#!/usr/bin/env python
"""
This example streams the raw floating point (freq, msec) tuples to stdout
in 4-byte single precision format (8 bytes per tuple), so that it can be
processed outside PySSTV.
Usage example using unixsstv/gen_values:
beacon.py | gen_values 44100 | play -r 44100 -t f32 -c 1 --norm -
"""
from pysstv.sstv import SSTV
from PIL import Image, ImageFont, ImageDraw
from pysstv.color import MartinM2
from subprocess import check_output
from cStringIO import StringIO
import RPi.GPIO as GPIO
import struct, sys
TX_PIN = 18
def main():
img = Image.open(StringIO(check_output(['raspistill', '--output', '-',
'--width', '320', '--height', '256', '-e', 'bmp'])))
img = img.resize((MartinM2.WIDTH, MartinM2.HEIGHT))
font = ImageFont.load_default()
draw = ImageDraw.Draw(img)
draw.text((17, 17), "HA5KDR", (0, 0, 0), font=font)
draw.text((16, 16), "HA5KDR", (255, 255, 255), font=font)
sstv = MartinM2(img, 44100, 16)
sstv.vox_enabled = True
for freq, msec in sstv.gen_freq_bits():
sys.stdout.write(struct.pack('ff', freq, msec))
GPIO.setmode(GPIO.BCM)
GPIO.setup(TX_PIN, GPIO.OUT)
GPIO.output(TX_PIN, True)
if __name__ == '__main__':
main()

5
beacon.sh 100644
Wyświetl plik

@ -0,0 +1,5 @@
#!/bin/sh
python /home/pi/beacon.py | /home/pi/unixsstv/gen_values 44100 >/tmp/wav.bin
play -q -r 44100 -t f32 -c 1 --norm /tmp/wav.bin >/dev/null 2>&1
python -c 'import RPi.GPIO as G; G.setmode(G.BCM); G.setup(18, G.OUT); G.output(18, False); G.cleanup()' >/dev/null 2>&1
rm -f /tmp/wav.bin