/* * Copyright © 2018 Keith Packard * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ load "footprint.5c" import Footprint; int pins = 8; if (dim(argv) > 1) pins = atoi(argv[1]); string name = sprintf("m50-31-%d", pins); real pad_width = 0.74; real pad_height = 1.30; real package_extra_width = 1.67; real pad_spacing = 1.27; real total_height = 3.60; real package_height = 1.80; real package_width = 1.27 * (pins - 1) + package_extra_width; real pad_gap = total_height - (pad_height * 2); real pad_y_center = pad_gap / 2 + pad_height / 2; real pad_y(int n) { if ((n & 1) != 0) return -pad_y_center; else return pad_y_center; } real pad_x(int n) { return (- (pins-1) / 2) * pad_spacing + (n-1) * pad_spacing; } void m50_pad(int n) { pad_mm(pad_x(n), pad_y(n), pad_width, pad_height, sprintf("%d", n), sprintf("%d", n)); } element_start(name); rect(-package_width / 2, -package_height / 2, package_width, package_height); for (int i = 1; i <= pins; i++) m50_pad(i); element_end();