--- /dev/null
+
+How to make your own:
+---------------------
+
+Watch / read this first:
+
+* http://www.kicad-pcb.org/display/KICAD/Videos+by+zupnikal
+
+The last two videos should be helpful for how to create a custom .emp file from images.
+
+
+* http://www.re-innovation.co.uk/web12/index.php/en/blog-75/230-adding-logo-to-kicad
+
+If you use linux (which you should), you don't have to use the online-scaler. Just use the scripts!
+
+
+---
+
+
+* Create a folder to hold your new footprint library.
+* Copy the scripts 'make_lib.sh' and 'scale.pl' into that folder.
+* Make sure these files are executable (chmod u+x ...).
+* Copy your custom .emp file into that foler.
+
+* Run the 'make_lib.sh' script as follows:
+
+./make_lib.sh input-file.emp lib-name.mod START END
+
+
+START and END are placeholders for positive integer numbers (1,2,3...) that determine
+the range of created footprint sizes. The units are metric (mm).
+
+The 'lib-name.mod' file will show up in the 'lib' sub-folder. Add it to your pcbnew
+library settings as usual.
+
+Footprints that are created for back-layers are automagically mirrored horizontally.
+To place them onto a back-layer, hover the mouse-pointer over them and press 'f' for 'flip'.
+
--- /dev/null
+
+The 'OSHW_logo_orig.emp' file results in a silkscreen logo with
+about 1.18in height, which may be too large for your project.
+
+Use the scale.pl script to resize it:
+
+scale.pl OSHW_logo_orig.emp new_logo.emp <layer> 5.0mm
+
+or
+
+scale.pl OSHW_logo_orig.emp new_logo.emp <layer> 0.5in
+
+
+Replace <layer> with the KiCad layer you need.
+
+Top copper: 15
+Top silkscreen: 21
+
+To move the object to bottom copper/silkscreen, just place
+the curser over the logo and press 'F' for flip in pcbnew.
+
+
+Now start kicad/pcbnew, go into the library/footprint editor
+("open module editor", it's the icon left to the scissors looking
+like a DIP chip) and click on the "import module" icon, select
+the .emp file of your choice and click OK.
+
+If you want to finish quickly, just click on the "insert module
+into current board icon" (it's the one with the yellow star).
+
+Place the logo where you need it. If the size is still not correct,
+repeat at the beginning.
+
+If the logo doesn't show up on your gerber files, your version
+of kicad still suffers from bug #792399.
+
--- /dev/null
+#!/bin/bash
+
+if [[ $# -ne 4 ]]
+then
+ echo -e "\nusage: $0 input-file.emp library-name.mod <start> <end>. 'start' and 'end' are integer (1,2,3...) sizes in mm (metric)\n"
+ exit
+fi
+
+INPUT_FILE=$1
+LIB_NAME=$2
+RANGE_START=$3
+RANGE_END=$4
+LIB_FOLDER="./lib"
+
+if [[ ! -d $LIB_FOLDER ]]
+then
+ echo -e "\n creating '$LIB_FOLDER' folder\n"
+ mkdir $LIB_FOLDER
+fi
+
+echo -e "\n working...\n"
+
+for number in `seq $RANGE_START $RANGE_END`
+do
+ TMP_FILE=`mktemp`
+ ./scale.pl $INPUT_FILE $TMP_FILE 21 ${number}.0mm
+ perl -pi -e "s/LOGO/${LIB_NAME/%.mod/}_silkscreen-front_${number}mm/" $TMP_FILE
+ cat $TMP_FILE >> ./$LIB_NAME
+ rm $TMP_FILE
+
+ ./scale.pl $INPUT_FILE $TMP_FILE 20 ${number}.0mm
+ perl -pi -e "s/LOGO/${LIB_NAME/%.mod/}_silkscreen-back_${number}mm/" $TMP_FILE
+ cat $TMP_FILE >> ./$LIB_NAME
+ rm $TMP_FILE
+done
+
+for number in `seq $RANGE_START $RANGE_END`
+do
+ TMP_FILE=`mktemp`
+ ./scale.pl $INPUT_FILE $TMP_FILE 15 ${number}.0mm
+ perl -pi -e "s/LOGO/${LIB_NAME/%.mod/}_copper-front_${number}mm/" $TMP_FILE
+ cat $TMP_FILE >> ./$LIB_NAME
+
+ ./scale.pl $INPUT_FILE $TMP_FILE 0 ${number}.0mm
+ perl -pi -e "s/LOGO/${LIB_NAME/%.mod/}_copper-back_${number}mm/" $TMP_FILE
+ cat $TMP_FILE >> ./$LIB_NAME
+done
+
+mv $LIB_NAME $LIB_FOLDER
+
+echo -e "\n done.\n"
--- /dev/null
+#!/usr/bin/perl -W
+
+use feature qw(state);
+
+sub usage();
+
+if(scalar(@ARGV) < 4) {
+ usage();
+}
+
+my $outfile = $ARGV[1];
+my $size = $ARGV[3]; # in 'mm' or in 'in'
+my $factor;
+my $calibration;
+my $layer = $ARGV[2];
+
+open(FILE, '<', $ARGV[0]) || die("cannot open: $!");
+my @infiledata = <FILE>;
+close(FILE);
+
+foreach $line (@infiledata) {
+ my $tmp = $line;
+ state $xmin = 0; # same as 'static xmin = 0;' in C
+ state $xmax = 0;
+ state $ymin = 0;
+ state $ymax = 0;
+ if($tmp =~ m/^(.*Dl)\ (.*)\ (.*)$/) {
+ if($2 <= $xmin) {
+ $xmin = $2;
+ }
+ if($2 >= $xmax) {
+ $xmax = $2;
+ }
+ if($3 <= $ymin) {
+ $ymin = $3;
+ }
+ if($3 >= $ymax) {
+ $ymax = $3;
+ }
+ }
+ if( ($xmax - $xmin) > ($ymax - $ymin) ) {
+ $calibration = ($xmax - $xmin);
+ } else {
+ $calibration = ($ymax - $ymin);
+ }
+ #print $xmin," - ",$xmax," - ",$ymin," - ",$ymax,"\n";
+ #print $calibration;
+}
+
+if($size =~ m/^\d{1,3}\.\d{1,3}in$/) {
+ $size =~ s/in//;
+ $factor = 10000/$calibration*$size; # currently all KiCad native units are in 1/10000 in
+} elsif($size =~ m/^\d{1,3}\.\d{1,3}mm$/) {
+ $size =~ s/mm//;
+ $factor = 10000/$calibration/25.4*$size;
+} else {
+ usage();
+}
+
+open(FILE,'>',$outfile) || die("cannot open: $!");
+foreach $line (@infiledata) {
+ my $tmp = $line;
+ if($tmp =~ m/^(.*Dl)\ (.*)\ (.*)$/) {
+ if( ($layer == 21) || ($layer == 15) ) { # top silkscreen or top copper
+ print FILE $1," ",int($2*$factor)," ",int($3*$factor),"\n";
+ } elsif ( ($layer == 20) || ($layer == 0) ) { # bottom silkscreen or bottom copper - needs horizontal mirroring
+ print FILE $1," ",int((-1)*$2*$factor)," ",int($3*$factor),"\n";
+ }
+ } elsif($tmp =~ m/^T(\d{1})\ 0\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ ([A-Z]{1})\ ([A-Z]{1})\ (-{0,1}\d*)\ (\".*\")$/) {
+ # always print module text on top-silkscreen (layer 21)
+ # printing it on the bottom silkscreen seems to confuse KiCad
+ # and things go haywire (text always appers on 'top'-whatever
+ # when graphics are on 'bottom'-whatever and vice versa).
+ print FILE "T$1 0 ",int($2*$factor)," ",int($3*$factor)," ",int($4*$factor)," ",int($5*$factor)," ",int($6*$factor)," ",$7," ",$8," 21 N ",$10,"\n";
+ } elsif($tmp =~ m/^(.*DP)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)\ (-{0,1}\d*)(.*)$/) {
+ if( ($layer == 0) || ($layer == 15) ) { # on top/bottom copper layer - always print on top-copper to avoid crap. see above
+ print FILE "$1 $2 $3 $4 $5 $6 $7 15\n";
+ } elsif ( ($layer == 20) || ($layer == 21) ) { # on top/bottom silk - always print on top-silk to avoid crap. see above
+ print FILE "$1 $2 $3 $4 $5 $6 $7 21\n";
+ }
+ }
+ else {
+ print FILE $line;
+ }
+}
+close(FILE);
+
+sub usage() {
+ print "\nusage: scale.pl <infile.emp> <outfile.emp> <layer number> <size: e.g. 5.00mm or 0.25in>\n\n";
+ print "The module will be scaled so that its largest dimension (x or y) matches <size>\n\n";
+ print "KiCad layers:\n";
+ print "-------------\n\n";
+ print "Top copper: 15\n";
+ print "Bottom copper: 0 (*)\n";
+ print "Top silkscreen: 21\n";
+ print "Bottom silkscreen: 20 (*)\n\n";
+ print "(*) To move the mirrored logo to bottom copper/silkscreen\n";
+ print " move the curser over it and press 'F' for flip layer.\n\n";
+ print " The layer-swap is not done in this script as KiCad\n";
+ print " gets confused and prints stuff on wrong layers.\n\n";
+ exit;
+}
+