// ============================================================ // XIAO ePaper Display Board EE04 — 3D-Printed Case // OpenSCAD parametric model // ============================================================ use /* [Preview] */ SHOW_BOARD = true; SHOW_LID = true; SHOW_BASE = true; SHOW_PLUNGERS = true; SHOW_BATTERY = true; EXPLODE = 65; // mm to pull lid out in Y- for inspection (try 40) /* [Board Dimensions — from EE04 STL] */ PCB_L = 80.00; // board length (case_x axis) PCB_W = 41.22; // board width (case_y axis) PCB_T = 1.93; // PCB thickness // Component heights measured from PCB bottom face: COMP_MAX_Z = 7.29; // tallest component (XIAO module) COMP_SIDE_Z = 3.82; // tallest component on +Y wall (buttons, USB-C) /* [Sliding Lid] */ LID_T = 1.5; // lid ceiling thickness FLANGE_H = 3.0; // Z height of retention flanges (base + lid); drives lid placement and Y- wall step FLANGE_W = FLANGE_H * tan(30); // flange width — 30° from vertical (60° from horizontal), printable without support SLIDE_CLEAR = 0.40; // clearance between flange/rib and groove/channel on all mating faces (0.4 mm suits typical FDM tolerances) // ---- Y- edge: FPC connector — notch in lid Y+ stop rib ---- // FPC_NOTCH_W and FPC_SLOT_W match the Z- face opening of epd_case: // _fpc_xw = 12.5 + 5.0 = 17.5 mm (cable + 2.5 mm clearance per side) // slot Y-extent at z=0: sqrt(_fpc_ro² − (FPC_BEND_R−WALL)²) ≈ 4.1 mm // with epd_case defaults: bend_r=4, wall=2, fpc_t=0.3, tol=0.3 → _fpc_ro=4.6 FPC_CX = 50.0; // PCB-relative case_x centre FPC_NOTCH_W = 17.5; // = _fpc_xw in epd_case (cable 12.5 + 2×2.5 mm clearance) FPC_U_T = LID_T; // U-rib arm and bar thickness FPC_U_DEPTH = 20.0; // how far Y- the U arms extend into the lid interior FPC_SLOT_W = 4.1; // ≈ sqrt(_fpc_ro²−(FPC_BEND_R−WALL)²) at epd_case z=0 /* [Cutout Positions — from STL geometry, PCB-origin-relative] */ // ---- +Y wall: Sliding power switch ---- // TODO: measure actual switch body dimensions from STL (as done for USB-C) before next print PWR_CX = 10.3; // PCB-relative case_x centre PWR_W = 5.0; // slot width PWR_H = 2.5; // slot height PWR_CZ = 3.8; // height above PCB bottom PWR_COVER_T = 0.6; // exterior skin over switch pocket (switch not user-accessible) // ---- +Y wall: USB-C port ---- USBC_CX = 65.65; USBC_W = 9.0; // port body width from STL USBC_H = 3.22; // port body height from STL USBC_CZ = 4.31; USBC_CBL_CLEAR = 1.5; // added per side for cable plug + routing clearance // ---- +Y wall: 3× user buttons + 1× reset ---- BTN_CX = [48.4, 39.075, 29.725, 20.425]; // PCB-relative case_x centres BTN_D = 2.3; // HOLE_D from hat.scad: PLUNGER_D(2.0) + 2×SLIP_CLEAR(0.15) BTN_CZ = 3.85; /* [Plunger] */ PLUNGER_D = 2.0; // body and head diameter — matches button actuator FLANGE_D = 2.9; // retention flange OD FLANGE_T = 1.2; // flange thickness (axial) PLUNGER_HEAD_H = 1.5; // exterior head protrusion past wall face /* [Case Parameters] */ WALL = 2.0; // wall thickness FLOOR = 2.0; // base floor thickness (thicker for thread engagement) CORNER_R = 2.5; // XY corner fillet radius SCREW_D = 3.2; // M3 tap drill diameter BOSS_D = 6.0; // PCB standoff boss outer diameter BOSS_H = 2.0; // standoff boss height; PCB bottom sits flush on boss top /* [Locating Studs] */ STUD_CLEAR = 0.10; // radial clearance per side — close (non-interference) fit in SLA resin STUD_H = PCB_T + 1.0; // stud cylinder height above boss top: through PCB + 1 mm proud STUD_R = (SCREW_D - 2*STUD_CLEAR) / 2; // stud pin radius (= cylinder + dome radius) /* [PCB Standoff Positions — relative to PCB origin] */ PCB_BOSS_X1 = 2.5; PCB_BOSS_X2 = PCB_L - 2.5; PCB_BOSS_Y1 = 2.5; PCB_BOSS_Y2 = PCB_W - 2.5; /* [Interior Clearances — PCB edge to interior wall face] */ CLR_XN = 2.0; // X- side CLR_XP = 42.0; // X+ side (JST cable routing) CLR_YN = 15.0; // Y- side (FPC routing; lid inserts from here) CLR_YP = 1.77; // Y+ side: calibrated contact(1.565) + rest clearance(0.20) CLR_LID = 5.0; // from tallest component top to lid underside BATT_W = 34.5; // 603449 LiPo width (X) BATT_D = 51.0; // 603449 LiPo depth (Y) BATT_T = 6.3; // 603449 LiPo thickness (Z) CLR_BATX = 1.5; // battery X clearance from X+ wall CLR_BATY = 1.5; // battery Y clearance from Y+ wall /* [Computed] */ PCB_Z = FLOOR + BOSS_H; // Base inner height: floor to lid underside ≈ BASE_H (flange rests on groove floor) BASE_INNER_H = BOSS_H + COMP_MAX_Z + CLR_LID; BASE_H = FLOOR + BASE_INNER_H; PCB_OX = WALL + CLR_XN; PCB_OY = WALL + CLR_YN; CAV_L = CLR_XN + PCB_L + CLR_XP; CAV_W = CLR_YN + PCB_W + CLR_YP; OUT_L = CAV_L + 2*WALL; OUT_W = CAV_W + 2*WALL; LID_H = FLANGE_H + LID_T; LID_Y_LEN = CAV_W; // flange length; lid Y+ end stops against Y+ interior wall // ============================================================ // HELPERS // ============================================================ module rounded_box(l, w, h, r) { hull() for (dx = [r, l-r], dy = [r, w-r]) translate([dx, dy, 0]) cylinder(r=r, h=h, $fn=32); } // Standoff boss: screw variant has through-hole; stud variant has locating pin instead. // Diagonal (X1,Y1)+(X2,Y2) → studs; (X1,Y2)+(X2,Y1) → screws. module pcb_boss(px, py, stud=false) { translate([PCB_OX + px, PCB_OY + py, FLOOR]) { difference() { cylinder(d=BOSS_D, h=BOSS_H + 0.01, $fn=24); if (!stud) translate([0, 0, -0.1]) cylinder(d=SCREW_D * 0.7, h=BOSS_H + 0.2, $fn=18); } if (stud) translate([0, 0, BOSS_H]) { cylinder(r=STUD_R, h=STUD_H, $fn=24); translate([0, 0, STUD_H]) sphere(r=STUD_R, $fn=24); } } } // Button plunger — origin at hole centre on the interior wall face. // At rest: flange flush with interior face, head proud of exterior face. module plunger() { color("orange") union() { translate([0, -FLANGE_T, 0]) rotate([-90, 0, 0]) cylinder(d = PLUNGER_D, h = FLANGE_T + WALL + PLUNGER_HEAD_H, $fn = 32); translate([0, -FLANGE_T, 0]) rotate([-90, 0, 0]) cylinder(d = FLANGE_D, h = FLANGE_T, $fn = 32); translate([0, WALL, 0]) rotate([-90, 0, 0]) cylinder(d = PLUNGER_D, h = PLUNGER_HEAD_H, $fn = 32); } } // ============================================================ // BASE // ============================================================ module base() { color("#004B49") { difference() { rounded_box(OUT_L, OUT_W, BASE_H, CORNER_R); // Interior cavity (open top) translate([WALL, WALL, FLOOR]) cube([CAV_L, CAV_W, BASE_H]); // ---- Boss screw holes through 50 % of floor (screw diagonal only) ---- for (pos = [[PCB_BOSS_X1, PCB_BOSS_Y2], [PCB_BOSS_X2, PCB_BOSS_Y1]]) translate([PCB_OX + pos[0], PCB_OY + pos[1], FLOOR * 0.5 - 0.1]) cylinder(d=SCREW_D * 0.7, h=FLOOR * 0.5 + 0.2, $fn=18); // ---- +Y wall cutouts ---- // Sliding power switch pocket — closed exterior face, interior clearance only translate([PCB_OX + PWR_CX - PWR_W/2, OUT_W - WALL - 0.1, PCB_Z + PWR_CZ - PWR_H/2]) cube([PWR_W, WALL - PWR_COVER_T + 0.1, PWR_H]); // USB-C slot translate([PCB_OX + USBC_CX - (USBC_W + 2*USBC_CBL_CLEAR)/2, OUT_W - WALL - 0.1, PCB_Z + USBC_CZ - (USBC_H + 2*USBC_CBL_CLEAR)/2]) cube([USBC_W + 2*USBC_CBL_CLEAR, WALL + 0.2, USBC_H + 2*USBC_CBL_CLEAR]); // 4× button holes (3 user + 1 reset) for (bcx = BTN_CX) translate([PCB_OX + bcx, OUT_W + 0.1, PCB_Z + BTN_CZ]) rotate([90, 0, 0]) cylinder(d=BTN_D, h=WALL + 0.3, $fn=32); // ---- Y- wall step for lid flange clearance ---- // Remove the full Y- wall above z=BASE_H-FLANGE_H-SLIDE_CLEAR so the lid // flanges can enter freely from Y-. translate([-0.1, -0.1, BASE_H - FLANGE_H - SLIDE_CLEAR]) cube([OUT_L + 0.2, WALL + 0.2, FLANGE_H + SLIDE_CLEAR + 0.1]); } // Standoff bosses (added outside diff so cavity doesn't subtract them) pcb_boss(PCB_BOSS_X1, PCB_BOSS_Y1, stud=true); // stud diagonal pcb_boss(PCB_BOSS_X2, PCB_BOSS_Y2, stud=true); // stud diagonal pcb_boss(PCB_BOSS_X1, PCB_BOSS_Y2, stud=false); // screw diagonal pcb_boss(PCB_BOSS_X2, PCB_BOSS_Y1, stud=false); // screw diagonal } // Lid-retention flanges — right triangles, wide face flush with case top (z=BASE_H), // tip pointing down to (WALL, BASE_H-FLANGE_H). Hypotenuse faces down-into-cavity; // lid flanges slide underneath it for Z retention. color("#2C3863") { hull() { translate([WALL, WALL, BASE_H - 0.01]) cube([FLANGE_W, CAV_W, 0.01]); translate([WALL, WALL, BASE_H - FLANGE_H]) cube([0.01, CAV_W, 0.01]); } hull() { translate([OUT_L - WALL - FLANGE_W, WALL, BASE_H - 0.01]) cube([FLANGE_W, CAV_W, 0.01]); translate([OUT_L - WALL - 0.01, WALL, BASE_H - FLANGE_H]) cube([0.01, CAV_W, 0.01]); } } } // ============================================================ // LID (slide-on; enters from Y- face, closes toward Y+) // Print upside-down (ceiling on build plate). // z=0 = bottom of flanges; z=FLANGE_H = ceiling underside. // Flanges sit inside cavity and ride on base retention flange hypotenuses. // ============================================================ module lid() { // Flanges: right triangles in XZ; hypotenuse at reciprocal angle to base retention flanges. // Wide vertical face at x=WALL+FLANGE_W (inner), tip at bottom-wall-face — same // (-FLANGE_W, -FLANGE_H) hypotenuse slope as base flanges so they mate when lid slides in. color("#2C3863") { // Left (X-) flange hull() { translate([WALL + FLANGE_W - SLIDE_CLEAR - 0.01, 0, 0]) cube([0.01, LID_Y_LEN, FLANGE_H - SLIDE_CLEAR]); translate([WALL + SLIDE_CLEAR, 0, -0.005]) cube([0.01, LID_Y_LEN, 0.01]); } // Right (X+) flange hull() { translate([OUT_L - WALL - FLANGE_W + SLIDE_CLEAR, 0, 0]) cube([0.01, LID_Y_LEN, FLANGE_H - SLIDE_CLEAR]); translate([OUT_L - WALL - SLIDE_CLEAR - 0.01, 0, -0.005]) cube([0.01, LID_Y_LEN, 0.01]); } // Interior ribs — 2 mm wide, on cavity face of each flange translate([WALL + FLANGE_W - SLIDE_CLEAR, 0, 0]) cube([2.0, LID_Y_LEN, FLANGE_H]); translate([OUT_L - WALL - FLANGE_W + SLIDE_CLEAR - 2.0, 0, 0]) cube([2.0, LID_Y_LEN, FLANGE_H]); // Y+ stop rib — split around FPC cable notch at PCB_OX+FPC_CX translate([WALL + FLANGE_W - SLIDE_CLEAR + 2.0, LID_Y_LEN - 3, FLANGE_H - 3]) cube([PCB_OX + FPC_CX - FPC_NOTCH_W/2 - (WALL + FLANGE_W - SLIDE_CLEAR + 2.0), 3, 3]); translate([PCB_OX + FPC_CX + FPC_NOTCH_W/2, LID_Y_LEN - 3, FLANGE_H - 3]) cube([OUT_L - WALL - FLANGE_W + SLIDE_CLEAR - 2.0 - (PCB_OX + FPC_CX + FPC_NOTCH_W/2), 3, 3]); // U-rib bridging the notch — arms outside gap edges, bar closing Y- end // Left arm translate([PCB_OX + FPC_CX - FPC_NOTCH_W/2 - FPC_U_T, LID_Y_LEN - 3 - FPC_U_DEPTH, FLANGE_H - 3]) cube([FPC_U_T, FPC_U_DEPTH, 3]); // Right arm translate([PCB_OX + FPC_CX + FPC_NOTCH_W/2, LID_Y_LEN - 3 - FPC_U_DEPTH, FLANGE_H - 3]) cube([FPC_U_T, FPC_U_DEPTH, 3]); // Bottom bar translate([PCB_OX + FPC_CX - FPC_NOTCH_W/2 - FPC_U_T, LID_Y_LEN - 3 - FPC_U_DEPTH, FLANGE_H - 3]) cube([FPC_NOTCH_W + 2*FPC_U_T, FPC_U_T, 3]); } color("#004B49") difference() { union() { // Ceiling plate — matches base footprint (OUT_L × OUT_W) with CORNER_R rounding translate([0, -WALL, FLANGE_H]) rounded_box(OUT_L, OUT_W, LID_T, CORNER_R); // Y- lip — same rounded_box profile clipped to the Y- wall zone so the // lip corners match the base exterior corners intersection() { translate([0, -WALL, -SLIDE_CLEAR]) rounded_box(OUT_L, OUT_W, FLANGE_H + SLIDE_CLEAR, CORNER_R); translate([-0.1, -WALL - 0.1, -SLIDE_CLEAR - 0.1]) cube([OUT_L + 0.2, WALL + 0.2, FLANGE_H + SLIDE_CLEAR + 0.2]); } } // FPC cable slot — from Y+ face of U-rib bottom bar, FPC_SLOT_W toward Y+ translate([PCB_OX + FPC_CX - FPC_NOTCH_W/2, LID_Y_LEN - 3 - FPC_U_DEPTH + FPC_U_T, FLANGE_H - 0.1]) cube([FPC_NOTCH_W, FPC_SLOT_W, LID_T + 0.2]); } } // ============================================================ // BOARD PLACEMENT // EE04() XY-normalises the STL (board left/front at origin). // +1.925 corrects for STL native Z (PCB bottom at Z=−1.925) so // the PCB bottom face lands exactly at PCB_Z. // ============================================================ module stl_board() { translate([PCB_OX, PCB_OY, PCB_Z]) EE04(); } module battery() { translate([CAV_L - BATT_W - CLR_BATX, CAV_W - BATT_D - CLR_BATY, FLOOR]) cube([BATT_W, BATT_D, BATT_T]); } // ============================================================ // ASSEMBLY // ============================================================ if (SHOW_BASE) base(); if (SHOW_BATTERY) battery(); if (SHOW_LID) translate([0, WALL - EXPLODE, BASE_H - FLANGE_H]) lid(); if (SHOW_BOARD) stl_board(); if (SHOW_PLUNGERS) for (bcx = BTN_CX) translate([PCB_OX + bcx, OUT_W - WALL, PCB_Z + BTN_CZ]) plunger();