From 9b6264ea6c99fe41ae0121e8ca3f1dd9a712e70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Tue, 1 Oct 2013 10:16:41 +0200 Subject: [PATCH] initial commit --- beacon.py | 39 +++++++++++++++++++++++++++++++++++++++ beacon.sh | 5 +++++ 2 files changed, 44 insertions(+) create mode 100644 beacon.py create mode 100644 beacon.sh diff --git a/beacon.py b/beacon.py new file mode 100644 index 0000000..b58c6ed --- /dev/null +++ b/beacon.py @@ -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() diff --git a/beacon.sh b/beacon.sh new file mode 100644 index 0000000..6d60e17 --- /dev/null +++ b/beacon.sh @@ -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