more code cleanup and fixes

This commit is contained in:
Edward Kisiel
2022-07-07 20:34:09 -04:00
parent 260752a32d
commit 086ff0766c
3 changed files with 31 additions and 31 deletions

View File

@@ -6,7 +6,7 @@
function poly_sides_r(r) = (max(round(4 * r),3)+1); function poly_sides_r(r) = (max(round(4 * r),3)+1);
// 2d primitive for outside fillets. // 2d primitive for outside fillets.
module fillet_2d_o(fillet_r, fillet_angle=90, fillet_fn=90) { module fillet_2d_o(fillet_r, fillet_angle=90, fillet_fn=0) {
add=0.01; add=0.01;
f_fn=(fillet_fn>0) ? fillet_fn*4 : (ceil(poly_sides_r(fillet_r)/4)*4); f_fn=(fillet_fn>0) ? fillet_fn*4 : (ceil(poly_sides_r(fillet_r)/4)*4);
if (fillet_r>0) { if (fillet_r>0) {
@@ -23,7 +23,7 @@ module fillet_2d_o(fillet_r, fillet_angle=90, fillet_fn=90) {
} }
// 2d primitive for inside fillets. // 2d primitive for inside fillets.
module fillet_2d_i(fillet_r, fillet_angle=90, fillet_fn=90) { module fillet_2d_i(fillet_r, fillet_angle=90, fillet_fn=0) {
add=0.01; add=0.01;
f_fn=(fillet_fn>0) ? fillet_fn*4 : (ceil(poly_sides_r(fillet_r)/4)*4); f_fn=(fillet_fn>0) ? fillet_fn*4 : (ceil(poly_sides_r(fillet_r)/4)*4);
if (fillet_r>0) { if (fillet_r>0) {
@@ -41,7 +41,7 @@ module fillet_2d_i(fillet_r, fillet_angle=90, fillet_fn=90) {
} }
// 3d rotated outside fillet. // 3d rotated outside fillet.
module fillet_polar_o(inner_r, fillet_r, fillet_angle=90, fillet_fn=90, rotate_fn=0) { module fillet_polar_o(inner_r, fillet_r, fillet_angle=90, fillet_fn=0, rotate_fn=0) {
if (fillet_r>0) { if (fillet_r>0) {
rotate_extrude(convexity=8, $fn=rotate_fn) { rotate_extrude(convexity=8, $fn=rotate_fn) {
translate([inner_r, 0, 0]) { translate([inner_r, 0, 0]) {
@@ -52,7 +52,7 @@ module fillet_polar_o(inner_r, fillet_r, fillet_angle=90, fillet_fn=90, rotate_f
} }
// 3d rotated inside fillet. // 3d rotated inside fillet.
module fillet_polar_i(inner_r, fillet_r, fillet_angle=90, fillet_fn=90, rotate_fn=0) { module fillet_polar_i(inner_r, fillet_r, fillet_angle=90, fillet_fn=0, rotate_fn=0) {
if (fillet_r>0) { if (fillet_r>0) {
rotate_extrude(convexity=8, $fn=rotate_fn) { rotate_extrude(convexity=8, $fn=rotate_fn) {
translate([inner_r, 0, 0]) { translate([inner_r, 0, 0]) {
@@ -62,7 +62,7 @@ module fillet_polar_i(inner_r, fillet_r, fillet_angle=90, fillet_fn=90, rotate_f
} }
// 3d rotated inside fillet negative. // 3d rotated inside fillet negative.
module fillet_polar_i_n(outer_r, fillet_r, fillet_angle=90, fillet_fn=90, rotate_fn=0) { module fillet_polar_i_n(outer_r, fillet_r, fillet_angle=90, fillet_fn=0, rotate_fn=0) {
if (fillet_r>0) { if (fillet_r>0) {
rotate_extrude(convexity=8, $fn=rotate_fn) { rotate_extrude(convexity=8, $fn=rotate_fn) {
translate([outer_r, 0, 0]) { translate([outer_r, 0, 0]) {
@@ -72,7 +72,7 @@ module fillet_polar_i_n(outer_r, fillet_r, fillet_angle=90, fillet_fn=90, rotate
} }
// 3d linear outside fillet. // 3d linear outside fillet.
module fillet_linear_o(l, fillet_r, fillet_angle=90, fillet_fn=90, add=0.02) { module fillet_linear_o(l, fillet_r, fillet_angle=90, fillet_fn=0, add=0.02) {
if (fillet_r>0) { if (fillet_r>0) {
translate([0,0,-add/2]) translate([0,0,-add/2])
linear_extrude(height=l+add, center=false) { linear_extrude(height=l+add, center=false) {
@@ -82,7 +82,7 @@ translate([0,0,-add/2])
} }
// 3d linear inside fillet. // 3d linear inside fillet.
module fillet_linear_i(l, fillet_r, fillet_angle=90, fillet_fn=90, add=0.02) { module fillet_linear_i(l, fillet_r, fillet_angle=90, fillet_fn=0, add=0.02) {
if (fillet_r>0) { if (fillet_r>0) {
translate([0,0,-add/2]) translate([0,0,-add/2])
linear_extrude(height=l+add, center=false) { linear_extrude(height=l+add, center=false) {
@@ -173,7 +173,7 @@ module cube_fillet_inside(size, radius=-1, vertical=[0,0,0,0], top=[0,0,0,0], bo
} }
} }
module cylinder_fillet_inside(h=10, r=10, top=3, bottom=3, $fn=0, fillet_fn=90, center=false) { module cylinder_fillet_inside(h=10, r=10, top=3, bottom=3, $fn=0, fillet_fn=0, center=false) {
c_fn=($fn>0) ? $fn : poly_sides_r(r); c_fn=($fn>0) ? $fn : poly_sides_r(r);
rotfix=(($fn>0) ? 0 : 180/c_fn); rotfix=(($fn>0) ? 0 : 180/c_fn);
cent=(center) ? -h/2 : 0; cent=(center) ? -h/2 : 0;
@@ -191,7 +191,7 @@ module cylinder_fillet_inside(h=10, r=10, top=3, bottom=3, $fn=0, fillet_fn=90,
} }
} }
module cylinder_fillet_outside(h=10, r=10, top=3, bottom=3, $fn=0, fillet_fn=90, center=false) { module cylinder_fillet_outside(h=10, r=10, top=3, bottom=3, $fn=0, fillet_fn=0, center=false) {
c_fn=($fn>0) ? $fn : poly_sides_r(r); c_fn=($fn>0) ? $fn : poly_sides_r(r);
rotfix=(($fn>0) ? 0 : 180/c_fn); rotfix=(($fn>0) ? 0 : 180/c_fn);
cent=(center) ? -h/2 : 0; cent=(center) ? -h/2 : 0;

View File

@@ -296,7 +296,7 @@ case_data = [
["c1+_round","c1+","round","none", // case_name,sbc_model,case_design,case_style ["c1+_round","c1+","round","none", // case_name,sbc_model,case_design,case_style
0,0,0,0,0,4,2, // pcb_loc_x,pcb_loc_y,pcb_loc_z,case_offset_x,case_offset_y,case_offset_tz,case_offset_bz, 0,0,0,0,0,4,2, // pcb_loc_x,pcb_loc_y,pcb_loc_z,case_offset_x,case_offset_y,case_offset_tz,case_offset_bz,
3,2,3,1.5,[2,2], // wallthick,floorthick,sidethick,gap,fillet 3,2,3,1.5,[0,0], // wallthick,floorthick,sidethick,gap,fillet
false,false,false,true,false, // indents,sidewall_support,sbc_top_standoffs,sbc_bottom_standoffs,case_ext_standoffs false,false,false,true,false, // indents,sidewall_support,sbc_top_standoffs,sbc_bottom_standoffs,case_ext_standoffs
false,"none","fan","none","true", // sata_punchout,gpio_opening,cooling,exhaust_vents,mode false,"none","fan","none","true", // sata_punchout,gpio_opening,cooling,exhaust_vents,mode
[6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_pcb_standoff [6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_pcb_standoff
@@ -534,7 +534,7 @@ case_data = [
["c2_round","c2","round","none", // case_name,sbc_model,case_design,case_style ["c2_round","c2","round","none", // case_name,sbc_model,case_design,case_style
0,0,0,0,0,4,2, // pcb_loc_x,pcb_loc_y,pcb_loc_z,case_offset_x,case_offset_y,case_offset_tz,case_offset_bz, 0,0,0,0,0,4,2, // pcb_loc_x,pcb_loc_y,pcb_loc_z,case_offset_x,case_offset_y,case_offset_tz,case_offset_bz,
3,2,3,1.5,[2,2], // wallthick,floorthick,sidethick,gap,fillet 3,2,3,1.5,[0,0], // wallthick,floorthick,sidethick,gap,fillet
false,false,false,true,false, // indents,sidewall_support,sbc_top_standoffs,sbc_bottom_standoffs,case_ext_standoffs false,false,false,true,false, // indents,sidewall_support,sbc_top_standoffs,sbc_bottom_standoffs,case_ext_standoffs
false,"none","fan","none","true", // sata_punchout,gpio_opening,cooling,exhaust_vents,mode false,"none","fan","none","true", // sata_punchout,gpio_opening,cooling,exhaust_vents,mode
[6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_pcb_standoff [6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_pcb_standoff
@@ -781,16 +781,16 @@ case_data = [
[6.75,5,3.6,10,4,1,0,0,0,4.5,5.1]], // bottom_ext_standoff [6.75,5,3.6,10,4,1,0,0,0,4.5,5.1]], // bottom_ext_standoff
["c4_round","c4","round","none", // case_name,sbc_model,case_design,case_style ["c4_round","c4","round","none", // case_name,sbc_model,case_design,case_style
0,0,0,0,0,4,2, // pcb_loc_x,pcb_loc_y,pcb_loc_z,case_offset_x,case_offset_y,case_offset_tz,case_offset_bz, 0,0,0,0,0,0,0, // pcb_loc_x,pcb_loc_y,pcb_loc_z,case_offset_x,case_offset_y,case_offset_tz,case_offset_bz,
3,2,3,1.5,[2,2], // wallthick,floorthick,sidethick,gap,fillet 3,2,3,1.5,[0,0], // wallthick,floorthick,sidethick,gap,fillet
false,false,false,true,false, // indents,sidewall_support,sbc_top_standoffs,sbc_bottom_standoffs,case_ext_standoffs false,false,false,true,false, // indents,sidewall_support,sbc_top_standoffs,sbc_bottom_standoffs,case_ext_standoffs
false,"none","vents","none","true", // sata_punchout,gpio_opening,cooling,exhaust_vents,mode false,"none","fan","none","true", // sata_punchout,gpio_opening,cooling,exhaust_vents,mode
[6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_pcb_standoff [6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_pcb_standoff
[6.75,5,3.6,10,4,1,0,0,0,4.5,5.1], // bottom_pcb_standoff [6.75,5,3.6,10,4,1,0,0,0,4.5,5.1], // bottom_pcb_standoff
[6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_ext_standoff [6.75,18,2.5,10,4,4,0,1,0,4.5,5.1], // top_ext_standoff
[6.75,5,3.6,10,4,1,0,0,0,4.5,5.1], // bottom_ext_standoff [6.75,5,3.6,10,4,1,0,0,0,4.5,5.1], // bottom_ext_standoff
"suball","round",10.5,-2,14.5,"top",[90,0,0],11,0,18,0,0,"",0, // sub power plug hole "suball","round",10.5,-2,14.5,"top",[90,0,0],11,0,18,0,0,"",0, // sub power plug hole
"suball","rectangle",34.5,-26,4.99,"top",[0,0,0],21,10,14.5,0,0,"vertical",[1,1,1,1]], // sub hdmi opening "suball","rectangle",34.5,-26,3.99,"top",[0,0,0],21,10,15.5,0,0,"vertical",[1,1,1,1]], // sub hdmi opening
// Odroid-XU4 // Odroid-XU4

View File

@@ -48,14 +48,14 @@ case_name = "c4_round"; // case_name to load from s
view = "model"; // viewing mode "platter", "model", "debug" view = "model"; // viewing mode "platter", "model", "debug"
highlight = false; // enable highlight for subtarctive geometry (true or false) highlight = false; // enable highlight for subtarctive geometry (true or false)
sbc_off = false; // sbc off in model view (true or false) sbc_off = true; // sbc off in model view (true or false)
raise_top = 0; // raises top mm in model view or < 0 = off raise_top = 0; // raises top mm in model view or < 0 = off
lower_bottom = 0; // lowers bottom mm in model view or < 0 = off lower_bottom = 0; // lowers bottom mm in model view or < 0 = off
move_leftside = 0; // move left side mm in model view or < 0 = off move_leftside = 0; // move left side mm in model view or < 0 = off
move_rightside = 0; // move right side mm in model view or < 0 = off move_rightside = 0; // move right side mm in model view or < 0 = off
move_front = 0; // move front mm in model view or < 0 = off move_front = 0; // move front mm in model view or < 0 = off
move_rear = 0; // move rear mm in model view or < 0 = off move_rear = 0; // move rear mm in model view or < 0 = off
case_fn = 90; // circle segments for round cases case_fn = 360; // circle segments for round cases
case_ffn = 90; // circle segments for fillet of round cases case_ffn = 90; // circle segments for fillet of round cases
c = search([case_name],case_data); c = search([case_name],case_data);
@@ -484,24 +484,24 @@ module case_bottom(case_design) {
translate([pcb_width/2,pcb_depth/2,bottom_height/2]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,bottom_height/2]) rotate([0,0,30])
cylinder_fillet_inside(h=bottom_height, r=case_diameter/2, cylinder_fillet_inside(h=bottom_height, r=case_diameter/2,
top=0, bottom=c_fillet, $fn=case_fn, fillet_fn=case_ffn, center=true); top=0, bottom=c_fillet, $fn=case_fn, fillet_fn=case_ffn, center=true);
translate([pcb_width/2,pcb_depth/2,(bottom_height/2)+1+floorthick]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,(bottom_height/2)+floorthick]) rotate([0,0,30])
cylinder_fillet_inside(h=bottom_height+adjust+floorthick, cylinder_fillet_inside(h=bottom_height+adjust+floorthick,
r=(case_diameter/2)-lip/2,top=0, bottom=c_fillet-1, $fn=case_fn, r=(case_diameter/2)-lip/2,top=0, bottom=c_fillet-1, $fn=case_fn,
fillet_fn=case_ffn, center=true); fillet_fn=case_ffn, center=true);
difference() { difference() {
translate([pcb_width/2,pcb_depth/2,(bottom_height-lip)]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,(bottom_height/2)-floorthick/2]) rotate([0,0,30])
cylinder(h=lip+adjust, r=(case_diameter/2)+1, $fn=case_fn); cylinder(h=lip+adjust, r=(case_diameter/2)+1, $fn=case_fn);
translate([pcb_width/2,pcb_depth/2,(bottom_height-lip)-adjust]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,(bottom_height/2)-adjust-floorthick/2]) rotate([0,0,30])
cylinder(h=lip+2*adjust, r=(case_diameter/2)-lip/4, $fn=case_fn); cylinder(h=lip+2*adjust, r=(case_diameter/2)-lip/4, $fn=case_fn);
} }
} }
difference() { difference() {
translate([pcb_width/2,pcb_depth/2,(bottom_height/2)+1+floorthick]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,(bottom_height/2)+2*floorthick]) rotate([0,0,30])
cylinder_fillet_inside(h=bottom_height+adjust+floorthick, cylinder_fillet_inside(h=bottom_height+adjust+floorthick+lip,
r=(case_diameter/2)-lip/2,top=0, bottom=c_fillet-1, $fn=case_fn, r=(case_diameter/2)-lip/2,top=0, bottom=c_fillet-1, $fn=case_fn,
fillet_fn=case_ffn, center=true); fillet_fn=case_ffn, center=true);
translate([-16,(depth/2)-60,-adjust]) translate([-16,(depth/2)-60,-adjust])
cube([width+10,110,top_height-2*floorthick-2]); cube([width+10,110,bottom_height+top_height-2*floorthick-2]);
translate([width-9,(depth/2)-62.5,bottom_height]) translate([width-9,(depth/2)-62.5,bottom_height])
cube([20,110,top_height-2*floorthick-2]); cube([20,110,top_height-2*floorthick-2]);
} }
@@ -952,23 +952,23 @@ module case_top(case_design) {
} }
if(case_design == "round") { if(case_design == "round") {
difference() { difference() {
translate([pcb_width/2,pcb_depth/2,case_z/2]) rotate([0,0,30]) #translate([pcb_width/2,pcb_depth/2,top_height]) rotate([0,0,30])
cylinder_fillet_inside(h=top_height, r=case_diameter/2, cylinder_fillet_inside(h=top_height+lip, r=case_diameter/2,
top=fillet, bottom=0, $fn=case_fn, fillet_fn=case_ffn, center=true); top=fillet, bottom=0, $fn=case_fn, fillet_fn=case_ffn, center=true);
translate([pcb_width/2,pcb_depth/2,(case_z/2)-floorthick]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,top_height-floorthick]) rotate([0,0,30])
cylinder_fillet_inside(h=top_height, r=(case_diameter/2)-lip/2, cylinder_fillet_inside(h=top_height, r=(case_diameter/2)-lip/2,
top=fillet-1, bottom=0, $fn=case_fn, fillet_fn=case_ffn, center=true); top=fillet-1, bottom=0, $fn=case_fn, fillet_fn=case_ffn, center=true);
translate([pcb_width/2,pcb_depth/2,lip-adjust]) rotate([0,0,30]) translate([pcb_width/2,pcb_depth/2,lip-1-adjust]) rotate([0,0,30])
cylinder(h=lip+2*adjust, r=(case_diameter/2)-(lip/4)+tol/2, $fn=case_fn); cylinder(h=lip+2*adjust, r=(case_diameter/2)-(lip/4)+tol/2, $fn=case_fn);
// io cutout // io cutout
translate([width,(depth/2)-wallthick-gap,floorthick+gap+top_height/2]) translate([width,(depth/2)-wallthick-gap,bottom_height+top_height/2-floorthick+1-lip/2])
cube_fillet_inside([18,depth-2*(wallthick+gap)-1,top_height-1], cube_fillet_inside([18,depth-2*(wallthick+gap)-1,top_height+lip],
vertical=[0,0,0,0], vertical=[0,0,0,0],
top=[0,0,0,0], top=[0,0,0,0],
bottom=[0,0,0,0], $fn=90); bottom=[0,0,0,0], $fn=90);
} }
translate([width-8.49,(depth/2)-32,bottom_height]) translate([width-8.49,(depth/2)-32.5,bottom_height])
cube([wallthick-.75,55,top_height-2*floorthick-3]); cube([wallthick-.5,56,top_height-1]);
} }
for (i=[30:14:len(case_data[c[0]])-1]) { for (i=[30:14:len(case_data[c[0]])-1]) {
class = case_data[c[0]][i]; class = case_data[c[0]][i];