...
 
Commits (2)
......@@ -2,26 +2,74 @@
#include <iostream>
//--------------------------------------------------------------------------------------------------
// All length measurements are in mm.
int main() {
// All length measurements are in mm.
double width = 6;
double height = 14;
// reused vars... dirty C style
double pad_x_min;
double pad_x_max;
double pad_y_min;
double pad_y_max;
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) {
pad_x_min = soic_pos_x + i * soic_pitch;
pad_x_max = pad_x_min + pad_width;
pad_y_min = soic_pos_y;
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);
}
}
}
// Cable attachment dims
double const min_cut_thickness = 0.4;
double const cable_pad_height = 2.4;
pad_x_min = (width - 2 * min_cut_thickness) / 3;
pad_x_max = pad_x_min + min_cut_thickness;
pad_y_min = 0;
pad_y_max = pad_y_min + cable_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);
}
}
......