From 402fbe32bd7b113421e6ad69bfce4a2069c213ba Mon Sep 17 00:00:00 2001
From: XANTRONIX Development
Date: Sun, 26 Nov 2023 00:55:14 -0500
Subject: Slowly but surely

---
 case/Makefile     |  2 +-
 case/outline.scad | 31 --------------------
 case/screws.scad  | 20 -------------
 case/top.scad     | 88 +++++++++++++++++++++++++++++++++++++++++++++----------
 4 files changed, 74 insertions(+), 67 deletions(-)
 delete mode 100644 case/outline.scad
 delete mode 100644 case/screws.scad

diff --git a/case/Makefile b/case/Makefile
index a429d5d..40dbadb 100644
--- a/case/Makefile
+++ b/case/Makefile
@@ -1,4 +1,4 @@
-SCAD_MODELS	= top-keyboard.scad top-outline.scad
+SCAD_MODELS	= top-keyboard.scad
 SCAD_INCLUDE	= params.scad
 
 STL_MODELS	= top-keyboard.stl
diff --git a/case/outline.scad b/case/outline.scad
deleted file mode 100644
index c48812c..0000000
--- a/case/outline.scad
+++ /dev/null
@@ -1,31 +0,0 @@
-include <screws.scad>
-
-$fn = 72;
-
-translate([case_length_bottom, 0, 0])
-rotate([0, 0, 90])
-intersection() {
-    square([200, 200], false);
-    union() {
-        square([wall_width, case_length_bottom], false);
-        square([case_width_bottom, wall_width], false);
-
-        translate([case_width_bottom - wall_width, 0, 0])
-        square([wall_width, case_length_bottom], false);
-
-        translate([0, case_length_bottom - wall_width, 0])
-        square([case_width_bottom, wall_width], false);
-
-
-        for (screw_post = screw_posts_top_case) {
-            x = screw_post[0];
-            y = screw_post[1];
-
-            translate([x, y, 0])
-            difference() {
-                circle(d=screw_post_diameter_outer);
-                circle(d=screw_post_diameter_inner);
-            }
-        }
-    }
-}
diff --git a/case/screws.scad b/case/screws.scad
deleted file mode 100644
index 657c11c..0000000
--- a/case/screws.scad
+++ /dev/null
@@ -1,20 +0,0 @@
-screw_post_lower_y_offset  = (keyboard_y_offset - 2 * wall_width) / 2 + wall_width;
-screw_post_middle_y_offset = screw_post_lower_y_offset  + 65.00;
-screw_post_upper_y_offset  = screw_post_middle_y_offset + 65.00;
-screw_post_x_offset        = (keyboard_x_offset - 2 * wall_width) / 2 + wall_width;
-
-screw_posts_top_case = [
-    /* Upper row */
-    [screw_post_x_offset,   screw_post_upper_y_offset, screw_post_corner_height],
-    [case_width_bottom / 2, case_length_bottom - 10.0, screw_post_middle_height],
-    [case_width_bottom - screw_post_x_offset, screw_post_upper_y_offset, screw_post_corner_height],
-
-    /* Middle row */
-    [screw_post_x_offset, screw_post_middle_y_offset, screw_post_corner_height],
-    [case_width_bottom - screw_post_x_offset, screw_post_middle_y_offset, screw_post_corner_height],
-
-    /* Bottom row */
-    [screw_post_x_offset, screw_post_lower_y_offset, screw_post_corner_height],
-    [case_width_bottom / 2, screw_post_lower_y_offset, screw_post_corner_height],
-    [case_width_bottom - screw_post_x_offset, screw_post_lower_y_offset, screw_post_corner_height]
-];
diff --git a/case/top.scad b/case/top.scad
index 951cde8..1b77b9b 100644
--- a/case/top.scad
+++ b/case/top.scad
@@ -1,11 +1,12 @@
 $fn = 72;
 
 include <support.scad>
