diff --git a/readme.md b/readme.md index 5b5793e..16973c6 100644 --- a/readme.md +++ b/readme.md @@ -678,6 +678,7 @@ PCB cameras. |:--- |:--- | | `camera_connector_pos(type)` | The flex connector block for the camera itself's position | | `camera_connector_size(type)` | The flex connector block for the camera itself's size | +| `camera_fov(type)` | The field of view of the camera lens | | `camera_lens(type)` | Stack of lens parts, can be round, rectangular or rounded rectangular, with optional tapered aperture | | `camera_lens_offset(type)` | Offset of the lens center from the PCB centre | | `camera_pcb(type)` | The PCB part of the camera | @@ -685,7 +686,7 @@ PCB cameras. ### Modules | Module | Description | |:--- |:--- | -| `camera(type, show_lens = true)` | Draw specified PCB camera | +| `camera(type, show_lens = true, fov_distance = 0, fov = undef)` | Draw specified PCB camera | | `camera_lens(type, offset = 0, show_lens = true)` | Draw the lens stack, with optional offset for making a clearance hole | ![cameras](tests/png/cameras.png) diff --git a/vitamins/camera.scad b/vitamins/camera.scad index b4c1717..b676038 100644 --- a/vitamins/camera.scad +++ b/vitamins/camera.scad @@ -28,6 +28,7 @@ function camera_lens_offset(type) = type[3]; //! Offset of the lens center fro function camera_lens(type) = type[4]; //! Stack of lens parts, can be round, rectangular 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 +function camera_fov(type) = type[7]; //! The field of view of the camera lens module camera_lens(type, offset = 0, show_lens = true) //! Draw the lens stack, with optional offset for making a clearance hole color(grey(20)) @@ -57,7 +58,7 @@ module camera_lens(type, offset = 0, show_lens = true) //! Draw the lens stack, } } -module camera(type, show_lens = true) { //! Draw specified PCB camera +module camera(type, show_lens = true, fov_distance = 0, fov = undef) { //! Draw specified PCB camera vitamin(str("camera(", type[0], "): ", type[1])); pcb = camera_pcb(type); @@ -66,6 +67,18 @@ module camera(type, show_lens = true) { //! Draw specified PCB camera translate_z(pcb_thickness(pcb)) { camera_lens(type, show_lens = show_lens); + if (show_lens&& fov_distance > 0) { + lens = camera_lens(type); + fov = is_undef(fov) ? camera_fov(type) : fov; + if (is_list(fov)) + #translate_z(lens[2][0].z) // note: use of # is deliberate, to show highlighted field of view + translate(camera_lens_offset(type)) + hull() { + cube([lens[1][1]/2, lens[1][1]/2, eps], center=true); + translate_z(fov_distance) + cube([2 * fov_distance * tan(fov.x / 2), 2 * fov_distance * tan(fov.y / 2), eps], center=true); + } + } conn = camera_connector_size(type); if(conn) { diff --git a/vitamins/cameras.scad b/vitamins/cameras.scad index cab5d46..8232b99 100644 --- a/vitamins/cameras.scad +++ b/vitamins/cameras.scad @@ -32,7 +32,8 @@ rpi_camera_v1 = ["rpi_camera_v1", "Raspberry Pi camera V1", rpi_camera_v1_pcb, [ [[0, 0, 4], 7.5 / 2], [[0, 0, 5], 5.5 / 2, [1.5/2, 2/2, 0.5]], ], - [0, 12 - 1.5 - 2.5], [8, 5, 1] + [0, 12 - 1.5 - 2.5], [8, 5, 1], + [54, 41] // FOV ]; rpi_camera_v2_pcb = ["", "", 25, 23.862, 1, 2, 2.2, 0, "green", false, [[2, -2], [-2, -2], [2, -14.5], [-2, -14.5]], @@ -47,7 +48,8 @@ rpi_camera_v2 = ["rpi_camera_v2", "Raspberry Pi camera V2", rpi_camera_v2_pcb, [ [[0, 0, 4], 7.5 / 2], [[0, 0, 5], 5.5 / 2, [1.5/2, 2/2, 0.5]], ], - [-13.8 + 12.5, 23.862 / 2 - 4.7], [8.5, 4, 1] + [-13.8 + 12.5, 23.862 / 2 - 4.7], [8.5, 4, 1], + [62.2, 48.8] // FOV ]; rpi_camera_pcb = ["", "", 36, 36, 1.6, 0, 3.2, 0, "green", false, [[3.5, -3.5], [-3.5, -3.5], [3.5, 3.5], [-3.5, 3.5]],