From 81bedda5aaa597acb1753d7b812614959182b9f7 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 23 May 2004 15:08:38 +0000 Subject: [PATCH] fancier --- misc/divider-table.pl | 48 ++++++++++++++++++++++++++++--------------- pcb/Makefile | 7 ++++--- pic.make | 7 ++++--- spice/Makefile | 7 ++++--- 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/misc/divider-table.pl b/misc/divider-table.pl index 6b5a6ab..fbd6c6a 100755 --- a/misc/divider-table.pl +++ b/misc/divider-table.pl @@ -10,7 +10,7 @@ our ($tlin,$tlog,@byrat); sub thead ($$) { my ($t,$h) = @_; - $$t = sprintf "%-10s |", $h; + $$t = sprintf "%-12s |", $h; } sub chead ($$) { my ($t,$h) = @_; @@ -18,30 +18,42 @@ sub chead ($$) { } sub theadend ($) { my ($t) = @_; - $$t .= "\n".('-'x(10+1)).'+'.('-'x(24*6))."\n"; + $$t .= "\n".('-'x(12+1)).'+'.('-'x(24*6))."\n"; } sub rhead ($$) { my ($t,$h) = @_; - $$t .= sprintf "%10s |", $h; + $$t .= sprintf "%12s |", $h; } sub cell ($$) { my ($t,$v) = @_; - $$t .= sprintf " %5.3f", $v; + $$t .= sprintf " %5s", $v; } sub rend ($$) { my ($t,$n) = @_; $$t .= "\n"; - $$t .= "\n" if ($n % 4) == 3; + $$t .= "\n" if (($n+1) % 6) == 0; } sub tend ($) { my ($t) = @_; } +sub mul10fit ($$) { + my ($v,$len) = @_; + while (length(sprintf "%d", $v) < $len) { $v *= 10.0; } + return sprintf "%d", $v; +} +sub fracfit ($$) { + my ($v,$len) = @_; + $v= sprintf "%".($len+2).".${len}f", $v; + $v =~ s/^\d\.//; + return $v; +} + sub scan () { my ($row,$col,$lin,$log,$rownum); @byrat = (); - thead(\$tlin,'Row/Col'); - thead(\$tlog,'L(R/C)+1'); + thead(\$tlin,'X/Y [*10^k]'); + thead(\$tlog,'frac(L(X/Y))'); for $col (@e24) { chead(\$tlin,$col); chead(\$tlog,$col); @@ -55,8 +67,10 @@ sub scan () { for $col (@e24) { $lin= $col*1.0 / $row; $log= log($lin)/log(10) + 1.0; - cell(\$tlin,$lin); - cell(\$tlog,$log); + + cell(\$tlin, mul10fit($lin,5)); + cell(\$tlog, fracfit($log,5)); + if ($col < $row) { $lin *= 10; } next if $row==$col; push @byrat, { Num => $col, @@ -90,24 +104,24 @@ sub sortbyrat () { sub byratcol ($$$) { my ($or,$cwr,$colnum) = @_; $$or .= ' ' if $colnum; - $$cwr = ($colnum<4 ? 7 : 6); + $$cwr = ($colnum<6 ? 6 : 5); } sub printbyrat () { use integer; - my ($brcols) = 7; + my ($brcols) = 8; my ($brrows) = (@byrat+$brcols-1) / $brcols; my ($byrat,$o,$colnum,$rownum,$cw); $o= ''; for ($colnum=0; $colnum<$brcols; $colnum++) { byratcol(\$o,\$cw,$colnum); - $o .= sprintf(" N/D %${cw}s %7s", - 'Q[*10]','Lg(Q)+1'); + $o .= sprintf("N/D %".($cw+1)."s %s", + 'Q*10^k','fc(Lg)'); } $o .= "\n"; for ($colnum=0; $colnum<$brcols; $colnum++) { byratcol(\$o,\$cw,$colnum); - $o .= '-' x (5+1+$cw+1+7); + $o .= '-' x (5+1+$cw+1+5); } $o .= "\n"; for ($rownum=0; $rownum<$brrows; $rownum++) { @@ -115,15 +129,17 @@ sub printbyrat () { $byrat= $byrat[$colnum*$brrows + $rownum]; next unless defined $byrat; byratcol(\$o,\$cw,$colnum); - $o .= sprintf("%2s/%-2s %${cw}.".($cw-2)."f %7.5f", + $o .= sprintf("%2s/%-2s %${cw}s %s", $byrat->{Num}, $byrat->{Den}, - $byrat->{Lin}, $byrat->{Log}); + mul10fit($byrat->{Lin}, $cw), + fracfit($byrat->{Log}, 5)); } $o .= "\n"; } print $o or die $!; } +print "\n" or die $!; scan(); ptable($tlin); ptable($tlog); diff --git a/pcb/Makefile b/pcb/Makefile index 1014ab6..7395a27 100644 --- a/pcb/Makefile +++ b/pcb/Makefile @@ -39,12 +39,13 @@ bulkres-items.partlist: ./farnell-resistor-convert.pl