/* * CYD + DHT11 外壳(与 generate_stl.py 一致) * * - DHT11:后盖外侧卡位仓,传感器微突出 * - 前后盖:公/母止口合盖 * * part = "front" | "back" | "assembly" */ part = "assembly"; // ["front","back","assembly"] pcb_l = 86; pcb_w = 50; wall = 2.4; gap = 0.35; bezel_t = 2.2; cavity = 7.5; lip_h = 2.4; lip_t = 1.15; disp_h = 4; skirt_h = disp_h + 1; view_l = 59.5; view_w = 45; view_ix = 7; view_iy = 2.5; disp_x = 8; mh_inset = 4; screw = 3.3; boss_od = 7; boss_id = 2.5; usb_w = 15; usb_h = 9; usb_y = 30.5; stand_foot = 16; dht_l = 16; dht_w = 12.5; dht_h = 8; dht_proud = 1.8; dht_clip = 1.1; inner_l = pcb_l + 2*gap; inner_w = pcb_w + 2*gap; outer_l = inner_l + 2*wall; outer_w = inner_w + 2*wall; shell_h = cavity + wall; $fn = 40; mh = [[mh_inset,mh_inset],[pcb_l-mh_inset,mh_inset], [pcb_l-mh_inset,pcb_w-mh_inset],[mh_inset,pcb_w-mh_inset]]; module rr(l,w,h,r) { hull() for (x=[r,l-r], y=[r,w-r]) translate([x,y,0]) cylinder(h=h,r=r); } module front() { z1 = bezel_t + skirt_h; difference() { union() { rr(outer_l, outer_w, z1, 3); // male lip translate([wall-lip_t, wall-lip_t, z1-0.05]) difference() { rr(outer_l-2*(wall-lip_t), outer_w-2*(wall-lip_t), lip_h, 2.2); translate([lip_t+0.15, lip_t+0.15, -0.1]) rr(outer_l-2*wall-0.3, outer_w-2*wall-0.3, lip_h+0.5, 1.4); } } translate([wall,wall,bezel_t]) rr(inner_l, inner_w, z1, 1.8); // view vx = wall+gap+disp_x+view_ix; vy = wall+gap+view_iy; translate([vx-0.25, vy-0.25, -0.1]) cube([view_l+0.5, view_w+0.5, bezel_t+1]); // screen pocket translate([wall+gap+disp_x-0.25, wall+gap-0.15, bezel_t-0.05]) cube([69.5, 50.3, disp_h+0.8]); for (p=mh) translate([wall+gap+p[0], wall+gap+p[1], -0.1]) cylinder(d=screw+0.2, h=z1+lip_h+1); } } module dht_bay() { cx = wall+gap+62; cy = wall+gap+pcb_w/2; bay_l = dht_l+3.2; bay_w = dht_w+3.2; bay_h = dht_h + wall*0.6 + dht_proud; difference() { translate([cx-bay_l/2, cy-bay_w/2, -bay_h+wall*0.35]) cube([bay_l, bay_w, bay_h+0.2]); // cavity translate([cx-dht_l/2-0.25, cy-dht_w/2-0.25, -bay_h+wall*0.35+1]) cube([dht_l+0.5, dht_w+0.5, bay_h]); // grill translate([cx-dht_l/2+1.2, cy-dht_w/2+1.2, -bay_h-0.2]) cube([dht_l-2.4, dht_w-2.4, wall+dht_proud+0.8]); // wire hole into case translate([cx-3.5, cy-4, wall-0.5]) cube([7, 8, 3]); } // 卡位 left/right z0 = -bay_h+wall*0.35+1.2; translate([cx-dht_l/2-1.2, cy-3.5, z0]) cube([1.2+dht_clip, 7, 3.2]); translate([cx+dht_l/2-dht_clip, cy-3.5, z0]) cube([1.2+dht_clip, 7, 3.2]); // stop ledge translate([cx-dht_l/2+1.5, cy-dht_w/2+0.8, -bay_h+wall*0.35+0.8]) cube([dht_l-3, dht_w-1.6, 1]); } module back() { difference() { union() { rr(outer_l, outer_w, shell_h, 3); // collar + female slot difference() { translate([0,0,shell_h-0.05]) rr(outer_l, outer_w, lip_h, 3); translate([wall+0.2, wall+0.2, shell_h-0.2]) rr(outer_l-2*wall-0.4, outer_w-2*wall-0.4, lip_h+0.5, 1.6); } for (p=mh) translate([wall+gap+p[0], wall+gap+p[1], wall]) difference() { cylinder(d=boss_od, h=cavity-0.4); translate([0,0,1]) cylinder(d=boss_id, h=cavity); } // stand translate([(outer_l-outer_l*0.7)/2, -stand_foot+0.4, 0]) difference() { cube([outer_l*0.7, stand_foot, shell_h*0.85]); translate([2,2,wall]) cube([outer_l*0.7-4, stand_foot-2, shell_h]); } dht_bay(); } translate([wall,wall,wall]) rr(inner_l, inner_w, shell_h+lip_h, 1.8); // female ring cut translate([wall-lip_t-0.12, wall-lip_t-0.12, shell_h+0.15]) difference() { cube([outer_l-2*(wall-lip_t-0.12), outer_w-2*(wall-lip_t-0.12), lip_h-0.3]); translate([lip_t+0.15, lip_t+0.15, -0.1]) cube([outer_l-2*wall-0.1, outer_w-2*wall-0.1, lip_h]); } // USB translate([-0.1, wall+gap+usb_y-usb_w/2, wall+1.2]) cube([wall+1.2, usb_w, usb_h]); } } if (part=="front") front(); else if (part=="back") back(); else { color("teal", 0.85) back(); translate([0,0,shell_h-2.2]) color("slategray", 0.75) translate([0, outer_w, bezel_t+skirt_h+lip_h]) rotate([180,0,0]) front(); }