From: Dobrica Pavlinusic Date: Fri, 24 Nov 2017 08:14:44 +0000 (+0100) Subject: find connectors and flip vertical pins inside them X-Git-Url: http://git.rot13.org/?p=linux-gpio-pinout;a=commitdiff_plain;h=5503d8eb06da6e17b83237d042d2c247a1c27d14 find connectors and flip vertical pins inside them --- diff --git a/gpio.pl b/gpio.pl index 5395ac5..9b02c48 100755 --- a/gpio.pl +++ b/gpio.pl @@ -167,7 +167,7 @@ while(<$pio>) { # annotate input 0 and output 1 pins # annotate_pin $p[0], ( $p[1] ? 'O' : 'I' ) . ':' . $p[4] if $p[1] == 0 || $p[1] == 1; my $pin = shift @p; - annotate_pin $pin, join(' ',@p); + annotate_pin $pin, join(' ',@p) if ! $opt_svg; } close($pio); @@ -373,8 +373,37 @@ sub line { my $last_cut_mark = 0; +sub connector { + my ( $from, $to ) = @_; + warn "# connector $from - $to ",dump( $line_parts[$from], $line_parts[$to] ); + if ( $opt_vertical ) { + foreach my $i ( 0 .. int(($to-$from)/2) ) { + my $t = $line_parts[$from + $i]; + $line_parts[$from + $i] = $line_parts[$to - $i]; + $line_parts[$to - $i] = $t; + } + } +} + +my $from; +my $to; +foreach my $i ( 0 .. $#line_parts ) { + next if $line_parts[$i]->[0] =~ m/^###/; + if (exists $line_parts[$i]->[1]) { + if (! $from) { + $from = $i; + } else { + $to = $i; + } + } elsif ($from && $to) { + connector $from => $to; + $from = $to = undef; + } +} +connector $from => $to if $from && $to; + foreach my $i ( 0 .. $#line_parts ) { - $i = $#line_parts - $i if $opt_vertical; +# $i = $#line_parts - $i if $opt_vertical; my $line = $line_parts[$i]; if ( $opt_svg ) {