more cleanup and documentation

This commit is contained in:
Edward Kisiel
2024-01-31 21:36:04 -05:00
parent a33450ac21
commit e5b9e8263c
17 changed files with 1673 additions and 748 deletions

View File

@@ -1,169 +1,219 @@
/*
This file is part of SBC Case Builder https://github.com/hominoids/SBC_Case_Builder
Copyright 2022,2023,2024 Edward A. Kisiel hominoid@cablemi.com
This program 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.
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 this program. If not, see <http://www.gnu.org/licenses/>
Code released under GPLv3: http://www.gnu.org/licenses/gpl.html
fan_cover(size, thick)
fan_mask(size, thick, style)
*/
/* fan cover */
/*
NAME: fan_cover
DESCRIPTION: creates fan covers for fan openings
TODO: none
USAGE: fan_cover(size, thick)
size = size of fan
thick = thickness of cover
*/
module fan_cover(size, thick) {
difference() {
color("grey",1) slab([size,size,thick],3);
color("grey",1) fan_mask(size, thick, 2);
color("grey", 1) slab([size, size, thick], 3);
color("grey", 1) fan_mask(size, thick, 2);
}
}
/* fan mask to create opening */
/*
DESCRIPTION: creates heatsink masks for openings
TODO:
USAGE: heatsink_mask(size, thick, style)
size = size of fan
thick = thickness of cover
style = 0="fan_open", 1="fan_1", 2="fan_2", 3"fan_hex"
*/
module fan_mask(size, thick, style) {
$fn=90;
if(style == 1) {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-2);
if(size == 40) {
// mount holes
translate ([size-4,size-4,-1]) cylinder(h=thick+2, d=3);
translate ([size-4,4,-1]) cylinder(h=thick+2, d=3);
translate ([4,size-4,-1]) cylinder(h=thick+2, d=3);
translate ([4,4,-1]) cylinder(h=thick+2, d=3);
}
if(size == 60) {
// mount holes
translate ([size-5,size-5,-1]) cylinder(h=thick+2, d=3);
translate ([size-5,5,-1]) cylinder(h=thick+2, d=3);
translate ([5,size-5,-1]) cylinder(h=thick+2, d=3);
translate ([5,5,-1]) cylinder(h=thick+2, d=3);
}
if(size >= 80) {
// mount holes
translate ([size-3.75,size-3.75,-1]) cylinder(h=thick+2, d=3);
translate ([size-3.75,3.75,-1]) cylinder(h=thick+2, d=3);
translate ([3.75,size-3.75,-1]) cylinder(h=thick+2, d=3);
translate ([3.75,3.75,-1]) cylinder(h=thick+2, d=3);
}
hole_pos = size == 30 ? 3 :
size == 40 ? 4 :
size == 50 || size == 60 || size == 70 ? 5 :
size >= 80 ? 3.75 : 3.75;
$fn = 90;
adj = .01;
if(style == 0) {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-1);
// mount holes
translate([size-hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([size-hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
}
if(style == 2 && size == 40) {
difference() {
union () {
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-2);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-6);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-10);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-14);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-18);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-22);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-26);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-30);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-34);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-38);
}
// mount holes
translate ([size-4,size-4,-1]) cylinder(h=thick+2, d=3);
translate ([size-4,4,-1]) cylinder(h=thick+2, d=3);
translate ([4,size-4,-1]) cylinder(h=thick+2, d=3);
translate ([4,4,-1]) cylinder(h=thick+2, d=3);
}
translate([6.5,5,-2]) rotate([0,0,45]) cube([size,2,thick+4]);
translate([4.5,size-6,-2]) rotate([0,0,-45]) cube([size,2,thick+4]);
}
}
if(style == 2 && size == 60) {
difference() {
union () {
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-2);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-6);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-10);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-14);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-18);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-22);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-26);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-30);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-34);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-38);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-42);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-46);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-50);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-54);
}
// mount holes
translate ([size-5,size-5,-1]) cylinder(h=thick+2, d=3);
translate ([size-5,5,-1]) cylinder(h=thick+2, d=3);
translate ([5,size-5,-1]) cylinder(h=thick+2, d=3);
translate ([5,5,-1]) cylinder(h=thick+2, d=3);
}
translate([9.5,8,-2]) rotate([0,0,45]) cube([size,2,thick+4]);
translate([8.5,size-10,-2]) rotate([0,0,-45]) cube([size,2,thick+4]);
}
}
if(style == 2 && size >= 80) {
difference() {
union () {
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-2);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-8);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-14);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-20);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-26);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-32);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-38);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-44);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-50);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-56);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-62);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-68);
}
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-74);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-79);
}
if(size == 92) {
if(style == 1 && size == 30) {
union() {
difference() {
union () {
difference() {
translate ([size/2,size/2,-1]) cylinder(h=thick+2, d=size-86);
translate ([size/2,size/2,-2]) cylinder(h=thick+4, d=size-92);
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-2);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-8);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-11);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-17);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-20);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-25);
}
// mount holes
translate([size-hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([size-hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
}
// mount holes
translate ([size-3.75,size-3.75,-1]) cylinder(h=thick+2, d=3);
translate ([size-3.75,3.75,-1]) cylinder(h=thick+2, d=3);
translate ([3.75,size-3.75,-1]) cylinder(h=thick+2, d=3);
translate ([3.75,3.75,-1]) cylinder(h=thick+2, d=3);
translate([5, 4, -2]) rotate([0, 0, 45]) cube([size, 1.5, thick+4]);
translate([4, size-5, -2]) rotate([0, 0, -45]) cube([size, 1.5, thick+4]);
}
translate([6.5,4.25,-2]) rotate([0,0,45]) cube([size*1.2,3,thick+4]);
translate([4.25,size-6.5,-2]) rotate([0,0,-45]) cube([size*1.2,3,thick+4]);
}
}
}
if(style == 3) {
if(style == 1 && size == 40) {
union() {
difference() {
union () {
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-2);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-8);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-11);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-17);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-20);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-25);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-28);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-35);
}
// mount holes
translate([size-hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([size-hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
}
translate([6.5, 5.5, -2]) rotate([0, 0, 45]) cube([size, 1.5, thick+4]);
translate([5, size-6, -2]) rotate([0, 0, -45]) cube([size, 1.5, thick+4]);
}
}
}
if(style == 1 && (size == 50 || size == 60 || size == 70)) {
union() {
difference() {
union () {
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-2);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-14);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-18);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-30);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-34);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-46);
}
if(size > 50) {
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-50);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-59);
}
}
// mount holes
translate([size-hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([size-hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
}
translate([8.5, 7, -2]) rotate([0, 0, 45]) cube([size > 60 ? size+4 : size+1, 2, thick+4]);
translate([6.5, size-8, -2]) rotate([0, 0, -45]) cube([size > 60 ? size+4 : size+1, 2, thick+4]);
}
}
}
if(style == 1 && size >= 80) {
union() {
difference() {
union () {
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-2);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-9);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-14);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-21);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-26);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-33);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-38);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-45);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-50);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-57);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-62);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-68);
}
if(size == 92) {
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-74);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-80);
}
difference() {
translate([size/2, size/2, -1]) cylinder(h=thick+2, d=size-85);
translate([size/2, size/2, -2]) cylinder(h=thick+4, d=size-91);
}
}
// mount holes
translate([size-hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([size-hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
}
translate([6.5, 4.25, -2]) rotate([0, 0, 45]) cube([size*1.2, 3, thick+4]);
translate([4.25, size-6.5, -2]) rotate([0, 0, -45]) cube([size*1.2, 3, thick+4]);
}
}
}
if(style == 2) {
inner = size == 30 ? 24 :
size == 40 ? 32 :
size == 50 ? 40 :
@@ -171,7 +221,7 @@ module fan_mask(size, thick, style) {
size == 70 ? 61.9 :
size == 80 ? 71.5 :
size * 0.8; // Use 80% as default
rings = size <= 40 ? 4 : 6;
bar_size = size <= 40 ? 2 : 3;
@@ -196,13 +246,40 @@ module fan_mask(size, thick, style) {
}
}
}
translate([0, 0, -1]) union() {
cylinder(d=bar_size*2+0.1, thick+6); // Add a circle to prevent any tiny holes around cross bar
rotate([0, 0, 45]) cube([size, bar_size, 12], center=true);
rotate([0, 0, 45]) cube([bar_size, size, 12], center=true);
}
translate([0, 0, 2])
union() {
cylinder(d=bar_size*2+0.1, thick+2); // Add a circle to prevent any tiny holes around cross bar
rotate([0, 0, 45]) cube([size, bar_size, thick+2], center=true);
rotate([0, 0, 45]) cube([bar_size, size, thick+2], center=true);
}
}
}
}
if(style == 3) {
hex_pos = size == 30 ? [-11.75, -4.5, 0] :
size == 40 ? [-14, -11.25, 0] :
size == 50 ? [-16, -6.5, 0] :
size == 60 ? [-11, -1.5, 0] :
size == 70 ? [-13, -3.5, 0] :
size >= 80 ? [-8.25, -3.5, 0] : [-9, -4, 0];
union() {
difference () {
translate([1+(size-2)/2, 1+(size-2)/2, -1]) cylinder(h=thick+2, d=size-2);
union() {
difference() {
translate([1+(size-2)/2, 1+(size-2)/2, -1-adj]) cylinder(h=thick+3, d=size-2);
translate(hex_pos) vent_hex(15, 8, thick+4, 12, 2, "horizontal");
}
}
}
}
// mount holes
translate([size-hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([size-hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, size-hole_pos, -1]) cylinder(h=thick+2, d=3);
translate([hole_pos, hole_pos, -1]) cylinder(h=thick+2, d=3);
}
}