[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: PCB paste layer, revisited.



> Getting a working solder stencil with minimal intervention gets me
> closer to robots.

I'll attach the script I used to "fix" the paste for my furnace board.

> 1) tweak flex and bison to recognize "Paste"
> 2) clone Pad data structure allocation and manipulation code
> 3) during parse, tuck away paste information as encountered
> 4) during parse, if an element is closed without encountering a paste 
> directive, synthesize paste directives that are copies of the pad 
> directives. (Preserves upward compatibility with existing footprint.)
> 5) tweak the printout code to look at the paste data instead of the pad 
> data.

That would be the way.  Don't forget about rotating elements, and undo.


#!/usr/bin/perl
# -*- perl -*-

while (<>) {

    if (/^\s*\)\s*$/) {
	$flag = 0;
    }

    if (/Element\[\"[^\"]*\" \"([^\"]*)\" \"([^\"]*)\" \"([^\"]*)\"/) {
	$element = $1;
	$refdes = $2;
	$value = $3;
	$element = "$element $refdes $value";
#	printf STDERR "Element: $element\n";
    }

    if (/Element\[.* "" "" "" /) {
	while (! /^\s*\)\s*$/) {
	    $_ = <>;
	}
	next;
    }

    if (($x1, $y1, $x2, $y2, $thick, $rest) =
	/Pad\[([\d-]+) ([\d-]+) ([\d-]+) ([\d-]+) ([\d-]+) (.*)\]/) {

	$cx = ($x1 + $x2) / 2;
	$cy = ($y1 + $y2) / 2;
	$w = &abs($x1 - $x2);
	$h = &abs($y1 - $y2);

	if ($element =~ /tqfp32/i) {
	    if ($x1 == $x2) {
		$cy += ($y1 < 0) ? 2000 : -2000;
	    } else {
		$cx += ($x1 < 0) ? 2000 : -2000;
	    }
	}


	if ($element =~ /gumstix/i) {
	    #$thick = 330;
	    $thick = 1180 - 300*2;
	    if ($x1 < 0) {
		$x1 = -6500 - $thick/2;
		$x2 = -9500 + $thick/2;
	    } else {
		$x1 = 6500 + $thick/2;
		$x2 = 9500 - $thick/2;
	    }
	} else {
	    #$thick *= 0.5;
	    $thick *= 0.75;
	    $x1 = $cx - $w/4;
	    $x2 = $cx + $w/4;
	    $y1 = $cy - $h/4;
	    $y2 = $cy + $h/4;
	}

	printf "\tPad[%d %d %d %d %d %s]\n", $x1, $y1, $x2, $y2, $thick, $rest;

    } else {
	print;
    }
}

sub abs {
    my ($v) = @_;
    return $v < 0 ? -$v : $v;
}


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user