ops-devices-cube/3d-model/cube-assembly.scad
2026-02-08 13:14:38 +01:00

271 lines
9.3 KiB
OpenSCAD

// ============================================================================
// Companion Cube — Modèle 3D Complet
// Version : 0.3.0
// Architecture : Pièces modulaires séparées
// ============================================================================
//
// STRUCTURE (10 pièces à imprimer) :
// 1. Frame (squelette) — Structure principale avec plots de fixation
// 2. Battery Cradle — Support batterie (vissé au frame)
// 3. PCB Central Mount — Support PCB central (vissé au frame)
// 4-9. PCB Carriers (x6) — Support PCB pour chaque face (vissé sur plots)
// - Standard (x4)
// - NFC (x1, dessus)
// - Qi (x1, dessous)
// 10-15. Face Covers (x6) — Coques extérieures (étanchéité + look Portal)
// - Standard (x4)
// - NFC (x1)
// - Qi (x1)
//
// ASSEMBLAGE :
// 1. Visser Battery Cradle + PCB Central Mount au Frame
// 2. Monter l'électronique (batterie, PCB central, câbles)
// 3. Visser chaque PCB Carrier sur les plots du Frame
// 4. Monter les PCBs (Anneau + Bouchon) sur chaque Carrier
// 5. Câbler JST depuis le PCB central vers chaque Carrier
// 6. Visser les Face Covers sur les Carriers (joint O-ring entre)
//
// UTILISATION :
// - Variables `SHOW_*` pour afficher/masquer les pièces
// - Variable `EXPLODE` pour la vue éclatée (0 à 1)
// - Modules individuels exportables en STL
//
// ============================================================================
include <cube-config.scad>
include <cube-parts.scad>
// --- Contrôle de l'affichage ------------------------------------------------
SHOW_FRAME = true; // Squelette principal
SHOW_INTERNALS = true; // Battery Cradle + PCB Central Mount
SHOW_PCB_CARRIERS = true; // 6 supports PCB
SHOW_FACE_COVERS = true; // 6 coques extérieures
SHOW_ELECTRONICS = true; // Batterie + PCB (visualisation)
SHOW_SECTION = false; // Coupe en section
EXPLODE = 0; // 0 = assemblé, 1 = vue éclatée (progressif)
// Distance d'éclatement
EXPLODE_DIST = 40 * EXPLODE;
// ============================================================================
// VISUALISATION ÉLECTRONIQUE (Ne pas imprimer)
// ============================================================================
module electronics() {
// --- Batterie LiPo ---
color(COLOR_BATTERY)
translate([0, 0, -10])
cube([BATT_LENGTH, BATT_WIDTH, BATT_HEIGHT], center=true);
// --- PCB Central ---
color(COLOR_PCB)
translate([0, 0, 8 + 5])
cube([CENTRAL_PCB_LENGTH, CENTRAL_PCB_WIDTH, CENTRAL_PCB_HEIGHT], center=true);
// --- ESP32-S3 module ---
color([0.15, 0.15, 0.15])
translate([0, 0, 8 + 5 + CENTRAL_PCB_HEIGHT/2 + 1.5])
cube([18, 18, 3], center=true);
// --- TP4056 ---
color(COLOR_PCB)
translate([20, 0, 8 + 5 + CENTRAL_PCB_HEIGHT/2 + 1])
cube([10, 8, 2], center=true);
}
// PCB Anneau (visualisation)
module pcb_ring() {
color(COLOR_PCB)
difference() {
cylinder(d=LED_RING_DIAM_EXT, h=LED_RING_HEIGHT);
translate([0, 0, -0.5])
cylinder(d=LED_RING_DIAM_INT, h=LED_RING_HEIGHT + 1);
}
// LEDs WS2812B
color(COLOR_LED)
for (i = [0:LED_COUNT-1]) {
angle = i * 360 / LED_COUNT;
r = (LED_RING_DIAM_EXT + LED_RING_DIAM_INT) / 4;
translate([r * cos(angle), r * sin(angle), LED_RING_HEIGHT])
cube([5, 5, 1.5], center=true);
}
}
// PCB Bouchon (visualisation)
module pcb_cap() {
color(COLOR_PCB)
cylinder(d=CAP_PCB_DIAM, h=CAP_PCB_HEIGHT);
// Pad capacitif
color([0.8, 0.6, 0.2])
translate([0, 0, CAP_PCB_HEIGHT])
cylinder(d=CAP_PCB_DIAM - 5, h=0.1);
}
// Module NFC PN532 (visualisation)
module nfc_module() {
color(COLOR_NFC) {
cube([NFC_PCB_SIZE, NFC_PCB_SIZE, NFC_PCB_HEIGHT], center=true);
translate([0, 0, NFC_PCB_HEIGHT/2])
cylinder(d=NFC_ANTENNA_DIAM, h=0.5);
}
}
// Bobine Qi (visualisation)
module qi_coil() {
color(COLOR_QI) {
cylinder(d=QI_COIL_DIAM, h=QI_COIL_HEIGHT);
translate([0, QI_COIL_DIAM/2 + 5, 0])
cube([QI_PCB_LENGTH, QI_PCB_WIDTH, QI_PCB_HEIGHT], center=true);
}
}
// ============================================================================
// ASSEMBLAGE PRINCIPAL
// ============================================================================
module assembly() {
half = CUBE_SIZE / 2;
edge_d = FRAME_EDGE_DEPTH;
// --- 1. FRAME (Squelette) ---
if (SHOW_FRAME)
color(COLOR_FRAME) frame();
// --- 2. INTERNALS (Supports internes) ---
if (SHOW_INTERNALS) {
// Battery Cradle (centré, décalé vers le bas)
color([0.4, 0.4, 0.4])
translate([0, 0, -10 - EXPLODE_DIST * 0.3])
battery_cradle();
// PCB Central Mount (centré, au-dessus de la batterie)
color([0.4, 0.4, 0.4])
translate([0, 0, 8 + EXPLODE_DIST * 0.3])
pcb_central_mount();
}
// --- 3. ÉLECTRONIQUE (Visualisation) ---
if (SHOW_ELECTRONICS)
electronics();
// --- 4-9. PCB CARRIERS (6 supports PCB) ---
if (SHOW_PCB_CARRIERS) {
carrier_offset = 10; // Distance depuis la corniche du frame
// Carrier Dessus (+Z) — NFC
color([0.5, 0.5, 0.5])
translate([0, 0, half - edge_d + carrier_offset + EXPLODE_DIST * 0.7])
pcb_carrier_nfc();
// Carrier Dessous (-Z) — Qi
color([0.5, 0.5, 0.5])
translate([0, 0, -(half - edge_d + carrier_offset) - EXPLODE_DIST * 0.7])
rotate([180, 0, 0])
pcb_carrier_qi();
// Carrier Avant (-Y)
color([0.5, 0.5, 0.5])
translate([0, -(half - edge_d + carrier_offset) - EXPLODE_DIST * 0.7, 0])
rotate([90, 0, 0])
pcb_carrier_standard();
// Carrier Arrière (+Y)
color([0.5, 0.5, 0.5])
translate([0, (half - edge_d + carrier_offset) + EXPLODE_DIST * 0.7, 0])
rotate([-90, 0, 0])
pcb_carrier_standard();
// Carrier Gauche (-X)
color([0.5, 0.5, 0.5])
translate([-(half - edge_d + carrier_offset) - EXPLODE_DIST * 0.7, 0, 0])
rotate([0, -90, 0])
pcb_carrier_standard();
// Carrier Droite (+X)
color([0.5, 0.5, 0.5])
translate([(half - edge_d + carrier_offset) + EXPLODE_DIST * 0.7, 0, 0])
rotate([0, 90, 0])
pcb_carrier_standard();
}
// --- 10-15. FACE COVERS (6 coques extérieures) ---
if (SHOW_FACE_COVERS) {
cover_offset = 16; // Distance depuis le frame (par-dessus les carriers)
// Cover Dessus (+Z) — NFC
color(COLOR_FACE)
translate([0, 0, half - edge_d + cover_offset + EXPLODE_DIST])
face_cover_nfc();
// Cover Dessous (-Z) — Qi
color(COLOR_FACE)
translate([0, 0, -(half - edge_d + cover_offset) - EXPLODE_DIST])
rotate([180, 0, 0])
face_cover_qi();
// Cover Avant (-Y)
color(COLOR_FACE)
translate([0, -(half - edge_d + cover_offset) - EXPLODE_DIST, 0])
rotate([90, 0, 0])
face_cover_standard();
// Cover Arrière (+Y)
color(COLOR_FACE)
translate([0, (half - edge_d + cover_offset) + EXPLODE_DIST, 0])
rotate([-90, 0, 0])
face_cover_standard();
// Cover Gauche (-X)
color(COLOR_FACE)
translate([-(half - edge_d + cover_offset) - EXPLODE_DIST, 0, 0])
rotate([0, -90, 0])
face_cover_standard();
// Cover Droite (+X)
color(COLOR_FACE)
translate([(half - edge_d + cover_offset) + EXPLODE_DIST, 0, 0])
rotate([0, 90, 0])
face_cover_standard();
}
}
// ============================================================================
// RENDU
// ============================================================================
if (SHOW_SECTION) {
difference() {
assembly();
// Coupe en section (plan YZ, moitié +X)
translate([CUBE_SIZE/2, 0, 0])
cube([CUBE_SIZE, CUBE_SIZE * 2, CUBE_SIZE * 2], center=true);
}
} else {
assembly();
}
// ============================================================================
// MODULES D'EXPORT (décommenter pour exporter individuellement en STL)
// ============================================================================
// Pour exporter une pièce : décommenter la ligne, commenter assembly(),
// puis Exporter en STL (F6 → File → Export STL)
// --- Pièces Structurelles ---
// frame(); // → 01-frame.stl
// battery_cradle(); // → 02-battery-cradle.stl
// pcb_central_mount(); // → 03-pcb-central-mount.stl
// --- PCB Carriers (6 pièces) ---
// pcb_carrier_standard(); // → 04-pcb-carrier-standard.stl (à imprimer x4)
// pcb_carrier_nfc(); // → 05-pcb-carrier-nfc.stl (dessus)
// pcb_carrier_qi(); // → 06-pcb-carrier-qi.stl (dessous)
// --- Face Covers (6 pièces) ---
// face_cover_standard(); // → 07-face-cover-standard.stl (à imprimer x4)
// face_cover_nfc(); // → 08-face-cover-nfc.stl (dessus)
// face_cover_qi(); // → 09-face-cover-qi.stl (dessous)