#!/usr/bin/perl

my @last;

while(1) {

my @o;
my @pcf = `gpio -x pcf8591:120:0x48 readall`;
my @gpio = `gpio -g readall`;
foreach (@gpio) {
	chomp;
#	next unless /\d\s/;

	# kill wiringpi mapping columns
	s/^(.{8}).{6}/$1/;
	s/.{6}(.{8})$/$1/;

	s/([ \d]{2})(...GPIO.)../$1$2$1/;
	s/(GPIO.)..(...)(\s*\d+)/$1$3$2$3/;

	push @o, $_;
	print $_, shift @pcf || "\n";
}

my $cmd = <STDIN>;

} #/while

