FreeCalypso > hg > ueda-linux
diff ifctf-part-lib/uschem-symbols/mkheader.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 20 Jul 2015 00:24:37 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ifctf-part-lib/uschem-symbols/mkheader.c Mon Jul 20 00:24:37 2015 +0000 @@ -0,0 +1,64 @@ +/* + * This program generates a uschem (subset of gschem) symbol + * for a dual-row header. Can also be used for board-to-board connectors. + */ + +#include <stdio.h> +#include <strings.h> +#include <ctype.h> + +int npins, btb; +int pinlength = 300, vstep = 400, boxwidth = 800; +int textoff_x = 75, textoff_y = 50; +int curpin, ycoord; + +doit() +{ + ycoord = npins / 2 * vstep; + printf("B %d 0 %d %d 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n", pinlength, + boxwidth, ycoord); + if (!btb) + printf("L %d %d %d 0 3 0 0 0 -1 -1\n", + pinlength + boxwidth / 2, ycoord, + pinlength + boxwidth / 2); + for (curpin = 1; curpin <= npins; ) { + ycoord -= vstep / 2; + printf("P 0 %d %d %d 1 0 0\n{\n", ycoord, pinlength, ycoord); + printf("T %d %d 5 8 1 1 0 6 1\n", pinlength - textoff_x, + ycoord + textoff_y); + printf("pinnumber=%d\n}\n", curpin++); + printf("P %d %d %d %d 1 0 1\n{\n", pinlength + boxwidth, ycoord, + pinlength * 2 + boxwidth, ycoord); + printf("T %d %d 5 8 1 1 0 0 1\n", + pinlength + boxwidth + textoff_x, ycoord + textoff_y); + printf("pinnumber=%d\n}\n", curpin); + ycoord -= vstep / 2; + if (!btb && curpin < npins) + printf("L %d %d %d %d 3 0 0 0 -1 -1\n", pinlength, + ycoord, pinlength + boxwidth, ycoord); + curpin++; + } +} + +main(argc, argv) + char **argv; +{ + char **ap; + + ap = argv + 1; + if (*ap && !strcmp(*ap, "-b")) { + ap++; + btb = 1; + } + if (!*ap || !isdigit(**ap)) { + fprintf(stderr, "usage: %s [-b] npins\n", argv[0]); + exit(1); + } + npins = atoi(*ap); + if (npins < 2 || npins & 1) { + fprintf(stderr, "%s: invalid npins argument\n", argv[0]); + exit(1); + } + doit(); + exit(0); +}