20 #include <footag/footag.h>
26 #define UNUSED(i) (void) (sizeof (i))
30 #define NELEM(a) ((sizeof a) / (sizeof (a[0])))
55 .type = FOOTAG_DATA_NONE, \
58 #define ITEM_BOOL(_val) { \
59 .type = FOOTAG_DATA_BOOL, \
65 #define ITEM_INTEGER(_val, _step, _min, _max) { \
66 .type = FOOTAG_DATA_INTEGER, \
77 #define ITEM_FLOAT(_val) { \
78 .type = FOOTAG_DATA_FLOAT, \
84 #define ITEM_LENGTH(_val) { \
85 .type = FOOTAG_DATA_LENGTH, \
92 #define ITEM_TOL_PM(_nom, _pm) { \
93 .type = FOOTAG_DATA_TOL, \
97 .min = (_nom - _pm), \
98 .max = (_nom + _pm), \
104 #define ITEM_TOL_MM(_min, _max) { \
105 .type = FOOTAG_DATA_TOL, \
108 .nom = ((_min + _max) / 2.0), \
115 #define ITEM_TOL_DATA(a, b) { \
116 .nom = (a) <= (b) ? ((a + b) / 2.0) : (a), \
117 .min = (a) <= (b) ? (a) : (a - b), \
118 .max = (a) <= (b) ? (b) : (a + b), \
121 #define ITEM_TOL(_a, _b) { \
122 .type = FOOTAG_DATA_TOL, \
124 .t = ITEM_TOL_DATA(_a, _b), \
128 #define ITEM_ENUM(_val, _num, ...) { \
129 .type = FOOTAG_DATA_ENUM, \
134 .strs = (const char *const []) { __VA_ARGS__ }, \
139 #define ITEM_BITMASK(_val, _num, ...) { \
140 .type = FOOTAG_DATA_BITMASK, \
145 .strs = (const char *const []) { __VA_ARGS__ }, \
150 #define PARAM_HEADER(_id, _name, _abbr) \
151 .id = PARAM_ ## _id, \
155 #define PARAM_TERM { \
156 PARAM_HEADER(DONE, "done", "done"), \
160 #define PARAM_TOPIC(_name) { \
167 #define PARAM_B(_id, _name, _abbr, _val) { \
168 PARAM_HEADER(_id, _name, _abbr), \
169 .item = ITEM_BOOL(_val), \
172 #define PARAM_I(_id, _name, _abbr, _val, _step, _min, _max) { \
173 PARAM_HEADER(_id, _name, _abbr), \
174 .item = ITEM_INTEGER(_val, _step, _min, _max), \
177 #define PARAM_F(_id, _name, _abbr, _val) { \
178 PARAM_HEADER(_id, _name, _abbr), \
179 .item = ITEM_FLOAT(_val), \
182 #define PARAM_L(_id, _name, _abbr, _val) { \
183 PARAM_HEADER(_id, _name, _abbr), \
184 .item = ITEM_LENGTH(_val), \
187 #define PARAM_TPM(_id, _name, _abbr, _nom, _pm) { \
188 PARAM_HEADER(_id, _name, _abbr), \
189 .item = ITEM_TOL_PM(_nom, _pm), \
192 #define PARAM_TMM(_id, _name, _abbr, _min, _max) { \
193 PARAM_HEADER(_id, _name, _abbr), \
194 .item = ITEM_TOL_MM(_min, _max), \
202 #define PARAM_T(_id, _name, _abbr, _a, _b) { \
203 PARAM_HEADER(_id, _name, _abbr), \
204 .item = ITEM_TOL(_a, _b), \
207 #define PARAM_E(_id, _name, _abbr, _val, _num, ...) { \
208 PARAM_HEADER(_id, _name, _abbr), \
209 .item = ITEM_ENUM(_val, _num, __VA_ARGS__), \
212 #define PARAM_M(_id, _name, _abbr, _val, _num, ...) { \
213 PARAM_HEADER(_id, _name, _abbr), \
214 .item = ITEM_BITMASK(_val, _num, __VA_ARGS__), \
217 #define PARAM_CALC_IPC7351B \
218 PARAM_TOPIC("Calc"), \
219 PARAM_E(CALC_D, "Density", "-", FOOTAG_LEVEL_N, FOOTAG_LEVEL_NUM, \
220 "Most", "Nominal", "Least" \
222 PARAM_L(CALC_F, "Fabrication", "-", 0.10), \
223 PARAM_L(CALC_P, "Placement", "-", 0.10), \
224 PARAM_TOPIC("Generate"), \
225 PARAM_E(CALC_ROUND, "Round-off", "-", 3, 4, \
226 "None", "0.01 mm", "0.02 mm", "0.05 mm" \
229 #define PARAM_CALC_IPC7351B_HIRES \
230 PARAM_TOPIC("Calc"), \
231 PARAM_E(CALC_D, "Density", "-", FOOTAG_LEVEL_N, FOOTAG_LEVEL_NUM, \
232 "Most", "Nominal", "Least" \
234 PARAM_L(CALC_F, "Fabrication", "-", 0.05), \
235 PARAM_L(CALC_P, "Placement", "-", 0.05), \
236 PARAM_TOPIC("Generate"), \
237 PARAM_E(CALC_ROUND, "Round-off", "-", 1, 4, \
238 "None", "0.01 mm", "0.02 mm", "0.05 mm" \
241 #define PARAM_CALC_IPC7251DRAFT1 \
242 PARAM_TOPIC("Calc"), \
243 PARAM_E(CALC_D, "Level", "-", FOOTAG_LEVEL_N, FOOTAG_LEVEL_NUM, \
244 "A (Maximum)", "B (Nominal)", "C (Least)" \
246 PARAM_TOPIC("Generate"), \
247 PARAM_E(CALC_ROUND, "Round-off", "-", 3, 4, \
248 "None", "0.01 mm", "0.02 mm", "0.05 mm" \
251 #define PARAM_PADSTACK_SMD_RECTS \
252 PARAM_E(CALC_STACK, "Padstack", "-", 1, 2, \
253 "Rectangular", "Rounded rectangular" \
256 int footag_init_from_template(
261 int footag_init_default(
265 int footag_init_twopin(
269 int footag_fini_default(
284 #define GETID(_ctx, _id) footag_data_by_id(_ctx, PARAM_ ## _id)
287 PARAM_DONE = FOOTAG_PARAM_DONE,
288 PARAM_IGNORE = FOOTAG_PARAM_IGNORE,
289 PARAM_TOPIC = FOOTAG_PARAM_TOPIC,
327 static inline int footag_get_density(
337 static const double ROUNDOFF_TO_GRID[4] = {
345 static inline double snap(
double v,
double grid)
347 if (!grid) {
return v; }
348 return round(v / grid) * grid;
362 void footag_setcourtyard(
367 static inline double footag_padypos(
double pitch,
int rows,
int row)
370 y = - 1 * ((rows / 2.0) - 1.0 / 2);
376 void footag_gridnames(
383 void footag_gennames(
392 double addx,
double addy,
401 void footag_gentworow(
407 enum footag_padstack stack
413 double wrow,
double hrow,
415 double wcol,
double hcol,
418 enum footag_padstack stack
426 int prows,
int pcols,
427 enum footag_padstack stack
436 enum footag_padstack stack
445 enum footag_padstack stack
448 void footag_gentwopin(
452 enum footag_padstack stack
455 void footag_ipc7351b_setrrectpad(
459 void footag_ipc7351b_setrrectpads(
463 int footag_realloc_pads(
468 static inline int intmin(
int a,
int b) {
return a < b ? a : b; }
469 static inline int intmax(
int a,
int b) {
return a < b ? b : a; }
484 const char *footag_hint_ipc7251draft1(
490 void footag_setref_ipc7351b(
496 void footag_setref_ipc7251draft1(
Definition: ipc7251draft1.h:52
Definition: ipc7351b.h:111