Просмотр исходного кода

fpc_adapter: self-contained module with integrated bosses

Bosses and stud pins are now part of fpc_adapter() — callers get
the full mount geometry from a single call. PCB/connector visuals
are gated on $preview. lid.scad simplified: adapt_boss() module
removed, replaced by one color-wrapped fpc_adapter() call.
ZiB 4 месяцев назад
Родитель
Сommit
84a9b10532
2 измененных файлов с 98 добавлено и 98 удалено
  1. 87 56
      fpc_adapter.scad
  2. 11 42
      lid.scad

+ 87 - 56
fpc_adapter.scad

@@ -10,44 +10,50 @@
 //   Connector A (Y+): FPC exits in +Y direction
 //   Connector B (Y-): FPC exits in -Y direction
 //
-// fpc_len_a / fpc_len_b control how much cable to show beyond each connector.
-// Set either to 0 to show an empty (no-cable) connector.
+// Mounting bosses hang from the Z- face (z=0, downward in -Z).
+// Stud pins extend upward from z=0 through the PCB locating holes.
+// When the board is flipped for ceiling-mount (rotate([0,180,0])):
+//   bosses point toward the ceiling, stud tips snap down through the PCB.
+//
+// fpc_adapter() always produces boss geometry.
+// PCB / connector / FPC visuals are shown only in $preview.
 
 // ── PCB ────────────────────────────────────────────────────────────────
-PCB_W  = 32.0;   // board width  (X)
-PCB_H  = 18.0;   // board height (Y)
-PCB_T  = 1.6;    // board thickness (standard; measured ~1.72)
-PCB_R  = 3.0;    // corner radius     ← replace with measured value
+PCB_W  = 32.0;
+PCB_H  = 18.0;
+PCB_T  = 1.6;    // standard; measured ~1.72
+PCB_R  = 3.0;    // corner radius
 
 // ── Mounting holes ─────────────────────────────────────────────────────
-HOLE_D   = 3.0;  // hole diameter
-HOLE_MX  = 3.75;  // hole center X from nearest X edge (2.25 clearance + 1.5 radius)
-HOLE_MY  = 3.75;  // hole center Y from nearest Y edge (2.25 clearance + 1.5 radius)
+HOLE_D   = 3.0;
+HOLE_MX  = 3.75;  // hole center from nearest X edge (2.25 clearance + 1.5 radius)
+HOLE_MY  = 3.75;  // hole center from nearest Y edge
 
 // ── FPC connectors (simple box approximation) ──────────────────────────
 CON_W    = 15.5;  // connector width along X
 CON_D    = 5.85;  // connector depth along Y
-CON_H    = 2.05;  // connector height above Z+ face (total stack 3.65 - PCB_T)
-CON_T    = 0.5;   // connector wall / overhang      ← replace
-
-// X centre of both connectors (assumed centred on board)
+CON_H    = 2.05;  // connector height above Z+ face (total stack 3.65 − PCB_T)
 CON_CX   = PCB_W / 2;
-
-// Y edge positions of the connector body
-//   Connector A sits at Y+ edge; connector B sits at Y- edge.
-CON_A_Y1 = PCB_H - CON_D;   // inner face (toward board centre)
-CON_B_Y0 = 0;                // outer face (at Y=0 edge)
+CON_A_Y1 = PCB_H - CON_D;  // Connector A inner face (Y+ side)
+CON_B_Y0 = 0;               // Connector B outer face (Y- side)
 
 // ── FPC cable (simple flat box) ────────────────────────────────────────
-FPC_W  = 12.5;  // cable width along X
-FPC_T  = 0.3;   // cable thickness      ← replace with measured value
+FPC_W  = 12.5;
+FPC_T  = 0.3;
 
-// FPC stub length at each connector. 0 = no cable shown; >0 = stub that many mm.
-FPC_YP = 20;  // cable length beyond Y+ connector
-FPC_YN = 0;   // cable length beyond Y- connector
+// Default stub lengths. 0 = no cable; >0 = stub that many mm.
+FPC_YP = 20;
+FPC_YN = 0;
+
+// ── Mounting bosses ────────────────────────────────────────────────────
+BOSS_D  = 6.0;           // boss outer diameter
+BOSS_H  = 2.0;           // boss standoff height (extends below Z- face)
+SCREW_D = 3.2;           // screw diameter; hole drilled at 0.7× for self-tap
+STUD_R  = 1.5;           // locating stud radius
+STUD_H  = PCB_T + 1.0;  // stud height: pierces PCB with 1 mm snap-through
 
 // ═══════════════════════════════════════════════════════════════════════