-include <screws.scad>
 include <keyboard.scad>
 include <logo.scad>
 
-module top_case(with_keyboard=false) {
+module top_case(with_keyboard=false, as_flat=false) {
+    eps = 0.01;
+
     accent_width    = 1.0000;
     accent_depth    = 0.5;
     accent_y_stride = (keyboard_pcb_length - accent_width) / 5.0;
@@ -18,7 +19,26 @@ module top_case(with_keyboard=false) {
     vent_x_first  = keyboard_x_offset + keyboard_pcb_width - vent_count * 2*vent_width;
     vent_y_offset = case_length_bottom - vent_length;
 
-    eps = 0.01;
+    screw_post_lower_y_offset  = (keyboard_y_offset - 2 * wall_width) / 2 + wall_width;
+    screw_post_middle_y_offset = screw_post_lower_y_offset  + 65.00;
+    screw_post_upper_y_offset  = screw_post_middle_y_offset + 65.00;
+    screw_post_x_offset        = (keyboard_x_offset - 2 * wall_width) / 2 + wall_width;
+
+    screw_posts_top_case = [
+        /* Upper row */
+        [screw_post_x_offset,   screw_post_upper_y_offset, screw_post_corner_height],
+        [case_width_bottom / 2, case_length_bottom - 10.0, screw_post_middle_height],
+        [case_width_bottom - screw_post_x_offset, screw_post_upper_y_offset, screw_post_corner_height],
+
+        /* Middle row */
+        [screw_post_x_offset, screw_post_middle_y_offset, screw_post_corner_height],
+        [case_width_bottom - screw_post_x_offset, screw_post_middle_y_offset, screw_post_corner_height],
+
+        /* Bottom row */
+        [screw_post_x_offset, screw_post_lower_y_offset, screw_post_corner_height],
+        [case_width_bottom / 2, screw_post_lower_y_offset, screw_post_corner_height],
+        [case_width_bottom - screw_post_x_offset, screw_post_lower_y_offset, screw_post_corner_height]
+    ];
 
     module fascia() {
         difference() {
@@ -195,24 +215,62 @@ module top_case(with_keyboard=false) {
         cube([wall_width, case_length_bottom, wall_height]);
     }
 
-    difference() {
-        body();
-        accents();
-        vents();
-        badges();
+    module model() {
+        difference() {
+            body();
+            accents();
+            vents();
+            badges();
+        }
+
+        screw_posts();
+
+        if (with_keyboard) {
+            z_offset = wall_height - keyboard_switch_height;
+
+            keyboard_supports();
+
+            translate([keyboard_x_offset, keyboard_y_offset, z_offset])
+            keyboard_deck(wall_width);
+        } else {
+            supports();
+        }
     }
 
-    screw_posts();
+    module flat() {
+        translate([case_length_bottom, 0, 0])
+        rotate([0, 0, 90])
+        intersection() {
+            square([200, 200], false);
+            union() {
+                square([wall_width, case_length_bottom], false);
+                square([case_width_bottom, wall_width], false);
+
+                translate([case_width_bottom - wall_width, 0, 0])
+                square([wall_width, case_length_bottom], false);
+
+                translate([0, case_length_bottom - wall_width, 0])
+                square([case_width_bottom, wall_width], false);
 
-    if (with_keyboard) {
-        z_offset = wall_height - keyboard_switch_height;
 
-        keyboard_supports();
+                for (screw_post = screw_posts_top_case) {
+                    x = screw_post[0];
+                    y = screw_post[1];
+
+                    translate([x, y, 0])
+                    difference() {
+                        circle(d=screw_post_diameter_outer);
+                        circle(d=screw_post_diameter_inner);
+                    }
+                }
+            }
+        }
+    }
 
-        translate([keyboard_x_offset, keyboard_y_offset, z_offset])
-        keyboard_deck(wall_width);
+    if (as_flat) {
+        flat();
     } else {
-        supports();
+        model();
     }
 }
 
-- 
cgit v1.2.3