Skip to content
Snippets Groups Projects
Commit 7799b2e0 authored by Erik Strand's avatar Erik Strand
Browse files

Draw SOIC pads

parent bec7c7e4
No related branches found
No related tags found
No related merge requests found
......@@ -2,26 +2,55 @@
#include <iostream>
//--------------------------------------------------------------------------------------------------
// All length measurements are in mm.
int main() {
// All length measurements are in mm.
double width = 6;
double height = 14;
double ppmm = 50;
auto const to_px = [ppmm](double x) {
return static_cast<uint32_t>(ppmm * x);
};
uint32_t width_px = to_px(width);
uint32_t height_px = to_px(height);
// overall board dims
double const width = 6;
double const height = 14;
uint32_t const width_px = to_px(width);
uint32_t const height_px = to_px(height);
PngWriter png_writer;
png_writer.allocate(width_px, height_px);
png_writer.set_all_pixels_black();
for (uint32_t y = 0; y < 10; ++y) {
for (uint32_t x = 0; x < 10; ++x) {
png_writer.set_pixel(x, y, 255);
auto const set_pixel = [&png_writer, height_px](uint32_t x, uint32_t y) {
png_writer.set_pixel(x, height_px - y - 1, 255);
};
// SOIC dims
double const pad_width = 0.5;
double const pad_height = 2.4;
//double const soic_width = 5;
double const soic_height = 7;
double const soic_pitch = 1.27;
// Draw the SOIC pads
double const soic_pos_x = 0.5 * (width - 3 * soic_pitch - pad_width);
double const soic_pos_y = 0.5 * (height - soic_height);
for (uint32_t i = 0; i < 4; ++i) {
double const pad_x_min = soic_pos_x + i * soic_pitch;
double const pad_x_max = pad_x_min + pad_width;
double pad_y_min = soic_pos_y;
double pad_y_max = pad_y_min + pad_height;
for (uint32_t x = to_px(pad_x_min); x < to_px(pad_x_max); ++x) {
for (uint32_t y = to_px(pad_y_min); y < to_px(pad_y_max); ++y) {
set_pixel(x, y);
}
}
pad_y_min = height - pad_y_max;
pad_y_max = pad_y_min + pad_height;
for (uint32_t x = to_px(pad_x_min); x < to_px(pad_x_max); ++x) {
for (uint32_t y = to_px(pad_y_min); y < to_px(pad_y_max); ++y) {
set_pixel(x, y);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment