Files
tdisplay/case/tdisplay_case.scad

292 lines
10 KiB
OpenSCAD
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Gehäuse für das LilyGO T-Display (ESP32, 1,14"-Display)
//
// Teile:
// oberteil – Front mit Displayfenster, zwei Tasten (Federzungen) und USB-C-Öffnung
// deckel – Rückwand; rastet ein und drückt die Platine gegen die Auflagen im Oberteil
// staender – Tischständer, hält das Gehäuse im Querformat leicht nach hinten geneigt
//
// Druck ohne Stützen, PLA oder PETG, 0,2 mm Schichthöhe:
// Oberteil mit der Front nach unten, Deckel mit der Außenseite nach unten, Ständer auf dem Boden.
// Die exportierten STLs liegen schon richtig herum.
//
// Zusammenbau: Platine mit dem Display voran ins Oberteil legen (USB-Buchse in die Öffnung),
// Deckel mit dem Füllstück an der USB-Seite zuerst einsetzen und andrücken, bis er einrastet.
// Öffnen: an der Kerbe gegenüber der USB-Seite mit dem Fingernagel aufhebeln.
//
// STL-Export: make -C case
include <tdisplay_board.scad>
/* [Ansicht] */
part = "explosion"; // [explosion, montage, schnitt, oberteil, deckel, staender, staender_montage]
/* [Passung] */
pcb_gap = 0.25; // Luft zwischen Platine und Innenwand
lid_fit = 0.2; // Luft zwischen Deckel und Gehäuse
snap = 0.4; // Höhe der Rastnasen am Deckel (0 = ohne)
pcb_clamp = 0.1; // Luft zwischen Deckelrippen und Platinenrückseite
/* [Gehäuse] */
wall = 1.6;
wall_usb = 1.2; // Stirnwand an der USB-Seite; dünner, damit der Stecker ganz hineingeht
back_t = 1.6; // Stärke des Deckels
back_space = 3.8; // Platz hinter der Platine (die Akkubuchse ist 3,4 mm hoch)
front_clear = 0.38; // Luft zwischen Displayglas und Front
front_skin = 0.7; // Restwand über der USB-Buchse
corner_r = 2.5;
front_chamfer = 0.6;
/* [Displayfenster] */
// Innenkante des Fensters in Platinenkoordinaten. Die sichtbare Fläche ist 24,91 × 14,86 mm groß;
// in X ist das Fenster großzügiger, weil ihre genaue Lage auf dem Glas nur geschätzt ist.
win_x = [15.9, 43.1];
win_y = [4.7, 20.35];
win_shift = 0; // Fenster in X verschieben (+ = weg vom USB-Ende)
win_chamfer = 1.5; // Fase nach außen
/* [Tasten] */
tongue_w = 4.4; // Breite der Federzunge
tongue_hinge = 11; // X des Gelenks
tongue_t = 0.8; // Stärke der Zunge
slot_w = 0.5; // Schlitz um die Zunge
nub_d = 2.4; // Stößel unter der Zunge
nub_gap = 0.15; // Luft zwischen Stößel und Taster
/* [Ständer] */
stand_tilt = 18; // Neigung nach hinten in Grad
stand_len = 34;
stand_lip = 4; // Höhe der vorderen Kante über der Gehäuseunterkante
/* [Schnittansicht] */
cut_y = 12.53; // Schnitt längs durch die Mitte der USB-Buchse
/* [Hidden] */
$fn = 48;
eps = 0.01;
// Höhen: Z = 0 ist die Vorderseite der Platine
z_top = usb_h + 0.25 + front_skin; // die USB-Buchse ist vorne das höchste Bauteil
z_in = disp_h + front_clear; // Innenseite der Front
z_lid_in = -pcb_t - back_space; // Innenseite des Deckels
z_bot = z_lid_in - back_t;
// Innenraum und Außenmaße
cx0 = -pcb_gap; cx1 = pcb_l + pcb_gap;
cy0 = -pcb_gap; cy1 = pcb_w + pcb_gap;
ox0 = cx0 - wall_usb; ox1 = cx1 + wall;
oy0 = cy0 - wall; oy1 = cy1 + wall;
inner_r = 1.0;
usb_y0 = usb_y - usb_w / 2 - 0.3;
usb_y1 = usb_y + usb_w / 2 + 0.3;
usb_top = usb_h + 0.25;
usb_bot = -0.35; // Oberkante des Füllstücks am Deckel
rib_x = 15; // ab hier sitzen an den Längskanten hinten keine Bauteile mehr
z_rib = -pcb_t - pcb_clamp;
z_low = -2.6; // Rippenhöhe am USB-Ende, unter den Bauteilen dort
snap_z = z_lid_in + 2.2;
snap_xs = [20, 44];
echo(str("Außenmaße: ", ox1 - ox0, " × ", oy1 - oy0, " × ", z_top - z_bot, " mm"));
module rrect(x0, y0, x1, y1, r) {
translate([x0 + r, y0 + r]) offset(r) square([x1 - x0 - 2 * r, y1 - y0 - 2 * r]);
}
module rbox(x0, y0, z0, x1, y1, z1, r) {
translate([0, 0, z0]) linear_extrude(z1 - z0) rrect(x0, y0, x1, y1, r);
}
// ---------- Oberteil ----------
module body() {
c = front_chamfer;
hull() {
rbox(ox0, oy0, z_bot, ox1, oy1, z_top - c, corner_r);
rbox(ox0 + c, oy0 + c, z_top - eps, ox1 - c, oy1 - c, z_top, corner_r - c);
}
}
module window_cut() {
x0 = win_x[0] + win_shift;
x1 = win_x[1] + win_shift;
c = win_chamfer;
hull() {
rbox(x0, win_y[0], z_in - eps, x1, win_y[1], z_in, 0.5);
rbox(x0 - c, win_y[0] - c, z_top, x1 + c, win_y[1] + c, z_top + eps, 0.5 + c);
}
}
module usb_cut() {
// Öffnung in der Stirnwand, nach hinten offen, damit die überstehende Buchse beim Einsetzen
// hineingleitet; unten schließt sie das Füllstück am Deckel
translate([ox0 - 1, 0, 0]) rotate([90, 0, 90]) linear_extrude(cx0 - ox0 + 1 + eps)
offset(0.6) offset(-0.6) translate([usb_y0, z_bot - 3]) square([usb_y1 - usb_y0, usb_top - z_bot + 3]);
// Tasche über der Buchse
translate([cx0 - eps, usb_y0, z_in - eps])
cube([usb_len - usb_overhang + 0.5 - cx0, usb_y1 - usb_y0, usb_top - z_in + eps]);
}
module tongue_cuts() {
x0 = 0.5;
x1 = tongue_hinge;
for (b = btn_pos) {
y0 = b[1] - tongue_w / 2;
// U-förmiger Schlitz, offen zum Gelenk hin
translate([0, 0, z_in - 1]) linear_extrude(z_top - z_in + 2) difference() {
translate([x0 - slot_w, y0 - slot_w]) square([x1 - x0 + slot_w, tongue_w + 2 * slot_w]);
translate([x0, y0]) square([x1 - x0 + 1, tongue_w]);
}
// Zunge von innen dünner machen, damit sie federt
translate([x0, y0, z_in - 1]) cube([x1 - x0, tongue_w, z_top - tongue_t - z_in + 1]);
}
}
module nubs() {
for (b = btn_pos)
translate([b[0], b[1], btn_h + nub_gap]) cylinder(d = nub_d, h = z_top - tongue_t - btn_h - nub_gap + eps);
}
module reset_cut() {
// Durchbruch, um den Reset-Taster mit einer Büroklammer zu drücken
translate([rst_x - 1.5, oy0 - 1, 0]) cube([3, wall + 1 + eps, 2]);
// Nut innen: der überstehende Tasterhebel gleitet beim Einsetzen an der Wand vorbei
translate([rst_x - 1.5, cy0 - 0.6, z_bot - 1]) cube([3, 0.6 + eps, 2 - z_bot + 1]);
// Platz über dem Tastergehäuse
translate([9.3, cy0 - eps, z_in - eps]) cube([5.2, 3.35, rst_h + 0.3 - z_in + eps]);
}
module snap_grooves() {
d = snap - lid_fit + 0.15;
if (snap > 0)
for (y = [cy0 - d, cy1 - eps])
translate([rib_x, y, snap_z - snap - 0.15]) cube([cx1 - rib_x - 2, d + eps, 2 * snap + 0.3]);
}
module pry_notch() {
translate([cx1 - eps, (oy0 + oy1) / 2 - 3, z_bot - 1]) cube([wall + 1, 6, 2]);
}
// Auflagen für die Platinenvorderseite, nur wo vorne keine Bauteile sitzen
module ledges() {
intersection() {
rbox(cx0, cy0, 0, cx1, cy1, z_in + eps, inner_r);
union() {
translate([15.5, cy0, 0]) cube([cx1 - 15.5, 1.2, z_in + eps]);
translate([15.5, cy1 - 1.2, 0]) cube([cx1 - 15.5, 1.2, z_in + eps]);
translate([pcb_l - 2, cy0, 0]) cube([cx1 - pcb_l + 2, cy1 - cy0, z_in + eps]);
}
}
}
module shell() {
difference() {
body();
rbox(cx0, cy0, z_bot - 1, cx1, cy1, z_in, inner_r);
window_cut();
usb_cut();
tongue_cuts();
reset_cut();
snap_grooves();
pry_notch();
}
ledges();
nubs();
}
// ---------- Deckel ----------
module lid() {
x0 = cx0 + lid_fit; x1 = cx1 - lid_fit;
y0 = cy0 + lid_fit; y1 = cy1 - lid_fit;
r = inner_r - lid_fit;
rib = 0.8;
rbox(x0, y0, z_bot, x1, y1, z_lid_in, r);
// Rippen am Rand; wo sie die Platine erreichen, halten sie sie gegen die Auflagen
intersection() {
rbox(x0, y0, z_lid_in - eps, x1, y1, z_rib, r);
union() {
for (y = [y0, y1 - rib]) {
translate([rib_x, y, z_lid_in - eps]) cube([x1 - rib_x, rib, z_rib - z_lid_in + eps]);
translate([x0, y, z_lid_in - eps]) cube([rib_x - x0, rib, z_low - z_lid_in + eps]);
}
translate([x1 - rib, y0, z_lid_in - eps]) cube([rib, y1 - y0, z_rib - z_lid_in + eps]);
translate([x0, y0, z_lid_in - eps]) cube([rib, y1 - y0, z_low - z_lid_in + eps]);
}
}
// Rastnasen
if (snap > 0)
for (sx = snap_xs, y = [y0, y1])
hull() for (dx = [-3, 3]) translate([sx + dx, y, snap_z]) sphere(r = snap, $fn = 16);
// Füllstück unter der USB-Buchse, unten mit der Rippe am USB-Ende verbunden
fy0 = usb_y0 + lid_fit;
fy1 = usb_y1 - lid_fit;
translate([ox0, fy0, z_bot]) cube([cx0 - 0.1 - ox0, fy1 - fy0, usb_bot - z_bot]);
translate([ox0, fy0, z_bot]) cube([x0 + rib - ox0, fy1 - fy0, z_low - z_bot]);
}
// ---------- Ständer ----------
stand_c = 0.3; // Luft um das Gehäuse
stand_floor = 2.5; // Bodenstärke unter der tiefsten Gehäuseecke
// Höhe der vorderen Unterkante des Gehäuses über dem Tisch
stand_v0 = stand_floor + stand_c + (z_top - z_bot + stand_c) * sin(stand_tilt);
module stand() {
T = z_top - z_bot;
W = oy1 - oy0;
a = stand_tilt;
c = stand_c;
v0 = stand_v0;
sup_t = 3;
sup_h = 0.65 * W;
depth = (T + c + sup_t) * cos(a) + sup_h * sin(a) + 3;
// Querschnitt, entlang X extrudiert
rotate([90, 0, 90]) linear_extrude(stand_len) offset(r = 0.6) offset(delta = -0.6) difference() {
union() {
translate([-3.5, 0]) square([depth + 3.5, v0 - 1]);
translate([-3.5, 0]) square([5.5, v0 + stand_lip]);
translate([0, v0]) rotate(-a) translate([T + c, -v0 - 5]) square([sup_t, sup_h + v0 + 5]);
}
translate([0, v0]) rotate(-a) translate([-c, -c]) square([T + 2 * c, W + 2 * c]);
translate([-50, -50]) square([200, 50]);
}
}
// Lage des Gehäuses im Ständer (für die Vorschau)
module on_stand() {
translate([(stand_len - (ox1 - ox0)) / 2 - ox0, 0, stand_v0])
rotate([90 - stand_tilt, 0, 0]) translate([0, -oy0, -z_top]) children();
}
// ---------- Ausgabe ----------
module assembled() {
color("#e8e8e8", 0.55) shell();
tdisplay_board();
color("#9a9a9a") lid();
}
if (part == "oberteil") {
translate([0, 0, z_top]) rotate([180, 0, 0]) shell();
} else if (part == "deckel") {
translate([0, 0, -z_bot]) lid();
} else if (part == "staender") {
stand();
} else if (part == "montage") {
assembled();
} else if (part == "explosion") {
color("#e8e8e8") translate([0, 0, 14]) shell();
tdisplay_board();
color("#9a9a9a") translate([0, 0, -12]) lid();
} else if (part == "schnitt") {
intersection() {
assembled();
translate([ox0 - 5, cut_y, z_bot - 5]) cube([ox1 - ox0 + 10, oy1 - oy0 + 10, z_top - z_bot + 10]);
}
} else if (part == "staender_montage") {
color("#9a9a9a") stand();
on_stand() { color("#e8e8e8") shell(); tdisplay_board(); color("#9a9a9a") lid(); }
}