FreeCalypso > hg > ueda-linux
comparison pads2gpcb/writeelem.c @ 46:c81aba92cb5e
pads2gpcb: generic element writing implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 30 Jan 2016 07:56:18 +0000 |
parents | |
children | dbf999b71c53 |
comparison
equal
deleted
inserted
replaced
45:3bdb1b5ff3d0 | 46:c81aba92cb5e |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include "struct.h" | |
4 #include "gpcbout.h" | |
5 | |
6 static void | |
7 emit_element_line(outf, body, strdesc, strname, strvalue, onbottom) | |
8 FILE *outf; | |
9 struct footprint_body *body; | |
10 char *strdesc, *strname, *strvalue; | |
11 int onbottom; | |
12 { | |
13 char mx_buf[DIM_OUT_BUFSIZE], *mx_str; | |
14 char my_buf[DIM_OUT_BUFSIZE], *my_str; | |
15 char tx_buf[DIM_OUT_BUFSIZE], *tx_str; | |
16 char ty_buf[DIM_OUT_BUFSIZE], *ty_str; | |
17 char *flagstr; | |
18 | |
19 mx_str = output_gpcb_dimension(body->mark_x, mx_buf); | |
20 my_str = output_gpcb_dimension(body->mark_y, my_buf); | |
21 tx_str = output_gpcb_dimension(body->refdes_x, tx_buf); | |
22 ty_str = output_gpcb_dimension(body->refdes_y, ty_buf); | |
23 flagstr = onbottom ? "onsolder" : ""; | |
24 | |
25 fprintf(outf, | |
26 "Element[\"%s\" \"%s\" \"%s\" \"%s\" %s %s %s %s %d %d \"%s\"]\n", | |
27 flagstr, strdesc, strname, strvalue, mx_str, my_str, | |
28 tx_str, ty_str, body->refdes_dir, body->refdes_scale, flagstr); | |
29 } | |
30 | |
31 static void | |
32 emit_pad_line(outf, pad, pinname, pinnumber, onbottom) | |
33 FILE *outf; | |
34 struct footprint_pad *pad; | |
35 char *pinname, *pinnumber; | |
36 int onbottom; | |
37 { | |
38 char x1_buf[DIM_OUT_BUFSIZE], *x1_str; | |
39 char y1_buf[DIM_OUT_BUFSIZE], *y1_str; | |
40 char x2_buf[DIM_OUT_BUFSIZE], *x2_str; | |
41 char y2_buf[DIM_OUT_BUFSIZE], *y2_str; | |
42 char thickness_buf[DIM_OUT_BUFSIZE], *thickness_str; | |
43 char clearance_buf[DIM_OUT_BUFSIZE], *clearance_str; | |
44 char mask_buf[DIM_OUT_BUFSIZE], *mask_str; | |
45 char *flagstr; | |
46 | |
47 x1_str = output_gpcb_dimension(pad->x1, x1_buf); | |
48 y1_str = output_gpcb_dimension(pad->y1, y1_buf); | |
49 x2_str = output_gpcb_dimension(pad->x2, x2_buf); | |
50 y2_str = output_gpcb_dimension(pad->y2, y2_buf); | |
51 thickness_str = output_gpcb_dimension(pad->thickness, thickness_buf); | |
52 clearance_str = output_gpcb_dimension(pad->clearance, clearance_buf); | |
53 mask_str = output_gpcb_dimension(pad->mask, mask_buf); | |
54 | |
55 if (onbottom && !pad->shape.rounded) | |
56 flagstr = "onsolder,square"; | |
57 else if (onbottom) | |
58 flagstr = "onsolder"; | |
59 else if (!pad->shape.rounded) | |
60 flagstr = "square"; | |
61 else | |
62 flagstr = ""; | |
63 | |
64 fprintf(outf, "\tPad[%s %s %s %s %s %s %s \"%s\" \"%s\" \"%s\"]\n", | |
65 x1_str, y1_str, x2_str, y2_str, | |
66 thickness_str, clearance_str, mask_str, | |
67 pinname, pinnumber, flagstr); | |
68 } | |
69 | |
70 write_gpcb_element(outf, body, alpha_pins, strdesc, strname, strvalue, onbottom) | |
71 FILE *outf; | |
72 struct footprint_body *body; | |
73 char **alpha_pins; | |
74 char *strdesc, *strname, *strvalue; | |
75 int onbottom; | |
76 { | |
77 int i; | |
78 char pinnum_buf[16], *pinnum_str; | |
79 | |
80 emit_element_line(outf, body, strdesc, strname, strvalue, onbottom); | |
81 fputs("(\n", outf); | |
82 for (i = 0; i < body->npins; i++) { | |
83 if (alpha_pins) | |
84 pinnum_str = alpha_pins[i]; | |
85 else { | |
86 sprintf(pinnum_buf, "%d", i + 1); | |
87 pinnum_str = pinnum_buf; | |
88 } | |
89 emit_pad_line(outf, body->pins + i, "", pinnum_str, onbottom); | |
90 } | |
91 fputs(")\n", outf); | |
92 return(0); | |
93 } |