# HG changeset patch # User Mychaela Falconia # Date 1454218233 0 # Node ID 9d7e2937883d3025f234b180dd63b63b07effd5a # Parent ff1d565d233ca49b1ee0f2a858912124c8fb436f pads2gpcb: select specific drawing levels for silk with -s diff -r ff1d565d233c -r 9d7e2937883d pads2gpcb/Makefile --- a/pads2gpcb/Makefile Sun Jan 31 05:02:49 2016 +0000 +++ b/pads2gpcb/Makefile Sun Jan 31 05:30:33 2016 +0000 @@ -1,6 +1,7 @@ CC= gcc CFLAGS= -O2 -OBJS= decals.o globals.o gpcbout.o main.o rdunits.o readpads.o writeelem.o +OBJS= decals.o globals.o gpcbout.o main.o rdunits.o readpads.o silkselect.o \ + writeelem.o HDRS= globals.h gpcbout.h struct.h PROG= pads2gpcb BINDIR= /usr/local/bin diff -r ff1d565d233c -r 9d7e2937883d pads2gpcb/decals.c --- a/pads2gpcb/decals.c Sun Jan 31 05:02:49 2016 +0000 +++ b/pads2gpcb/decals.c Sun Jan 31 05:30:33 2016 +0000 @@ -12,7 +12,7 @@ static struct footprint_body fpbody; static struct footprint_pad *pins_array; -#define MAX_SILK_LINES 16 +#define MAX_SILK_LINES 64 static struct element_line silk_lines[MAX_SILK_LINES]; static struct element_arc silk_arcs[MAX_SILK_LINES]; static int num_silk_lines; @@ -58,6 +58,17 @@ } static +drawpiece_silk_candidate() +{ + int level; + + if (input_line_nfields != 5) + return(0); + level = atoi(input_line_fields[4]); + return is_drawlevel_selected(level); +} + +static try_silk_open_closed() { int ncoord, i, bad; @@ -67,11 +78,6 @@ if (strcmp(input_line_fields[0], "OPEN") && strcmp(input_line_fields[0], "CLOSED")) return(0); - if (input_line_nfields != 5) - return(0); - if (strcmp(input_line_fields[4], "0") && - strcmp(input_line_fields[4], "1")) - return(0); ncoord = atoi(input_line_fields[1]); if (ncoord < 2) { printf("line %d: silk %s piece ncoord < 2\n", input_lineno, @@ -125,11 +131,6 @@ if (strcmp(input_line_fields[0], "CIRCLE")) return(0); - if (input_line_nfields != 5) - return(0); - if (strcmp(input_line_fields[4], "0") && - strcmp(input_line_fields[4], "1")) - return(0); if (strcmp(input_line_fields[1], "2")) { printf("line %d: silk CIRCLE piece ncoord != 2\n", input_lineno); @@ -213,7 +214,7 @@ input_filename, input_lineno); exit(1); } - if (do_footprint_silk) { + if (do_footprint_silk && drawpiece_silk_candidate()) { if (try_silk_open_closed()) return; if (try_silk_circle()) diff -r ff1d565d233c -r 9d7e2937883d pads2gpcb/main.c --- a/pads2gpcb/main.c Sun Jan 31 05:02:49 2016 +0000 +++ b/pads2gpcb/main.c Sun Jan 31 05:30:33 2016 +0000 @@ -58,11 +58,13 @@ { int c; extern int optind; + extern char *optarg; - while ((c = getopt(argc, argv, "sw:")) != EOF) + while ((c = getopt(argc, argv, "s:w:")) != EOF) switch (c) { case 's': do_footprint_silk = 1; + select_drawlevel_for_silk(atoi(optarg)); continue; case 'w': process_write_option(); diff -r ff1d565d233c -r 9d7e2937883d pads2gpcb/silkselect.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pads2gpcb/silkselect.c Sun Jan 31 05:30:33 2016 +0000 @@ -0,0 +1,27 @@ +#include +#include + +#define MAX_LEVEL_SELECT 8 + +static int select_array[MAX_LEVEL_SELECT]; +static int num_select; + +select_drawlevel_for_silk(level) +{ + if (num_select >= MAX_LEVEL_SELECT) { + fprintf(stderr, "Error: MAX_LEVEL_SELECT exceeded\n"); + exit(1); + } + select_array[num_select++] = level; + return(0); +} + +is_drawlevel_selected(level) +{ + int i; + + for (i = 0; i < num_select; i++) + if (select_array[i] == level) + return(1); + return(0); +}