From 424193cb1859de0ef4904edef45d6d021e9d3588 Mon Sep 17 00:00:00 2001 From: realraum Date: Wed, 1 Feb 2012 23:08:52 +0000 Subject: [PATCH] added conversion to binary form --- rf433rcv/pc/data2sample.pl | 20 ++++++++++++++++++++ rf433rcv/pc/sample2data.pl | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 rf433rcv/pc/data2sample.pl create mode 100755 rf433rcv/pc/sample2data.pl diff --git a/rf433rcv/pc/data2sample.pl b/rf433rcv/pc/data2sample.pl new file mode 100755 index 0000000..2690012 --- /dev/null +++ b/rf433rcv/pc/data2sample.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl +use strict; +my $base=shift @ARGV; + +my @input= split //,<>; + +print 1 x $base; +print 0 x (31 * $base); + +for my $current (@input) +{ + if ($current) + { + print 1 x (3*$base); + print 0 x $base; + } else { + print 1 x $base; + print 0 x (3*$base); + } +} diff --git a/rf433rcv/pc/sample2data.pl b/rf433rcv/pc/sample2data.pl new file mode 100755 index 0000000..57afafe --- /dev/null +++ b/rf433rcv/pc/sample2data.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use strict; +my @input= split //,<>; + +my $zero=0; +my $one=0; +my $last=0; +my $timebase; +for my $current (@input) +{ + if (($current != $last) and ($current == 1) ) + { + print (($zero>$one)?"0":"1") if $one; #skip first=sync + $timebase = (($zero>$one)?$one:$zero); + #print "$zero,$one\n"; + $zero=0; + $one=0; + } + if ($current) + { + $one++ + } else { + $zero++ + } + $last=$current; +} +#print "\n"; +warn "Base $timebase\n"; -- 1.7.10.4