2020-06-29 18:03:54 -04:00
|
|
|
//
|
|
|
|
// NopSCADlib Copyright Chris Palmer 2020
|
|
|
|
// nop.head@gmail.com
|
|
|
|
// hydraraptor.blogspot.com
|
|
|
|
//
|
|
|
|
// This file is part of NopSCADlib.
|
|
|
|
//
|
|
|
|
// NopSCADlib 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 3 of
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// NopSCADlib 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along with NopSCADlib.
|
|
|
|
// If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
//! PCB cameras.
|
|
|
|
//
|
|
|
|
include <../utils/core/core.scad>
|
|
|
|
use <pcb.scad>
|
|
|
|
|
2020-07-04 04:55:38 -04:00
|
|
|
function camera_pcb(type) = type[2]; //! The PCB part of the camera
|
|
|
|
function camera_lens_offset(type) = type[3]; //! Offset of the lens center from the PCB centre
|
|
|
|
function camera_lens(type) = type[4]; //! Stack of lens parts, can be round, rectanular or rounded rectangular, with optional tapered aperture
|
|
|
|
function camera_connector_pos(type) = type[5]; //! The flex connector block for the camera itself's position
|
|
|
|
function camera_connector_size(type)= type[6]; //! The flex connector block for the camera itself's size
|
|
|
|
|
2020-11-21 15:45:39 -05:00
|
|
|
module camera_lens(type, offset = 0, show_lens = true) //! Draw the lens stack, with optional offset for making a clearance hole
|
2020-07-04 04:55:38 -04:00
|
|
|
color(grey(20))
|
|
|
|
translate(camera_lens_offset(type))
|
|
|
|
for(p = camera_lens(type)) {
|
|
|
|
size = p[0];
|
|
|
|
r = p[1] + offset;
|
|
|
|
app = p[2];
|
|
|
|
if(size.x)
|
2021-02-08 04:41:07 -05:00
|
|
|
rounded_rectangle(size + [2 * offset, 2 * offset, round_to_layer(offset)], r);
|
2020-07-04 04:55:38 -04:00
|
|
|
else
|
2020-11-21 15:45:39 -05:00
|
|
|
if (show_lens)
|
|
|
|
translate_z(size.y)
|
|
|
|
rotate_extrude()
|
|
|
|
difference() {
|
|
|
|
square([r, size.z + round_to_layer(offset)]);
|
2020-07-04 04:55:38 -04:00
|
|
|
|
2020-11-21 15:45:39 -05:00
|
|
|
if(app)
|
|
|
|
translate([0, size.z])
|
|
|
|
hull() {
|
|
|
|
translate([0, -eps])
|
|
|
|
square([app.y, eps * 2]);
|
2020-07-04 04:55:38 -04:00
|
|
|
|
2020-11-21 15:45:39 -05:00
|
|
|
translate([0, -app.z])
|
|
|
|
square([app.x, app.z]);
|
|
|
|
}
|
|
|
|
}
|
2020-07-04 04:55:38 -04:00
|
|
|
}
|
2020-06-29 18:03:54 -04:00
|
|
|
|
2020-11-21 15:45:39 -05:00
|
|
|
module camera(type, show_lens = true) { //! Draw specified PCB camera
|
2020-06-29 18:03:54 -04:00
|
|
|
vitamin(str("camera(", type[0], "): ", type[1]));
|
|
|
|
pcb = camera_pcb(type);
|
|
|
|
|
|
|
|
not_on_bom()
|
|
|
|
pcb(pcb);
|
|
|
|
|
|
|
|
translate_z(pcb_thickness(pcb)) {
|
2020-11-21 15:45:39 -05:00
|
|
|
camera_lens(type, show_lens = show_lens);
|
2020-06-29 18:03:54 -04:00
|
|
|
|
2020-07-04 04:55:38 -04:00
|
|
|
conn = camera_connector_size(type);
|
2020-06-29 18:03:54 -04:00
|
|
|
if(conn) {
|
2020-07-04 04:55:38 -04:00
|
|
|
pos = camera_connector_pos(type);
|
2020-06-29 18:03:54 -04:00
|
|
|
color(grey(20))
|
2020-07-04 04:55:38 -04:00
|
|
|
translate(pos)
|
2021-02-08 04:41:07 -05:00
|
|
|
rounded_rectangle(conn, 0.5);
|
2020-06-29 18:03:54 -04:00
|
|
|
|
|
|
|
flex = [5, 0.1];
|
|
|
|
color("orange")
|
|
|
|
hull() {
|
|
|
|
translate_z(flex.y /2)
|
|
|
|
translate(camera_lens_offset(type) + [0, camera_lens(type)[0][0].y / 2])
|
|
|
|
cube([flex.x, eps, flex.y], center = true);
|
|
|
|
|
2020-07-04 04:55:38 -04:00
|
|
|
translate_z(conn.z - flex.y)
|
2020-07-04 09:54:19 -04:00
|
|
|
translate([camera_lens_offset(type).x, pos.y] - [0, conn.y / 2])
|
2020-06-29 18:03:54 -04:00
|
|
|
cube([flex.x, eps, flex.y], center = true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|