-// Modules
+// Private helpers
 // ═══════════════════════════════════════════════════════════════════════
 
 module _pcb_shape(h) {
@@ -58,41 +64,66 @@ module _pcb_shape(h) {
         square([PCB_W - 2*r, PCB_H - 2*r]);
 }
 
-module fpc_adapter(fpc_yp=FPC_YP, fpc_yn=FPC_YN) {
+// Boss hangs from Z- face (z=0) downward; stud pin rises through PCB hole.
+// Stud diagonal: (X1,Y1)+(X2,Y2); screw diagonal: (X1,Y2)+(X2,Y1).
+module _adapt_boss(px, py, stud=false) {
+  translate([px, py, 0]) {
+    translate([0, 0, -BOSS_H])
+      difference() {
+        cylinder(d=BOSS_D, h=BOSS_H, $fn=24);
+        if (!stud)
+          translate([0, 0, -0.1])
+            cylinder(d=SCREW_D * 0.7, h=BOSS_H + 0.2, $fn=18);
+      }
+    if (stud) {
+      cylinder(r=STUD_R, h=STUD_H, $fn=24);
+      translate([0, 0, STUD_H])
+        sphere(r=STUD_R, $fn=24);
+    }
+  }
+}
 
-  // ── PCB body ──────────────────────────────────────────────────────
-  color("#1a7abf", 0.85)
-    difference() {
-      _pcb_shape(PCB_T);
+// ═══════════════════════════════════════════════════════════════════════
+// Public module
+// ═══════════════════════════════════════════════════════════════════════
 
-      // Mounting holes
-      for (xi = [HOLE_MX, PCB_W - HOLE_MX])
-        for (yi = [HOLE_MY, PCB_H - HOLE_MY])
-          translate([xi, yi, -0.1])
-            cylinder(d=HOLE_D, h=PCB_T + 0.2, $fn=24);
-    }
+module fpc_adapter(fpc_yp=FPC_YP, fpc_yn=FPC_YN) {
 
-  // ── Connector A (Y+ edge, FPC exits +Y) ──────────────────────────
-  color("#d0d0d0")
-    translate([CON_CX - CON_W/2, CON_A_Y1, PCB_T])
-      cube([CON_W, CON_D, CON_H]);
-
-  // FPC stub out of connector A
-  if (fpc_yp > 0)
-    color("#e8e8e8")
-      translate([CON_CX - FPC_W/2, PCB_H, PCB_T + (CON_H - FPC_T)/2])
-        cube([FPC_W, fpc_yp, FPC_T]);
-
-  // ── Connector B (Y- edge, FPC exits -Y) ──────────────────────────
-  color("#d0d0d0")
-    translate([CON_CX - CON_W/2, CON_B_Y0, PCB_T])
-      cube([CON_W, CON_D, CON_H]);
-
-  // FPC stub out of connector B
-  if (fpc_yn > 0)
-    color("#e8e8e8")
-      translate([CON_CX - FPC_W/2, -fpc_yn, PCB_T + (CON_H - FPC_T)/2])
-        cube([FPC_W, fpc_yn, FPC_T]);
+  // ── Visual geometry (preview only) ──────────────────────────────────
+  if ($preview) {
+    color("#1a7abf", 0.85)
+      difference() {
+        _pcb_shape(PCB_T);
+        for (xi = [HOLE_MX, PCB_W - HOLE_MX])
+          for (yi = [HOLE_MY, PCB_H - HOLE_MY])
+            translate([xi, yi, -0.1])
+              cylinder(d=HOLE_D, h=PCB_T + 0.2, $fn=24);
+      }
+
+    // Connector A (Y+ edge, FPC exits +Y)
+    color("#d0d0d0")
+      translate([CON_CX - CON_W/2, CON_A_Y1, PCB_T])
+        cube([CON_W, CON_D, CON_H]);
+    if (fpc_yp > 0)
+      color("#e8e8e8")
+        translate([CON_CX - FPC_W/2, PCB_H, PCB_T + (CON_H - FPC_T)/2])
+          cube([FPC_W, fpc_yp, FPC_T]);
+
+    // Connector B (Y- edge, FPC exits -Y)
+    color("#d0d0d0")
+      translate([CON_CX - CON_W/2, CON_B_Y0, PCB_T])
+        cube([CON_W, CON_D, CON_H]);
+    if (fpc_yn > 0)
+      color("#e8e8e8")
+        translate([CON_CX - FPC_W/2, -fpc_yn, PCB_T + (CON_H - FPC_T)/2])
+          cube([FPC_W, fpc_yn, FPC_T]);
+  }
+
+  // ── Mounting bosses (always — structural geometry for host part) ─────
+  _adapt_boss(HOLE_MX,          HOLE_MY,          stud=true);
+  _adapt_boss(PCB_W - HOLE_MX,  PCB_H - HOLE_MY,  stud=true);
+  _adapt_boss(HOLE_MX,          PCB_H - HOLE_MY,   stud=false);
+  _adapt_boss(PCB_W - HOLE_MX,  HOLE_MY,           stud=false);
 }
 
 // Standalone render

+ 11 - 42
lid.scad

@@ -6,44 +6,20 @@ use <GDEY0583T81.scad>
 use <fpc_adapter.scad>
 
 /* [Preview] */
-SHOW_DISP     = true;
-SHOW_ADAPTER  = true;
+SHOW_DISP = true;
 
 /* [FPC Adapter Mount] */
 ADAPT_SLOT_GAP = 2.0;  // gap: adapter Y+ edge to slot Y- edge ← tune
 
-// Adapter board constants (mirror fpc_adapter.scad defaults)
-_adpt_w       = 32.0;
-_adpt_h       = 18.0;
-_adpt_hole_mx = 3.75;
-_adpt_hole_my = 3.75;
+// Adapter board dimensions (must match fpc_adapter.scad PCB_W / PCB_H)
+_adpt_w = 32.0;
+_adpt_h = 18.0;
 
 // Derived adapter position in lid XY space
 _slot_y    = LID_Y_LEN - 3 - FPC_U_DEPTH + FPC_U_T;  // slot Y- edge
 _adapt_ox  = PCB_OX + FPC_CX - _adpt_w / 2;           // adapter PCB X- edge
 _adapt_oy  = _slot_y - ADAPT_SLOT_GAP - _adpt_h;       // adapter PCB Y- edge
 
-// ============================================================
-//  FPC ADAPTER BOSS
-//  Boss hangs downward from ceiling (z=FLANGE_H); stud tip points down
-//  so PCB presses up against boss bottoms and stud snaps through PCB hole.
-// ============================================================
-module adapt_boss(px, py, stud=false) {
-  translate([_adapt_ox + px, _adapt_oy + py, FLANGE_H - BOSS_H]) {
-    difference() {
-      cylinder(d=BOSS_D, h=BOSS_H, $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, -STUD_H]) {
-        cylinder(r=STUD_R, h=STUD_H, $fn=24);
-        sphere(r=STUD_R, $fn=24);
-      }
-  }
-}
-
 // ============================================================
 //  LID  (slide-on; enters from Y- face, closes toward Y+)
 //  Flanges sit inside cavity and ride on base retention flange hypotenuses.
@@ -127,7 +103,7 @@ module lid() {
     }
   }
 
-  color("#004B49") {
+  color("#004B49")
   difference() {
     union() {
       if (!EPD_IS_LID)
@@ -159,14 +135,6 @@ module lid() {
       cube([FPC_NOTCH_W, FPC_SLOT_W, LID_T + 0.2]);
   }
 
-  // Adapter bosses — stud diagonal: (X1,Y1) and (X2,Y2); screw diagonal: (X1,Y2) and (X2,Y1)
-  adapt_boss(_adpt_hole_mx,            _adpt_hole_my,            stud=true);
-  adapt_boss(_adpt_w - _adpt_hole_mx,  _adpt_h - _adpt_hole_my, stud=true);
-  adapt_boss(_adpt_hole_mx,            _adpt_h - _adpt_hole_my,  stud=false);
-  adapt_boss(_adpt_w - _adpt_hole_mx,  _adpt_hole_my,            stud=false);
-
-  } // end color("#004B49")
-
   // Display mockup — seated inside epd_case, preview only
   if ($preview && EPD_IS_LID && SHOW_DISP)
     translate([
@@ -176,12 +144,13 @@ module lid() {
     ])
       GDEY0583T81(fpc_bend_start=0, fpc_bend_r=FPC_BEND_R, fpc_post_clip=2);
 
-  // FPC adapter board — Z- face against boss bottoms; component side (Z+) faces down into cavity
+  // FPC adapter — bosses always (structural); PCB/connectors shown only in $preview.
   // rotate([0,180,0]) flips Z without disturbing ±Y connector exits; +_adpt_w re-centres X.
-  if ($preview && SHOW_ADAPTER)
-    translate([_adapt_ox + _adpt_w, _adapt_oy, FLANGE_H - BOSS_H])
-      rotate([0, 180, 0])
-        fpc_adapter(fpc_yp=15, fpc_yn=0);
+  // Bosses inherit the enclosing color; PCB visual overrides to blue internally.
+  color("#004B49")
+  translate([_adapt_ox + _adpt_w, _adapt_oy, FLANGE_H - BOSS_H])
+    rotate([0, 180, 0])
+      fpc_adapter(fpc_yp=15, fpc_yn=0);
 }
 
 // ============================================================