diff --git a/node_board/main.cpp b/node_board/main.cpp index 7d6a7409a56897d7f493d5f5bc2d0f183b13efb5..35f54336b10a9188395c7df45c22c2bb233461cd 100644 --- a/node_board/main.cpp +++ b/node_board/main.cpp @@ -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); + } } }