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