00001
00024 #include "register_functions.c"
00025 #include "to.h"
00026
00027
00034 int
00035 to_create_element_to92 ()
00036 {
00037 gdouble xmax;
00038 gdouble xmin;
00039 gdouble ymax;
00040 gdouble ymin;
00041 gdouble x_text;
00042 gdouble y_text;
00043 gdouble dx;
00044 gint pin_number;
00045 gchar *pin_pad_name = g_strdup ("");
00046 FlagType pad_flag;
00047 ElementTypePtr element;
00048
00049 if (!element)
00050 {
00051 if (verbose)
00052 g_log ("", G_LOG_LEVEL_WARNING,
00053 _("could not create a valid element pointer for a %s package."),
00054 footprint_type);
00055 return (EXIT_FAILURE);
00056 }
00057
00058
00059 element->MarkX = 0;
00060 element->MarkY = 0;
00061
00062
00063
00064
00065
00066 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
00067 {
00068 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
00069 }
00070 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
00071 {
00072 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
00073 }
00074 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
00075 {
00076 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
00077 }
00078 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
00079 {
00080 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
00081 }
00082
00083 if (multiplier * (-courtyard_length / 2.0) < xmin)
00084 {
00085 xmin = multiplier * (-courtyard_length / 2.0);
00086 }
00087 if (multiplier * (courtyard_length / 2.0) > xmax)
00088 {
00089 xmax = multiplier * (courtyard_length / 2.0);
00090 }
00091 if (multiplier * (-courtyard_width / 2.0) < ymin)
00092 {
00093 ymin = multiplier * (-courtyard_width / 2.0);
00094 }
00095 if (multiplier * (courtyard_width / 2.0) > ymax)
00096 {
00097 ymax = multiplier * (courtyard_width / 2.0);
00098 }
00099
00100 element->Name[1].Scale = 100;
00101 element->Name[1].X = 0.0 ;
00102 element->Name[1].Y = (ymin - 10000.0);
00103 element->Name[1].TextString = footprint_name;
00104 element->Name[1].Element = element;
00105 element->Name[1].Direction = EAST;
00106 element->Name[1].ID = ID++;
00107
00108 element->Name[2].Scale = 100;
00109 element->Name[2].X = 0.0 ;
00110 element->Name[2].Y = (ymin - 10000.0);
00111 element->Name[2].TextString = footprint_refdes;
00112 element->Name[2].Element = element;
00113 element->Name[2].Direction = EAST;
00114 element->Name[2].ID = ID++;
00115
00116 element->Name[3].Scale = 100;
00117 element->Name[3].X = 0.0 ;
00118 element->Name[3].Y = (ymin - 10000.0);
00119 element->Name[3].TextString = footprint_value;
00120 element->Name[3].Element = element;
00121 element->Name[3].Direction = EAST;
00122 element->Name[3].ID = ID++;
00123
00124 if (pad_shapes_type == SQUARE)
00125 {
00126 pad_flag.f = SQUARE;
00127 }
00128 else
00129 {
00130 pad_flag.f = CLEAR;
00131 }
00132 create_new_pin
00133 (
00134 element,
00135 (int) (5000),
00136 (int) (0),
00137 (int) (multiplier * pad_diameter),
00138 (int) (multiplier * pad_clearance),
00139 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00140 (int) (multiplier * pin_drill_diameter),
00141 "",
00142 "3",
00143 pad_flag
00144 );
00145 create_new_pin
00146 (
00147 element,
00148 (int) (0),
00149 (int) (0),
00150 (int) (multiplier * pad_diameter),
00151 (int) (multiplier * pad_clearance),
00152 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00153 (int) (multiplier * pin_drill_diameter),
00154 "",
00155 "2",
00156 pad_flag
00157 );
00158 if (pin1_square || (pad_shapes_type == SQUARE))
00159 {
00160 pad_flag.f = SQUARE;
00161 }
00162 else
00163 {
00164 pad_flag.f = CLEAR;
00165 }
00166 create_new_pin
00167 (
00168 element,
00169 -5000,
00170 0,
00171 (int) (multiplier * pad_diameter),
00172 (int) (multiplier * pad_clearance),
00173 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00174 (int) (multiplier * pin_drill_diameter),
00175 "",
00176 "1",
00177 pad_flag
00178 );
00179
00180 create_new_line
00181 (
00182 element,
00183 -8600,
00184 -6000,
00185 8600,
00186 -6000,
00187 (int) (multiplier * silkscreen_line_width)
00188 );
00189 create_new_arc
00190 (
00191 element,
00192 0,
00193 0,
00194 10500,
00195 10500,
00196 -35,
00197 250,
00198 (int) (multiplier * silkscreen_line_width)
00199 );
00200
00201
00202
00203 create_new_arc
00204 (
00205 element,
00206 0,
00207 0,
00208 xmax,
00209 ymax,
00210 0,
00211 360,
00212 (int) (multiplier * silkscreen_line_width)
00213 );
00214
00215 if (attributes_in_footprint)
00216 {
00217 element = create_attributes_in_element (element);
00218 }
00219
00220 if (verbose)
00221 {
00222 g_log ("", G_LOG_LEVEL_INFO,
00223 _("created an element for a %s package: %s."),
00224 footprint_type,
00225 footprint_filename);
00226 }
00227 current_element = (ElementTypePtr) &element;
00228 return (EXIT_SUCCESS);
00229 }
00230
00231
00238 int
00239 to_create_element_to92_staggered ()
00240 {
00241 gdouble xmax;
00242 gdouble xmin;
00243 gdouble ymax;
00244 gdouble ymin;
00245 gdouble x_text;
00246 gdouble y_text;
00247 gdouble dx;
00248 gint pin_number;
00249 gchar *pin_pad_name = g_strdup ("");
00250 FlagType pad_flag;
00251 ElementTypePtr element;
00252
00253 if (!element)
00254 {
00255 if (verbose)
00256 g_log ("", G_LOG_LEVEL_WARNING,
00257 _("could not create a valid element pointer for a %s package."),
00258 footprint_type);
00259 return (EXIT_FAILURE);
00260 }
00261
00262
00263 element->MarkX = 0;
00264 element->MarkY = 0;
00265
00266
00267
00268
00269
00270 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
00271 {
00272 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
00273 }
00274 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
00275 {
00276 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
00277 }
00278 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
00279 {
00280 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
00281 }
00282 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
00283 {
00284 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
00285 }
00286
00287 if (multiplier * (-courtyard_length / 2.0) < xmin)
00288 {
00289 xmin = multiplier * (-courtyard_length / 2.0);
00290 }
00291 if (multiplier * (courtyard_length / 2.0) > xmax)
00292 {
00293 xmax = multiplier * (courtyard_length / 2.0);
00294 }
00295 if (multiplier * (-courtyard_width / 2.0) < ymin)
00296 {
00297 ymin = multiplier * (-courtyard_width / 2.0);
00298 }
00299 if (multiplier * (courtyard_width / 2.0) > ymax)
00300 {
00301 ymax = multiplier * (courtyard_width / 2.0);
00302 }
00303
00304 element->Name[1].Scale = 100;
00305 element->Name[1].X = 0.0 ;
00306 element->Name[1].Y = (ymin - 10000.0);
00307 element->Name[1].TextString = footprint_name;
00308 element->Name[1].Element = element;
00309 element->Name[1].Direction = EAST;
00310 element->Name[1].ID = ID++;
00311
00312 element->Name[2].Scale = 100;
00313 element->Name[2].X = 0.0 ;
00314 element->Name[2].Y = (ymin - 10000.0);
00315 element->Name[2].TextString = footprint_refdes;
00316 element->Name[2].Element = element;
00317 element->Name[2].Direction = EAST;
00318 element->Name[2].ID = ID++;
00319
00320 element->Name[3].Scale = 100;
00321 element->Name[3].X = 0.0 ;
00322 element->Name[3].Y = (ymin - 10000.0);
00323 element->Name[3].TextString = footprint_value;
00324 element->Name[3].Element = element;
00325 element->Name[3].Direction = EAST;
00326 element->Name[3].ID = ID++;
00327
00328 if (pad_shapes_type == SQUARE)
00329 {
00330 pad_flag.f = SQUARE;
00331 }
00332 else
00333 {
00334 pad_flag.f = CLEAR;
00335 }
00336 create_new_pin
00337 (
00338 element,
00339 5000,
00340 0,
00341 (int) (multiplier * pad_diameter),
00342 (int) (multiplier * pad_clearance),
00343 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00344 (int) (multiplier * pin_drill_diameter),
00345 "",
00346 "3",
00347 pad_flag
00348 );
00349 create_new_pin
00350 (
00351 element,
00352 0,
00353 -5000,
00354 (int) (multiplier * pad_diameter),
00355 (int) (multiplier * pad_clearance),
00356 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00357 (int) (multiplier * pin_drill_diameter),
00358 "",
00359 "2",
00360 pad_flag
00361 );
00362 if (pin1_square || (pad_shapes_type == SQUARE))
00363 {
00364 pad_flag.f = SQUARE;
00365 }
00366 else
00367 {
00368 pad_flag.f = CLEAR;
00369 }
00370 create_new_pin
00371 (
00372 element,
00373 -5000,
00374 0,
00375 (int) (multiplier * pad_diameter),
00376 (int) (multiplier * pad_clearance),
00377 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00378 (int) (multiplier * pin_drill_diameter),
00379 "",
00380 "1",
00381 pad_flag
00382 );
00383
00384 create_new_line
00385 (
00386 element,
00387 -8600,
00388 -6000,
00389 8600,
00390 -6000,
00391 (int) (multiplier * silkscreen_line_width)
00392 );
00393 create_new_arc
00394 (
00395 element,
00396 0,
00397 0,
00398 10500,
00399 10500,
00400 -35,
00401 250,
00402 (int) (multiplier * silkscreen_line_width)
00403 );
00404
00405
00406
00407 create_new_arc
00408 (
00409 element,
00410 0,
00411 0,
00412 xmax,
00413 ymax,
00414 0,
00415 360,
00416 (int) (multiplier * silkscreen_line_width)
00417 );
00418
00419 if (attributes_in_footprint)
00420 {
00421 element = create_attributes_in_element (element);
00422 }
00423
00424 if (verbose)
00425 {
00426 g_log ("", G_LOG_LEVEL_INFO,
00427 _("created an element for a %s package: %s."),
00428 footprint_type,
00429 footprint_filename);
00430 }
00431 current_element = (ElementTypePtr) &element;
00432 return (EXIT_SUCCESS);
00433 }
00434
00435
00445 int
00446 to_create_packages_list ()
00447 {
00448 g_list_free (packages_list);
00449 packages_list = g_list_append (packages_list, "TO92");
00450 packages_list = g_list_append (packages_list, "TO92S");
00451 packages_list = g_list_append (packages_list, "TO220");
00452 packages_list = g_list_append (packages_list, "TO220S");
00453 packages_list = g_list_append (packages_list, "TO220SW");
00454 packages_list = g_list_append (packages_list, "TO220W");
00455 return (EXIT_SUCCESS);
00456 }
00457
00458
00482 int
00483 to_drc ()
00484 {
00485 int result = EXIT_SUCCESS;
00486 if (verbose)
00487 {
00488 g_log ("", G_LOG_LEVEL_INFO,
00489 (_("[%s] DRC Check: checking package %s.")),
00490 footprint_type, footprint_name);
00491 }
00492
00493 switch (pad_shapes_type)
00494 {
00495 case NO_SHAPE:
00496 {
00497 if (verbose)
00498 {
00499 g_log ("", G_LOG_LEVEL_WARNING,
00500 (_("[%s] DRC Error: NO_SHAPE specified for check for allowed pad shapes.")),
00501 footprint_type);
00502 }
00503 result = EXIT_FAILURE;
00504 break;
00505 }
00506 case ROUND:
00507 {
00508 break;
00509 }
00510 case SQUARE:
00511 {
00512 if (verbose)
00513 {
00514 g_log ("", G_LOG_LEVEL_WARNING,
00515 (_("[%s] DRC Error: square pad shape specified for check for allowed pad shapes.")),
00516 footprint_type);
00517 }
00518 result = EXIT_FAILURE;
00519 break;
00520 }
00521 case OCTAGONAL:
00522 {
00523 if (verbose)
00524 {
00525 g_log ("", G_LOG_LEVEL_WARNING,
00526 (_("[%s] DRC Error: octagonal pad shape specified for check for allowed pad shapes.")),
00527 footprint_type);
00528 }
00529 result = EXIT_FAILURE;
00530 break;
00531 }
00532 case ROUND_ELONGATED:
00533 {
00534 break;
00535 }
00536 default:
00537 {
00538 if (verbose)
00539 {
00540 g_log ("", G_LOG_LEVEL_WARNING,
00541 (_("[%s] DRC Error: no valid pad shape type specified.")),
00542 footprint_type);
00543 }
00544 result = EXIT_FAILURE;
00545 break;
00546 }
00547 }
00548
00549 if (pitch_x <= 0.0)
00550 {
00551 if (verbose)
00552 {
00553 g_log ("", G_LOG_LEVEL_WARNING,
00554 (_("[%s] DRC Error: pitch (X-direction) should be greater than 0.")),
00555 footprint_type);
00556 }
00557 result = EXIT_FAILURE;
00558 }
00559
00560 if (package_body_length <= 0.0)
00561 {
00562 if (verbose)
00563 {
00564 g_log ("", G_LOG_LEVEL_WARNING,
00565 (_("[%s] DRC Error: specified package body length is too small.")),
00566 footprint_type);
00567 }
00568 result = EXIT_FAILURE;
00569 }
00570 if (package_body_width <= 0.0)
00571 {
00572 if (verbose)
00573 {
00574 g_log ("", G_LOG_LEVEL_WARNING,
00575 (_("[%s] DRC Error: specified package body width is too small.")),
00576 footprint_type);
00577 }
00578 result = EXIT_FAILURE;
00579 }
00580 if (package_body_height <= 0.0)
00581 {
00582 if (verbose)
00583 {
00584 g_log ("", G_LOG_LEVEL_WARNING,
00585 (_("[%s] DRC Error: specified package body height is too small.")),
00586 footprint_type);
00587 }
00588 result = EXIT_FAILURE;
00589 }
00590
00591 if (courtyard_length <= 0.0)
00592 {
00593 if (verbose)
00594 {
00595 g_log ("", G_LOG_LEVEL_WARNING,
00596 (_("[%s] DRC Error: specified courtyard length is too small.")),
00597 footprint_type);
00598 }
00599 result = EXIT_FAILURE;
00600 }
00601 if (courtyard_width <= 0.0)
00602 {
00603 if (verbose)
00604 {
00605 g_log ("", G_LOG_LEVEL_WARNING,
00606 (_("[%s] DRC Error: specified courtyard width is too small.")),
00607 footprint_type);
00608 }
00609 result = EXIT_FAILURE;
00610 }
00611
00612 if ((pitch_y - pad_diameter < pad_clearance) || (pitch_y - pad_width < pad_clearance))
00613 {
00614 if (verbose)
00615 {
00616 g_log ("", G_LOG_LEVEL_WARNING,
00617 (_("[%s] DRC Error: minimum clearance between copper (Y-direction) is too small.")),
00618 footprint_type);
00619 }
00620 result = EXIT_FAILURE;
00621 }
00622
00623 if (fiducial)
00624 {
00625 if (verbose)
00626 {
00627 g_log ("", G_LOG_LEVEL_WARNING,
00628 (_("[%s] DRC Error: package should not have any fiducials.")),
00629 footprint_type);
00630 }
00631 result = EXIT_FAILURE;
00632 }
00633
00634
00635 if (package_body_length - courtyard_length < courtyard_clearance_with_package)
00636 {
00637 if (verbose)
00638 {
00639 g_log ("", G_LOG_LEVEL_WARNING,
00640 (_("[%s] DRC Error: clearance of the package length with regard to the courtyard dimensions is too small.")),
00641 footprint_type);
00642 }
00643 result = EXIT_FAILURE;
00644 }
00645
00646
00647 if (package_body_width - courtyard_width < courtyard_clearance_with_package)
00648 {
00649 if (verbose)
00650 {
00651 g_log ("", G_LOG_LEVEL_WARNING,
00652 (_("[%s] DRC Error: clearance of the package width with regard to the courtyard dimensions is too small.")),
00653 footprint_type);
00654 }
00655 result = EXIT_FAILURE;
00656 }
00662
00663 if (silkscreen_package_outline && (silkscreen_line_width == 0.0))
00664 {
00665 if (verbose)
00666 {
00667 g_log ("", G_LOG_LEVEL_WARNING,
00668 (_("[%s] DRC Error: silkscreen line width is too small.")),
00669 footprint_type);
00670 }
00671 result = EXIT_FAILURE;
00672 }
00673 switch (units_type)
00674 {
00675 case NO_UNITS:
00676 {
00677 if (verbose)
00678 {
00679 g_log ("", G_LOG_LEVEL_WARNING,
00680 (_("[%s] DRC Error: no units specified.")),
00681 footprint_type);
00682 }
00683 result = EXIT_FAILURE;
00684 break;
00685 }
00686 case MIL:
00687 if (silkscreen_package_outline && (silkscreen_line_width > 40.0))
00688 {
00689 if (verbose)
00690 {
00691 g_log ("", G_LOG_LEVEL_WARNING,
00692 (_("[%s] DRC Error: silkscreen line width too wide.")),
00693 footprint_type);
00694 }
00695 result = EXIT_FAILURE;
00696 break;
00697 }
00698 case MIL_100:
00699 if (silkscreen_package_outline && (silkscreen_line_width > 4000.0))
00700 {
00701 if (verbose)
00702 {
00703 g_log ("", G_LOG_LEVEL_WARNING,
00704 (_("[%s] DRC Error: silkscreen line width too wide.")),
00705 footprint_type);
00706 }
00707 result = EXIT_FAILURE;
00708 break;
00709 }
00710 case MM:
00711 if (silkscreen_package_outline && (silkscreen_line_width > 1.0))
00712 {
00713 if (verbose)
00714 {
00715 g_log ("", G_LOG_LEVEL_WARNING,
00716 (_("[%s] DRC Error: silkscreen line width too wide.")),
00717 footprint_type);
00718 }
00719 result = EXIT_FAILURE;
00720 break;
00721 }
00722 default:
00723 {
00724 if (verbose)
00725 {
00726 g_log ("", G_LOG_LEVEL_WARNING,
00727 (_("[%s] DRC Error: no valid units type specified.")),
00728 footprint_type);
00729 }
00730 result = EXIT_FAILURE;
00731 break;
00732 }
00733 }
00734
00735 if (verbose && (result == EXIT_SUCCESS))
00736 {
00737 g_log ("", G_LOG_LEVEL_INFO,
00738 (_("[%s] DRC Check: no errors while checking package %s.")),
00739 footprint_type, footprint_name);
00740 }
00741 return (result);
00742 }
00743
00744
00758 int
00759 to_get_default_footprint_values ()
00760 {
00761 if (!strcmp (footprint_name, "?TO92"))
00762 {
00763 number_of_pins = 3;
00764 package_body_length = 0.0;
00765 package_body_width = 0.0;
00766 package_body_height = 0.0;
00767 package_is_radial = TRUE;
00768 number_of_columns = 0;
00769 number_of_rows = 0;
00770 pitch_x = 0.0;
00771 pitch_y = 0.0;
00772 pad_diameter = 1.00;
00773 pin_drill_diameter = 0.72;
00774 pad_length = 0.0;
00775 pad_width = 0.0;
00776 pad_shape = g_strdup ("rounded pad");
00777 pad_shapes_type = ROUND;
00778 thermal = FALSE;
00779 thermal_length = 0.0;
00780 thermal_width = 0.0;
00781 silkscreen_package_outline = FALSE;
00782 silkscreen_length = 0.0;
00783 silkscreen_width = 0.0;
00784 courtyard_length = 0.0;
00785 courtyard_width = 0.0;
00786 count_x = 0;
00787 count_y = 0;
00788 footprint_units = g_strdup ("mm");
00789 g_free (footprint_name);
00790 footprint_name = g_strdup ("TO92");
00791 return (EXIT_SUCCESS);
00792 }
00793 else
00794 {
00795 g_log ("", G_LOG_LEVEL_WARNING,
00796 _("default values for footprint %s not found.\n"),
00797 footprint_name);
00798 return (EXIT_FAILURE);
00799 }
00800 }
00801
00802
00810 #if GUI
00811 int
00812 to_set_gui_constraints ()
00813 {
00814
00815 GtkWidget *package_is_radial_checkbutton = lookup_widget (GTK_WIDGET (widget),
00816 "package_is_radial_checkbutton");
00817 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (package_is_radial_checkbutton), FALSE);
00818 gtk_widget_set_sensitive (package_is_radial_checkbutton, FALSE);
00819
00820
00821 GtkWidget *number_of_columns_entry = lookup_widget (GTK_WIDGET (widget),
00822 "number_of_columns_entry");
00823 gtk_entry_set_text (GTK_ENTRY (number_of_columns_entry), "3");
00824 gtk_widget_set_sensitive (number_of_columns_entry, FALSE);
00825 GtkWidget *number_of_rows_entry = lookup_widget (GTK_WIDGET (widget),
00826 "number_of_rows_entry");
00827 gtk_entry_set_text (GTK_ENTRY (number_of_rows_entry), "1");
00828 gtk_widget_set_sensitive (number_of_rows_entry, FALSE);
00829 GtkWidget *count_x_entry = lookup_widget (GTK_WIDGET (widget),
00830 "count_x_entry");
00831 gtk_entry_set_text (GTK_ENTRY (count_x_entry), "");
00832 gtk_widget_set_sensitive (count_x_entry, FALSE);
00833 GtkWidget *count_y_entry = lookup_widget (GTK_WIDGET (widget),
00834 "count_y_entry");
00835 gtk_entry_set_text (GTK_ENTRY (count_y_entry), "");
00836 gtk_widget_set_sensitive (count_y_entry, FALSE);
00837 GtkWidget *number_1_position_entry = lookup_widget (GTK_WIDGET (widget),
00838 "number_1_position_entry");
00839 gtk_combo_box_set_active (GTK_COMBO_BOX (number_1_position_entry), UPPER_LEFT);
00840 gtk_widget_set_sensitive (number_1_position_entry, FALSE);
00841
00842
00843 gui_constraints_disable_thermal_tab_widgets (widget);
00844
00845
00846 gui_constraints_disable_heel_and_toe_goals_tab_widgets (widget);
00847 return (EXIT_SUCCESS);
00848 }
00849 #endif
00850
00851
00858 int
00859 to_write_footprint_to220 ()
00860 {
00861 gdouble xmax;
00862 gdouble xmin;
00863 gdouble ymax;
00864 gdouble ymin;
00865 gdouble x_text;
00866 gdouble y_text;
00867 gchar *pin_pad_flags = g_strdup ("");
00868
00869
00870 fp = fopen (footprint_filename, "w");
00871 if (!fp)
00872 {
00873 g_log ("", G_LOG_LEVEL_WARNING,
00874 _("could not open file for %s footprint: %s."),
00875 footprint_type, footprint_filename);
00876 fclose (fp);
00877 return (EXIT_FAILURE);
00878 }
00879
00880 if (license_in_footprint)
00881 {
00882 write_license ();
00883 }
00884
00885
00886 xmin = -20000 - (multiplier * courtyard_clearance_with_package);
00887 xmax = 20000 + (multiplier * courtyard_clearance_with_package);
00888 ymin = -79000 - (multiplier * courtyard_clearance_with_package);
00889 ymax = 10000 + (multiplier * courtyard_clearance_with_package);
00890
00891
00892 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
00893 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
00894 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
00895 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
00896 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
00897 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
00898 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
00899 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
00900
00901 if (multiplier * (-courtyard_length / 2.0) < xmin)
00902 xmin = multiplier * (-courtyard_length / 2.0);
00903 if (multiplier * (courtyard_length / 2.0) > xmax)
00904 xmax = multiplier * (courtyard_length / 2.0);
00905 if (multiplier * (-courtyard_width / 2.0) < ymin)
00906 ymin = multiplier * (-courtyard_width / 2.0);
00907 if (multiplier * (courtyard_width / 2.0) > ymax)
00908 ymax = multiplier * (courtyard_width / 2.0);
00909
00910
00911 x_text = 0.0 ;
00912 y_text = (ymin - 10000.0);
00913 write_element_header (x_text, y_text);
00914
00915 if (!strcmp (pad_shape, "rectangular pad"))
00916 pin_pad_flags = g_strdup ("square");
00917 else
00918 pin_pad_flags = g_strdup ("");
00919 write_pin
00920 (
00921 1,
00922 "",
00923 -10000.0,
00924 0.0,
00925 multiplier * pad_diameter,
00926 multiplier * pad_clearance,
00927 multiplier * (pad_diameter + pad_solder_mask_clearance),
00928 multiplier * pin_drill_diameter,
00929
00930 (pin1_square) ? "square" : ""
00931 );
00932 write_pin
00933 (
00934 2,
00935 "",
00936 0.0,
00937 0.0,
00938 multiplier * pad_diameter,
00939 multiplier * pad_clearance,
00940 multiplier * (pad_diameter + pad_solder_mask_clearance),
00941 multiplier * pin_drill_diameter,
00942 pin_pad_flags
00943 );
00944 write_pin
00945 (
00946 3,
00947 "",
00948 10000.0,
00949 0.0,
00950 multiplier * pad_diameter,
00951 multiplier * pad_clearance,
00952 multiplier * (pad_diameter + pad_solder_mask_clearance),
00953 multiplier * pin_drill_diameter,
00954 pin_pad_flags
00955 );
00956
00957 write_pin
00958 (
00959 0,
00960 "",
00961 10000.0,
00962 -67000.0,
00963 15000.0,
00964 multiplier * pad_clearance,
00965 15000.0 + (multiplier * pad_solder_mask_clearance),
00966 13000.0,
00967 "hole"
00968 );
00969
00970 if (thermal)
00971 {
00972 write_pad
00973 (
00974 0,
00975 "",
00976 0,
00977 -67000 - (multiplier * (thermal_width + (thermal_length / 2))),
00978 0,
00979 -67000 + (multiplier * (thermal_width + (thermal_length / 2))),
00980 multiplier * thermal_length,
00981 multiplier * pad_clearance,
00982 multiplier * (thermal_length + (2 * thermal_solder_mask_clearance)),
00983 pin_pad_flags
00984 );
00985 }
00986
00987 if (silkscreen_package_outline)
00988 {
00989
00990 fprintf (fp, "# Write leads on the silkscreen\n");
00991 write_element_line
00992 (
00993 -10000,
00994 (int) (multiplier * (-pad_diameter)),
00995 -10000,
00996 -18000,
00997 (int) multiplier * (2 * silkscreen_line_width)
00998 );
00999 write_element_line
01000 (
01001 0,
01002 (int) (multiplier * (-pad_diameter)),
01003 0,
01004 -18000,
01005 (int) multiplier * (2 * silkscreen_line_width)
01006 );
01007 write_element_line
01008 (
01009 10000,
01010 (int) (multiplier * (-pad_diameter)),
01011 10000,
01012 -18000,
01013 (int) multiplier * (2 * silkscreen_line_width)
01014 );
01015
01016 fprintf (fp, "# Write a package body on the silkscreen\n");
01017 write_element_line
01018 (
01019 -20000,
01020 -18000,
01021 -20000,
01022 -55500,
01023 (int) multiplier * (silkscreen_line_width)
01024 );
01025 write_element_line
01026 (
01027 20000,
01028 -18000,
01029 20000,
01030 -55500,
01031 (int) multiplier * (silkscreen_line_width)
01032 );
01033 write_element_line
01034 (
01035 -20000,
01036 -55500,
01037 20000,
01038 -55500,
01039 (int) multiplier * (silkscreen_line_width)
01040 );
01041 write_element_line
01042 (
01043 -20000,
01044 -18000,
01045 20000,
01046 -18000,
01047 (int) multiplier * (silkscreen_line_width)
01048 );
01049
01050 fprintf (fp, "# Write a Cooling tab with notches on the silkscreen\n");
01051 write_element_line
01052 (
01053 -20000,
01054 -55500,
01055 20000,
01056 -55500,
01057 (int) multiplier * (silkscreen_line_width)
01058 );
01059 write_element_line
01060 (
01061 20000,
01062 -55500,
01063 20000,
01064 -68000,
01065 (int) multiplier * (silkscreen_line_width)
01066 );
01067 write_element_line
01068 (
01069 20000,
01070 -68000,
01071 18500,
01072 -68000,
01073 (int) multiplier * (silkscreen_line_width)
01074 );
01075 write_element_line
01076 (
01077 18500,
01078 -68000,
01079 18500,
01080 -75000,
01081 (int) multiplier * (silkscreen_line_width)
01082 );
01083 write_element_line
01084 (
01085 18500,
01086 -75000,
01087 20000,
01088 -75000,
01089 (int) multiplier * (silkscreen_line_width)
01090 );
01091 write_element_line
01092 (
01093 20000,
01094 -75000,
01095 20000,
01096 -79000,
01097 (int) multiplier * (silkscreen_line_width)
01098 );
01099 write_element_line
01100 (
01101 20000,
01102 -79000,
01103 -20000,
01104 -79000,
01105 (int) multiplier * (silkscreen_line_width)
01106 );
01107 write_element_line
01108 (
01109 -20000,
01110 -79000,
01111 -20000,
01112 -75000,
01113 (int) multiplier * (silkscreen_line_width)
01114 );
01115 write_element_line
01116 (
01117 -20000,
01118 -75000,
01119 -18500,
01120 -75000,
01121 (int) multiplier * (silkscreen_line_width)
01122 );
01123 write_element_line
01124 (
01125 -18500,
01126 -75000,
01127 -18500,
01128 -68000,
01129 (int) multiplier * (silkscreen_line_width)
01130 );
01131 write_element_line
01132 (
01133 -18500,
01134 -68000,
01135 -20000,
01136 -68000,
01137 (int) multiplier * (silkscreen_line_width)
01138 );
01139 write_element_line
01140 (
01141 -20000,
01142 -68000,
01143 -20000,
01144 -55500,
01145 (int) multiplier * (silkscreen_line_width)
01146 );
01147 }
01148
01149 if (silkscreen_indicate_1)
01150 {
01152 }
01153
01154 if (courtyard)
01155 {
01156 fprintf (fp, "# Write a courtyard on the silkscreen\n");
01157 write_rectangle
01158 (
01159 xmin,
01160 ymin,
01161 xmax,
01162 ymax,
01163 multiplier * courtyard_line_width
01164 );
01165 }
01166
01167 if (attributes_in_footprint)
01168 {
01169 write_attributes ();
01170 }
01171
01172 fprintf (fp, "\n");
01173 fprintf (fp, ")\n");
01174 fclose (fp);
01175
01176 if (verbose)
01177 {
01178 g_log ("", G_LOG_LEVEL_INFO,
01179 _("wrote a footprint for a %s package: %s."),
01180 footprint_type,
01181 footprint_filename);
01182 }
01183 return (EXIT_SUCCESS);
01184 }
01185
01186
01194 int
01195 to_write_footprint_to220_staggered ()
01196 {
01197 gdouble xmax;
01198 gdouble xmin;
01199 gdouble ymax;
01200 gdouble ymin;
01201 gdouble x_text;
01202 gdouble y_text;
01203 gchar *pin_pad_flags = g_strdup ("");
01204
01205
01206 fp = fopen (footprint_filename, "w");
01207 if (!fp)
01208 {
01209 g_log ("", G_LOG_LEVEL_WARNING,
01210 _("could not open file for %s footprint: %s."),
01211 footprint_type, footprint_filename);
01212 fclose (fp);
01213 return (EXIT_FAILURE);
01214 }
01215
01216 if (license_in_footprint)
01217 {
01218 write_license ();
01219 }
01220
01221
01222 xmin = -20000 - (multiplier * courtyard_clearance_with_package);
01223 xmax = 20000 + (multiplier * courtyard_clearance_with_package);
01224 ymin = -79000 - (multiplier * courtyard_clearance_with_package);
01225 ymax = 10000 + (multiplier * courtyard_clearance_with_package);
01226
01227
01228 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
01229 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
01230 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
01231 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
01232 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
01233 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
01234 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
01235 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
01236
01237 if (multiplier * (-courtyard_length / 2.0) < xmin)
01238 xmin = multiplier * (-courtyard_length / 2.0);
01239 if (multiplier * (courtyard_length / 2.0) > xmax)
01240 xmax = multiplier * (courtyard_length / 2.0);
01241 if (multiplier * (-courtyard_width / 2.0) < ymin)
01242 ymin = multiplier * (-courtyard_width / 2.0);
01243 if (multiplier * (courtyard_width / 2.0) > ymax)
01244 ymax = multiplier * (courtyard_width / 2.0);
01245
01246
01247 x_text = 0.0 ;
01248 y_text = (ymin - 10000.0);
01249 write_element_header (x_text, y_text);
01250
01251 if (!strcmp (pad_shape, "rectangular pad"))
01252 pin_pad_flags = g_strdup ("square");
01253 else
01254 pin_pad_flags = g_strdup ("");
01255 write_pin
01256 (
01257 1,
01258 "",
01259 -10000.0,
01260 0.0,
01261 multiplier * pad_diameter,
01262 multiplier * pad_clearance,
01263 multiplier * (pad_diameter + pad_solder_mask_clearance),
01264 multiplier * pin_drill_diameter,
01265
01266 (pin1_square) ? "square" : ""
01267 );
01268 write_pin
01269 (
01270 2,
01271 "",
01272 0.0,
01273 10000.0,
01274 multiplier * pad_diameter,
01275 multiplier * pad_clearance,
01276 multiplier * (pad_diameter + pad_solder_mask_clearance),
01277 multiplier * pin_drill_diameter,
01278 pin_pad_flags
01279 );
01280 write_pin
01281 (
01282 3,
01283 "",
01284 10000.0,
01285 0.0,
01286 multiplier * pad_diameter,
01287 multiplier * pad_clearance,
01288 multiplier * (pad_diameter + pad_solder_mask_clearance),
01289 multiplier * pin_drill_diameter,
01290 pin_pad_flags
01291 );
01292
01293 write_pin
01294 (
01295 0,
01296 "",
01297 10000.0,
01298 -67000.0,
01299 15000.0,
01300 multiplier * pad_clearance,
01301 15000.0 + (multiplier * pad_solder_mask_clearance),
01302 13000.0,
01303 "hole"
01304 );
01305
01306 if (thermal)
01307 {
01308 write_pad
01309 (
01310 0,
01311 "",
01312 0,
01313 -67000 - (multiplier * (thermal_width + (thermal_length / 2))),
01314 0,
01315 -67000 + (multiplier * (thermal_width + (thermal_length / 2))),
01316 multiplier * thermal_length,
01317 multiplier * pad_clearance,
01318 multiplier * (thermal_length + (2 * thermal_solder_mask_clearance)),
01319 pin_pad_flags
01320 );
01321 }
01322
01323 if (silkscreen_package_outline)
01324 {
01325
01326 fprintf (fp, "# Write leads on the silkscreen\n");
01327 write_element_line
01328 (
01329 -10000,
01330 (int) (multiplier * (-pad_diameter)),
01331 -10000,
01332 -18000,
01333 (int) multiplier * (2 * silkscreen_line_width)
01334 );
01335 write_element_line
01336 (
01337 0,
01338 (int) (multiplier * (-pad_diameter)),
01339 0,
01340 -8000,
01341 (int) multiplier * (2 * silkscreen_line_width)
01342 );
01343 write_element_line
01344 (
01345 10000,
01346 (int) (multiplier * (-pad_diameter)),
01347 10000,
01348 -18000,
01349 (int) multiplier * (2 * silkscreen_line_width)
01350 );
01351
01352 fprintf (fp, "# Write a package body on the silkscreen\n");
01353 write_element_line
01354 (
01355 -20000,
01356 -18000,
01357 -20000,
01358 -55500,
01359 (int) multiplier * (silkscreen_line_width)
01360 );
01361 write_element_line
01362 (
01363 20000,
01364 -18000,
01365 20000,
01366 -55500,
01367 (int) multiplier * (silkscreen_line_width)
01368 );
01369 write_element_line
01370 (
01371 -20000,
01372 -55500,
01373 20000,
01374 -55500,
01375 (int) multiplier * (silkscreen_line_width)
01376 );
01377 write_element_line
01378 (
01379 -20000,
01380 -18000,
01381 20000,
01382 -18000,
01383 (int) multiplier * (silkscreen_line_width)
01384 );
01385
01386 fprintf (fp, "# Write a Cooling tab with notches on the silkscreen\n");
01387 write_element_line
01388 (
01389 -20000,
01390 -55500,
01391 20000,
01392 -55500,
01393 (int) multiplier * (silkscreen_line_width)
01394 );
01395 write_element_line
01396 (
01397 20000,
01398 -55500,
01399 20000,
01400 -68000,
01401 (int) multiplier * (silkscreen_line_width)
01402 );
01403 write_element_line
01404 (
01405 20000,
01406 -68000,
01407 18500,
01408 -68000,
01409 (int) multiplier * (silkscreen_line_width)
01410 );
01411 write_element_line
01412 (
01413 18500,
01414 -68000,
01415 18500,
01416 -75000,
01417 (int) multiplier * (silkscreen_line_width)
01418 );
01419 write_element_line
01420 (
01421 18500,
01422 -75000,
01423 20000,
01424 -75000,
01425 (int) multiplier * (silkscreen_line_width)
01426 );
01427 write_element_line
01428 (
01429 20000,
01430 -75000,
01431 20000,
01432 -79000,
01433 (int) multiplier * (silkscreen_line_width)
01434 );
01435 write_element_line
01436 (
01437 20000,
01438 -79000,
01439 -20000,
01440 -79000,
01441 (int) multiplier * (silkscreen_line_width)
01442 );
01443 write_element_line
01444 (
01445 -20000,
01446 -79000,
01447 -20000,
01448 -75000,
01449 (int) multiplier * (silkscreen_line_width)
01450 );
01451 write_element_line
01452 (
01453 -20000,
01454 -75000,
01455 -18500,
01456 -75000,
01457 (int) multiplier * (silkscreen_line_width)
01458 );
01459 write_element_line
01460 (
01461 -18500,
01462 -75000,
01463 -18500,
01464 -68000,
01465 (int) multiplier * (silkscreen_line_width)
01466 );
01467 write_element_line
01468 (
01469 -18500,
01470 -68000,
01471 -20000,
01472 -68000,
01473 (int) multiplier * (silkscreen_line_width)
01474 );
01475 write_element_line
01476 (
01477 -20000,
01478 -68000,
01479 -20000,
01480 -55500,
01481 (int) multiplier * (silkscreen_line_width)
01482 );
01483 }
01484
01485 if (silkscreen_indicate_1)
01486 {
01488 }
01489
01490 if (courtyard)
01491 {
01492 fprintf (fp, "# Write a courtyard on the silkscreen\n");
01493 write_rectangle
01494 (
01495 xmin,
01496 ymin,
01497 xmax,
01498 ymax,
01499 multiplier * courtyard_line_width
01500 );
01501 }
01502
01503 if (attributes_in_footprint)
01504 {
01505 write_attributes ();
01506 }
01507
01508 fprintf (fp, "\n");
01509 fprintf (fp, ")\n");
01510 fclose (fp);
01511
01512 if (verbose)
01513 {
01514 g_log ("", G_LOG_LEVEL_INFO,
01515 _("wrote a footprint for a %s package: %s."),
01516 footprint_type,
01517 footprint_filename);
01518 }
01519 return (EXIT_SUCCESS);
01520 }
01521
01522
01529 int
01530 to_write_footprint_to220_standing ()
01531 {
01532 gdouble xmax;
01533 gdouble xmin;
01534 gdouble ymax;
01535 gdouble ymin;
01536 gdouble x_text;
01537 gdouble y_text;
01538 gchar *pin_pad_flags = g_strdup ("");
01539
01540
01541 fp = fopen (footprint_filename, "w");
01542 if (!fp)
01543 {
01544 g_log ("", G_LOG_LEVEL_WARNING,
01545 _("could not open file for %s footprint: %s."),
01546 footprint_type, footprint_filename);
01547 fclose (fp);
01548 return (EXIT_FAILURE);
01549 }
01550
01551 if (license_in_footprint)
01552 {
01553 write_license ();
01554 }
01555
01556
01557 xmin = -20750 - (multiplier * courtyard_clearance_with_package);
01558 xmax = 20750 + (multiplier * courtyard_clearance_with_package);
01559 ymin = -12600 - (multiplier * courtyard_clearance_with_package);
01560 ymax = 5900 + (multiplier * courtyard_clearance_with_package);
01561
01562
01563 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
01564 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
01565 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
01566 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
01567 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
01568 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
01569 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
01570 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
01571
01572 if (multiplier * (-courtyard_length / 2.0) < xmin)
01573 xmin = multiplier * (-courtyard_length / 2.0);
01574 if (multiplier * (courtyard_length / 2.0) > xmax)
01575 xmax = multiplier * (courtyard_length / 2.0);
01576 if (multiplier * (-courtyard_width / 2.0) < ymin)
01577 ymin = multiplier * (-courtyard_width / 2.0);
01578 if (multiplier * (courtyard_width / 2.0) > ymax)
01579 ymax = multiplier * (courtyard_width / 2.0);
01580
01581
01582 x_text = 0.0 ;
01583 y_text = (ymin - 10000.0);
01584 write_element_header (x_text, y_text);
01585
01586 if (!strcmp (pad_shape, "rectangular pad"))
01587 pin_pad_flags = g_strdup ("square");
01588 else
01589 pin_pad_flags = g_strdup ("");
01590 write_pin
01591 (
01592 1,
01593 "",
01594 -10000.0,
01595 0.0,
01596 multiplier * pad_diameter,
01597 multiplier * pad_clearance,
01598 multiplier * (pad_diameter + pad_solder_mask_clearance),
01599 multiplier * pin_drill_diameter,
01600
01601 (pin1_square) ? "square" : ""
01602 );
01603 write_pin
01604 (
01605 2,
01606 "",
01607 0.0,
01608 0.0,
01609 multiplier * pad_diameter,
01610 multiplier * pad_clearance,
01611 multiplier * (pad_diameter + pad_solder_mask_clearance),
01612 multiplier * pin_drill_diameter,
01613 pin_pad_flags
01614 );
01615 write_pin
01616 (
01617 3,
01618 "",
01619 10000.0,
01620 0.0,
01621 multiplier * pad_diameter,
01622 multiplier * pad_clearance,
01623 multiplier * (pad_diameter + pad_solder_mask_clearance),
01624 multiplier * pin_drill_diameter,
01625 pin_pad_flags
01626 );
01627
01628 if (silkscreen_package_outline)
01629 {
01630 fprintf (fp, "# Write a package body on the silkscreen\n");
01631 write_element_line
01632 (
01633 -20750,
01634 -12600,
01635 -20750,
01636 5900,
01637 (int) multiplier * (silkscreen_line_width)
01638 );
01639 write_element_line
01640 (
01641 -20750,
01642 5900,
01643 20750,
01644 5900,
01645 (int) multiplier * (silkscreen_line_width)
01646 );
01647 write_element_line
01648 (
01649 20750,
01650 5900,
01651 20750,
01652 -12600,
01653 (int) multiplier * (silkscreen_line_width)
01654 );
01655 write_element_line
01656 (
01657 20750,
01658 -12600,
01659 -20750,
01660 -12600,
01661 (int) multiplier * (silkscreen_line_width)
01662 );
01663 write_element_line
01664 (
01665 -18750,
01666 -10000,
01667 18750,
01668 -10000,
01669 5200
01670 );
01671 write_element_line
01672 (
01673 -20750,
01674 -7600,
01675 20750,
01676 -7600,
01677 (int) multiplier * (silkscreen_line_width)
01678 );
01679 }
01680
01681 if (silkscreen_indicate_1)
01682 {
01684 }
01685
01686 if (courtyard)
01687 {
01688 fprintf (fp, "# Write a courtyard on the silkscreen\n");
01689 write_rectangle
01690 (
01691 xmin,
01692 ymin,
01693 xmax,
01694 ymax,
01695 multiplier * courtyard_line_width
01696 );
01697 }
01698
01699 if (attributes_in_footprint)
01700 {
01701 write_attributes ();
01702 }
01703
01704 fprintf (fp, "\n");
01705 fprintf (fp, ")\n");
01706 fclose (fp);
01707
01708 if (verbose)
01709 {
01710 g_log ("", G_LOG_LEVEL_INFO,
01711 _("wrote a footprint for a %s package: %s."),
01712 footprint_type,
01713 footprint_filename);
01714 }
01715 return (EXIT_SUCCESS);
01716 }
01717
01718
01726 int
01727 to_write_footprint_to220_standing_staggered ()
01728 {
01729 gdouble xmax;
01730 gdouble xmin;
01731 gdouble ymax;
01732 gdouble ymin;
01733 gdouble x_text;
01734 gdouble y_text;
01735 gchar *pin_pad_flags = g_strdup ("");
01736
01737
01738 fp = fopen (footprint_filename, "w");
01739 if (!fp)
01740 {
01741 g_log ("", G_LOG_LEVEL_WARNING,
01742 _("could not open file for %s footprint: %s."),
01743 footprint_type, footprint_filename);
01744 fclose (fp);
01745 return (EXIT_FAILURE);
01746 }
01747
01748 if (license_in_footprint)
01749 {
01750 write_license ();
01751 }
01752
01753
01754 xmin = -30750 - (multiplier * courtyard_clearance_with_package);
01755 xmax = 20750 + (multiplier * courtyard_clearance_with_package);
01756 ymin = -12600 - (multiplier * courtyard_clearance_with_package);
01757 ymax = 5900 + (multiplier * courtyard_clearance_with_package);
01758
01759
01760 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
01761 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
01762 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
01763 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
01764 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
01765 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
01766 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
01767 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
01768
01769 if (multiplier * (-courtyard_length / 2.0) < xmin)
01770 xmin = multiplier * (-courtyard_length / 2.0);
01771 if (multiplier * (courtyard_length / 2.0) > xmax)
01772 xmax = multiplier * (courtyard_length / 2.0);
01773 if (multiplier * (-courtyard_width / 2.0) < ymin)
01774 ymin = multiplier * (-courtyard_width / 2.0);
01775 if (multiplier * (courtyard_width / 2.0) > ymax)
01776 ymax = multiplier * (courtyard_width / 2.0);
01777
01778
01779 x_text = 0.0 ;
01780 y_text = (ymin - 10000.0);
01781 write_element_header (x_text, y_text);
01782
01783 if (!strcmp (pad_shape, "rectangular pad"))
01784 pin_pad_flags = g_strdup ("square");
01785 else
01786 pin_pad_flags = g_strdup ("");
01787 write_pin
01788 (
01789 1,
01790 "",
01791 -10000.0,
01792 0.0,
01793 multiplier * pad_diameter,
01794 multiplier * pad_clearance,
01795 multiplier * (pad_diameter + pad_solder_mask_clearance),
01796 multiplier * pin_drill_diameter,
01797
01798 (pin1_square) ? "square" : ""
01799 );
01800 write_pin
01801 (
01802 2,
01803 "",
01804 0.0,
01805 -10000.0,
01806 multiplier * pad_diameter,
01807 multiplier * pad_clearance,
01808 multiplier * (pad_diameter + pad_solder_mask_clearance),
01809 multiplier * pin_drill_diameter,
01810 pin_pad_flags
01811 );
01812 write_pin
01813 (
01814 3,
01815 "",
01816 10000.0,
01817 0.0,
01818 multiplier * pad_diameter,
01819 multiplier * pad_clearance,
01820 multiplier * (pad_diameter + pad_solder_mask_clearance),
01821 multiplier * pin_drill_diameter,
01822 pin_pad_flags
01823 );
01824
01825 if (silkscreen_package_outline)
01826 {
01827 fprintf (fp, "# Write a package body on the silkscreen\n");
01828 write_element_line
01829 (
01830 -30750,
01831 -12600,
01832 -30750,
01833 5900,
01834 (int) multiplier * (silkscreen_line_width)
01835 );
01836 write_element_line
01837 (
01838 -30750,
01839 5900,
01840 20750,
01841 5900,
01842 (int) multiplier * (silkscreen_line_width)
01843 );
01844 write_element_line
01845 (
01846 20750,
01847 5900,
01848 20750,
01849 -12600,
01850 (int) multiplier * (silkscreen_line_width)
01851 );
01852 write_element_line
01853 (
01854 20750,
01855 -12600,
01856 -30750,
01857 -12600,
01858 (int) multiplier * (silkscreen_line_width)
01859 );
01860 write_element_line
01861 (
01862 -18750,
01863 -10000,
01864 18750,
01865 -10000,
01866 5200
01867 );
01868 write_element_line
01869 (
01870 -30750,
01871 -7600,
01872 20750,
01873 -7600,
01874 (int) multiplier * (silkscreen_line_width)
01875 );
01876 }
01877
01878 if (silkscreen_indicate_1)
01879 {
01881 }
01882
01883 if (courtyard)
01884 {
01885 fprintf (fp, "# Write a courtyard on the silkscreen\n");
01886 write_rectangle
01887 (
01888 xmin,
01889 ymin,
01890 xmax,
01891 ymax,
01892 multiplier * courtyard_line_width
01893 );
01894 }
01895
01896 if (attributes_in_footprint)
01897 {
01898 write_attributes ();
01899 }
01900
01901 fprintf (fp, "\n");
01902 fprintf (fp, ")\n");
01903 fclose (fp);
01904
01905 if (verbose)
01906 {
01907 g_log ("", G_LOG_LEVEL_INFO,
01908 _("wrote a footprint for a %s package: %s."),
01909 footprint_type,
01910 footprint_filename);
01911 }
01912 return (EXIT_SUCCESS);
01913 }
01914
01915
01922 int
01923 to_write_footprint_to92 ()
01924 {
01925 gdouble xmax;
01926 gdouble xmin;
01927 gdouble ymax;
01928 gdouble ymin;
01929 gdouble x_text;
01930 gdouble y_text;
01931 gchar *pin_pad_flags = g_strdup ("");
01932
01933
01934 fp = fopen (footprint_filename, "w");
01935 if (!fp)
01936 {
01937 g_log ("", G_LOG_LEVEL_WARNING,
01938 _("could not open file for %s footprint: %s."),
01939 footprint_type, footprint_filename);
01940 fclose (fp);
01941 return (EXIT_FAILURE);
01942 }
01943
01944 if (license_in_footprint)
01945 {
01946 write_license ();
01947 }
01948
01949
01950 xmin = -10500 - (multiplier * courtyard_clearance_with_package);
01951 xmax = 10500 + (multiplier * courtyard_clearance_with_package);
01952 ymin = -8600 - (multiplier * courtyard_clearance_with_package);
01953 ymax = 10500 + (multiplier * courtyard_clearance_with_package);
01954
01955
01956 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
01957 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
01958 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
01959 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
01960 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
01961 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
01962 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
01963 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
01964
01965 if (multiplier * (-courtyard_length / 2.0) < xmin)
01966 xmin = multiplier * (-courtyard_length / 2.0);
01967 if (multiplier * (courtyard_length / 2.0) > xmax)
01968 xmax = multiplier * (courtyard_length / 2.0);
01969 if (multiplier * (-courtyard_width / 2.0) < ymin)
01970 ymin = multiplier * (-courtyard_width / 2.0);
01971 if (multiplier * (courtyard_width / 2.0) > ymax)
01972 ymax = multiplier * (courtyard_width / 2.0);
01973
01974
01975 x_text = 0.0 ;
01976 y_text = (ymin - 10000.0);
01977 write_element_header (x_text, y_text);
01978
01979 if (!strcmp (pad_shape, "rectangular pad"))
01980 pin_pad_flags = g_strdup ("square");
01981 else
01982 pin_pad_flags = g_strdup ("");
01983 write_pin
01984 (
01985 1,
01986 "",
01987 -5000.0,
01988 0.0,
01989 multiplier * pad_diameter,
01990 multiplier * pad_clearance,
01991 multiplier * (pad_diameter + pad_solder_mask_clearance),
01992 multiplier * pin_drill_diameter,
01993
01994 (pin1_square) ? "square" : ""
01995 );
01996 write_pin
01997 (
01998 2,
01999 "",
02000 0.0,
02001 0.0,
02002 multiplier * pad_diameter,
02003 multiplier * pad_clearance,
02004 multiplier * (pad_diameter + pad_solder_mask_clearance),
02005 multiplier * pin_drill_diameter,
02006 pin_pad_flags
02007 );
02008 write_pin
02009 (
02010 3,
02011 "",
02012 5000.0,
02013 0.0,
02014 multiplier * pad_diameter,
02015 multiplier * pad_clearance,
02016 multiplier * (pad_diameter + pad_solder_mask_clearance),
02017 multiplier * pin_drill_diameter,
02018 pin_pad_flags
02019 );
02020
02021 if (silkscreen_package_outline)
02022 {
02023 fprintf (fp, "# Write a package body on the silkscreen\n");
02024 write_element_line
02025 (
02026 -8600,
02027 -6000,
02028 8600,
02029 -6000,
02030 (int) multiplier * (silkscreen_line_width)
02031 );
02032 write_element_arc
02033 (
02034 0,
02035 0,
02036 10500,
02037 10500,
02038 -35,
02039 250,
02040 multiplier * silkscreen_line_width
02041 );
02042 }
02043
02044 if (silkscreen_indicate_1)
02045 {
02047 }
02048
02049 if (courtyard)
02050 {
02051 fprintf (fp, "# Write a courtyard on the silkscreen\n");
02052 if (package_is_radial)
02053 {
02054 write_element_arc
02055 (
02056 0.0,
02057 0.0,
02058 xmax,
02059 ymax,
02060 0,
02061 360,
02062 multiplier * courtyard_line_width
02063 );
02064 }
02065 else
02066 {
02067 write_rectangle
02068 (
02069 xmin,
02070 ymin,
02071 xmax,
02072 ymax,
02073 multiplier * courtyard_line_width
02074 );
02075 }
02076 }
02077
02078 if (attributes_in_footprint)
02079 {
02080 write_attributes ();
02081 }
02082
02083 fprintf (fp, "\n");
02084 fprintf (fp, ")\n");
02085 fclose (fp);
02086
02087 if (verbose)
02088 {
02089 g_log ("", G_LOG_LEVEL_INFO,
02090 _("wrote a footprint for a %s package: %s."),
02091 footprint_type,
02092 footprint_filename);
02093 }
02094 return (EXIT_SUCCESS);
02095 }
02096
02097
02105 int
02106 to_write_footprint_to92_staggered ()
02107 {
02108 gdouble xmax;
02109 gdouble xmin;
02110 gdouble ymax;
02111 gdouble ymin;
02112 gdouble x_text;
02113 gdouble y_text;
02114 gchar *pin_pad_flags = g_strdup ("");
02115
02116
02117 fp = fopen (footprint_filename, "w");
02118 if (!fp)
02119 {
02120 g_log ("", G_LOG_LEVEL_WARNING,
02121 _("could not open file for %s footprint: %s."),
02122 footprint_type, footprint_filename);
02123 fclose (fp);
02124 return (EXIT_FAILURE);
02125 }
02126
02127 if (license_in_footprint)
02128 {
02129 write_license ();
02130 }
02131
02132
02133 xmin = -10500 - (multiplier * courtyard_clearance_with_package);
02134 xmax = 10500 + (multiplier * courtyard_clearance_with_package);
02135 ymin = -8600 - (multiplier * courtyard_clearance_with_package);
02136 ymax = 10500 + (multiplier * courtyard_clearance_with_package);
02137
02138
02139 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
02140 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
02141 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
02142 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
02143 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
02144 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
02145 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
02146 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
02147
02148 if (multiplier * (-courtyard_length / 2.0) < xmin)
02149 xmin = multiplier * (-courtyard_length / 2.0);
02150 if (multiplier * (courtyard_length / 2.0) > xmax)
02151 xmax = multiplier * (courtyard_length / 2.0);
02152 if (multiplier * (-courtyard_width / 2.0) < ymin)
02153 ymin = multiplier * (-courtyard_width / 2.0);
02154 if (multiplier * (courtyard_width / 2.0) > ymax)
02155 ymax = multiplier * (courtyard_width / 2.0);
02156
02157
02158 x_text = 0.0 ;
02159 y_text = (ymin - 10000.0);
02160 write_element_header (x_text, y_text);
02161
02162 if (!strcmp (pad_shape, "rectangular pad"))
02163 pin_pad_flags = g_strdup ("square");
02164 else
02165 pin_pad_flags = g_strdup ("");
02166 write_pin
02167 (
02168 1,
02169 "",
02170 -5000.0,
02171 0.0,
02172 multiplier * pad_diameter,
02173 multiplier * pad_clearance,
02174 multiplier * (pad_diameter + pad_solder_mask_clearance),
02175 multiplier * pin_drill_diameter,
02176
02177 (pin1_square) ? "square" : ""
02178 );
02179 write_pin
02180 (
02181 2,
02182 "",
02183 0.0,
02184 -5000.0,
02185 multiplier * pad_diameter,
02186 multiplier * pad_clearance,
02187 multiplier * (pad_diameter + pad_solder_mask_clearance),
02188 multiplier * pin_drill_diameter,
02189 pin_pad_flags
02190 );
02191 write_pin
02192 (
02193 3,
02194 "",
02195 5000.0,
02196 0.0,
02197 multiplier * pad_diameter,
02198 multiplier * pad_clearance,
02199 multiplier * (pad_diameter + pad_solder_mask_clearance),
02200 multiplier * pin_drill_diameter,
02201 pin_pad_flags
02202 );
02203
02204 if (silkscreen_package_outline)
02205 {
02206 fprintf (fp, "# Write a package body on the silkscreen\n");
02207 write_element_line
02208 (
02209 -8600,
02210 -6000,
02211 8600,
02212 -6000,
02213 (int) multiplier * (silkscreen_line_width)
02214 );
02215 write_element_arc
02216 (
02217 0,
02218 0,
02219 10500,
02220 10500,
02221 -35,
02222 250,
02223 multiplier * silkscreen_line_width
02224 );
02225 }
02226
02227 if (silkscreen_indicate_1)
02228 {
02230 }
02231
02232 if (courtyard)
02233 {
02234 fprintf (fp, "# Write a courtyard on the silkscreen\n");
02235 if (package_is_radial)
02236 {
02237 write_element_arc
02238 (
02239 0.0,
02240 0.0,
02241 xmax,
02242 ymax,
02243 0,
02244 360,
02245 multiplier * courtyard_line_width
02246 );
02247 }
02248 else
02249 {
02250 write_rectangle
02251 (
02252 xmin,
02253 ymin,
02254 xmax,
02255 ymax,
02256 multiplier * courtyard_line_width
02257 );
02258 }
02259 }
02260
02261 if (attributes_in_footprint)
02262 {
02263 write_attributes ();
02264 }
02265
02266 fprintf (fp, "\n");
02267 fprintf (fp, ")\n");
02268 fclose (fp);
02269
02270 if (verbose)
02271 {
02272 g_log ("", G_LOG_LEVEL_INFO,
02273 _("wrote a footprint for a %s package: %s."),
02274 footprint_type,
02275 footprint_filename);
02276 }
02277 return (EXIT_SUCCESS);
02278 }
02279
02280
02284 static fpw_function_t
02285 to_function_list[] =
02286 {
02287 #if GUI
02288 {
02289 "Set GUI constraints",
02290 to_set_gui_constraints,
02291 "Set GUI constraints for a TO package",
02292 NULL
02293 },
02294 #endif
02295 {
02296 "Create element",
02297 to_create_element_to92,
02298 "Create an element for a TO92 package",
02299 NULL
02300 },
02301 {
02302 "Packages list",
02303 to_create_packages_list,
02304 "Create a list of known TO packages",
02305 NULL
02306 },
02307 {
02308 "Default Element Values",
02309 to_get_default_footprint_values,
02310 "Get default values for a INDC SMT package",
02311 NULL
02312 },
02313 {
02314 "Write footprint",
02315 to_write_footprint_to220,
02316 "Write a footprint for a TO220 package",
02317 NULL
02318 },
02319 {
02320 "Write footprint",
02321 to_write_footprint_to220_staggered,
02322 "Write a footprint for a TO220S package",
02323 NULL
02324 },
02325 {
02326 "Write footprint",
02327 to_write_footprint_to220_standing,
02328 "Write a footprint for a TO220W package",
02329 NULL
02330 },
02331 {
02332 "Write footprint",
02333 to_write_footprint_to220_standing_staggered,
02334 "Write a footprint for a TO220SW package",
02335 NULL
02336 },
02337 {
02338 "Write footprint",
02339 to_write_footprint_to92,
02340 "Write a footprint for a TO92 package",
02341 NULL
02342 }
02343 };
02344
02345
02349 REGISTER_FUNCTIONS (to_function_list)
02350
02351
02352
02355 void
02356 to_init ()
02357 {
02358 register_to_function_list ();
02359 }
02360
02361
02362