From 01748600942545e02076a05812308bff46451112 Mon Sep 17 00:00:00 2001 From: carbonfet <59760875+carbonfet@users.noreply.github.com> Date: Mon, 13 Jan 2020 04:45:52 -0500 Subject: [PATCH] Add files via upload --- src/dactyl_keyboard/dactyl.clj | 1009 ++++++++++++++++++++++---------- 1 file changed, 704 insertions(+), 305 deletions(-) diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj index 5e1697c..999b366 100644 --- a/src/dactyl_keyboard/dactyl.clj +++ b/src/dactyl_keyboard/dactyl.clj @@ -1,9 +1,10 @@ (ns dactyl-keyboard.dactyl - (:refer-clojure :exclude [use import]) - (:require [clojure.core.matrix :refer [array matrix mmul]] - [scad-clj.scad :refer :all] - [scad-clj.model :refer :all] - [unicode-math.core :refer :all])) + (:refer-clojure :exclude [use import]) + (:require [clojure.core.matrix :refer [array matrix mmul]] + [scad-clj.scad :refer :all] + [scad-clj.model :refer :all] + [unicode-math.core :refer :all])) + (defn deg2rad [degrees] (* (/ degrees 180) pi)) @@ -13,37 +14,50 @@ ;;;;;;;;;;;;;;;;;;;;;; (def nrows 5) -(def ncols 6) +(def ncols 7) (def α (/ π 12)) ; curvature of the columns (def β (/ π 36)) ; curvature of the rows (def centerrow (- nrows 3)) ; controls front-back tilt -(def centercol 2) ; controls left-right tilt / tenting (higher number is more tenting) +(def centercol 4) ; controls left-right tilt / tenting (higher number is more tenting) (def tenting-angle (/ π 12)) ; or, change this for more precise tenting control -(def column-style - (if (> nrows 5) :orthographic :standard)) ; options include :standard, :orthographic, and :fixed -; (def column-style :fixed) -(def pinky-15u true) -(defn column-offset [column] (cond - (= column 2) [0 2.82 -4.5] - (>= column 4) [0 -12 5.64] ; original [0 -5.8 5.64] - :else [0 0 0])) +(def pinky-15u true) ; controls whether the outer column uses 1.5u keys +(def first-15u-row 0) ; controls which should be the first row to have 1.5u keys on the outer column +(def last-15u-row 3) ; controls which should be the last row to have 1.5u keys on the outer column + +(def extra-row true) ; adds an extra bottom row to the outer columns +(def inner-column true) ; adds an extra inner column (two less rows than nrows) +(def mini-thumb false) ; toggles between the default thumb cluster and mini thumb cluster + +(def column-style :standard) + +(if (true? inner-column) + (defn column-offset [column] (cond + (<= column 1) [0 -2 0] + (= column 3) [0 2.82 -4.5] + (>= column 5) [0 -12 5.64] ; original [0 -5.8 5.64] + :else [0 0 0])) + (defn column-offset [column] (cond + (= column 2) [0 2.82 -4.5] + (>= column 4) [0 -12 5.64] ; original [0 -5.8 5.64] + :else [0 0 0])) + ) (def thumb-offsets [6 -3 7]) -(def keyboard-z-offset 9) ; controls overall height; original=9 with centercol=3; use 16 for centercol=2 +(def keyboard-z-offset 11) ; controls overall height; original=9 with centercol=3; use 16 for centercol=2 (def extra-width 2.5) ; extra space between the base of keys; original= 2 (def extra-height 1.0) ; original= 0.5 -(def wall-z-offset -5) ; original=-15 length of the first downward-sloping part of the wall (negative) +(def wall-z-offset -8) ; length of the first downward-sloping part of the wall (negative) (def wall-xy-offset 5) ; offset in the x and/or y direction for the first downward-sloping part of the wall (negative) (def wall-thickness 2) ; wall thickness parameter; originally 5 ;; Settings for column-style == :fixed ;; The defaults roughly match Maltron settings -;; http://patentimages.storage.googleapis.com/EP0219944A2/imgf0002.png +;; http://patentimages.storage.googleapis.com/EP0219944A2/imgf0002.png ;; Fixed-z overrides the z portion of the column ofsets above. ;; NOTE: THIS DOESN'T WORK QUITE LIKE I'D HOPED. (def fixed-angles [(deg2rad 10) (deg2rad 10) 0 0 0 (deg2rad -15) (deg2rad -15)]) @@ -53,7 +67,7 @@ ; If you use Cherry MX or Gateron switches, this can be turned on. ; If you use other switches such as Kailh, you should set this as false -(def create-side-nubs? true) +(def create-side-nubs? false) ;;;;;;;;;;;;;;;;;;;;;;; ;; General variables ;; @@ -62,22 +76,24 @@ (def lastrow (dec nrows)) (def cornerrow (dec lastrow)) (def lastcol (dec ncols)) +(if (true? extra-row) (def extra-cornerrow lastrow) (def extra-cornerrow cornerrow)) +(if (true? inner-column) (def innercol-offset 1) (def innercol-offset 0)) ;;;;;;;;;;;;;;;;; ;; Switch Hole ;; ;;;;;;;;;;;;;;;;; -(def keyswitch-height 14.2) ;; Was 14.1, then 14.25 -(def keyswitch-width 14.2) +(def keyswitch-height 14.15) +(def keyswitch-width 14.15) (def sa-profile-key-height 12.7) -(def plate-thickness 2) +(def plate-thickness 4) (def side-nub-thickness 4) (def retention-tab-thickness 1.5) (def retention-tab-hole-thickness (- plate-thickness retention-tab-thickness)) -(def mount-width (+ keyswitch-width 3)) -(def mount-height (+ keyswitch-height 3)) +(def mount-width (+ keyswitch-width 3.2)) +(def mount-height (+ keyswitch-height 2.7)) (def single-plate (let [top-wall (->> (cube (+ keyswitch-width 3) 1.5 plate-thickness) @@ -98,7 +114,7 @@ (translate [0 0 (- plate-thickness side-nub-thickness)])) plate-half (union top-wall left-wall (if create-side-nubs? (with-fn 100 side-nub))) top-nub (->> (cube 5 5 retention-tab-hole-thickness) - (translate [(+ (/ keyswitch-width 2)) 0 (/ retention-tab-hole-thickness 2)])) + (translate [(+ (/ keyswitch-width 2.5)) 0 (/ retention-tab-hole-thickness 2)])) top-nub-pair (union top-nub (->> top-nub (mirror [1 0 0]) @@ -112,6 +128,22 @@ top-nub-pair (rotate (/ π 2) [0 0 1]))))) +(def larger-plate + (let [plate-height (/ (- sa-double-length mount-height) 3) + top-plate (->> (cube mount-width plate-height web-thickness) + (translate [0 (/ (+ plate-height mount-height) 2) + (- plate-thickness (/ web-thickness 2))])) + ] + (union top-plate (mirror [0 1 0] top-plate)))) + +(def larger-plate-half + (let [plate-height (/ (- sa-double-length mount-height) 3) + top-plate (->> (cube mount-width plate-height web-thickness) + (translate [0 (/ (+ plate-height mount-height) 2) + (- plate-thickness (/ web-thickness 2))])) + ] + (union top-plate (mirror [0 0 0] top-plate)))) + ;;;;;;;;;;;;;;;; ;; SA Keycaps ;; ;;;;;;;;;;;;;;;; @@ -159,9 +191,12 @@ ;; Placement Functions ;; ;;;;;;;;;;;;;;;;;;;;;;;;; -(def columns (range 0 ncols)) +(def columns (range (+ innercol-offset 0) ncols)) (def rows (range 0 nrows)) +(def innercolumn 0) +(def innerrows (range 0 (- nrows 2))) + (def cap-top-height (+ plate-thickness sa-profile-key-height)) (def row-radius (+ (/ (/ (+ mount-height extra-height) 2) (Math/sin (/ α 2))) @@ -171,12 +206,12 @@ cap-top-height)) (def column-x-delta (+ -1 (- (* column-radius (Math/sin β))))) -(defn offset-for-column [col] - (if (and (true? pinky-15u) (= col lastcol)) 5.5 0)) +(defn offset-for-column [col, row] + (if (and (true? pinky-15u) (= col lastcol) (<= row last-15u-row) (>= row first-15u-row)) 4.7625 0)) (defn apply-key-geometry [translate-fn rotate-x-fn rotate-y-fn column row shape] (let [column-angle (* β (- centercol column)) placed-shape (->> shape - (translate-fn [(offset-for-column column) 0 (- row-radius)]) + (translate-fn [(offset-for-column column, row) 0 (- row-radius)]) (rotate-x-fn (* α (- centerrow row))) (translate-fn [0 0 row-radius]) (translate-fn [0 0 (- column-radius)]) @@ -200,9 +235,9 @@ (rotate-y-fn fixed-tenting) (translate-fn [0 (second (column-offset column)) 0]))] (->> (case column-style - :orthographic placed-shape-ortho - :fixed placed-shape-fixed - placed-shape) + :orthographic placed-shape-ortho + :fixed placed-shape-fixed + placed-shape) (rotate-y-fn tenting-angle) (translate-fn [0 0 keyboard-z-offset])))) @@ -233,11 +268,14 @@ (apply union (for [column columns row rows - :when (or (.contains [2 3] column) + :when (or (.contains [(+ innercol-offset 2) (+ innercol-offset 3)] column) + (and (.contains [(+ innercol-offset 4) (+ innercol-offset 5)] column) (true? extra-row) (= ncols (+ innercol-offset 6))) + (and (.contains [(+ innercol-offset 4)] column) (true? extra-row) (= ncols (+ innercol-offset 5))) + (and (true? inner-column) (not= row cornerrow)(= column 0)) (not= row lastrow))] (->> single-plate + ; (rotate (/ π 2) [0 0 1]) (key-place column row))))) - (def caps (apply union (for [column columns @@ -247,11 +285,20 @@ (->> (sa-cap (if (and (true? pinky-15u) (= column lastcol)) 1.5 1)) (key-place column row))))) +;placement for the innermost column +(def key-holes-inner + (if (true? inner-column) + (apply union + (for [row innerrows] + (->> single-plate + ; (rotate (/ π 2) [0 0 1]) + (key-place 0 row)))))) + ;;;;;;;;;;;;;;;;;;;; ;; Web Connectors ;; ;;;;;;;;;;;;;;;;;;;; -(def web-thickness 2) +(def web-thickness 3.5) (def post-size 0.1) (def web-post (->> (cube post-size post-size web-thickness) (translate [0 0 (+ (/ web-thickness -2) @@ -264,16 +311,15 @@ (def web-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) ; wide posts for 1.5u keys in the main cluster - (if (true? pinky-15u) (do (def wide-post-tr (translate [(- (/ mount-width 1.2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) - (def wide-post-tl (translate [(+ (/ mount-width -1.2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) - (def wide-post-bl (translate [(+ (/ mount-width -1.2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) - (def wide-post-br (translate [(- (/ mount-width 1.2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post))) + (def wide-post-tl (translate [(+ (/ mount-width -1.2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) + (def wide-post-bl (translate [(+ (/ mount-width -1.2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) + (def wide-post-br (translate [(- (/ mount-width 1.2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post))) (do (def wide-post-tr web-post-tr) - (def wide-post-tl web-post-tl) - (def wide-post-bl web-post-bl) - (def wide-post-br web-post-br))) + (def wide-post-tl web-post-tl) + (def wide-post-bl web-post-bl) + (def wide-post-br web-post-br))) (defn triangle-hulls [& shapes] (apply union @@ -284,7 +330,7 @@ (apply union (concat ;; Row connections - (for [column (range 0 (dec ncols)) + (for [column (range (+ innercol-offset 0) (dec ncols)) row (range 0 lastrow)] (triangle-hulls (key-place (inc column) row web-post-tl) @@ -310,45 +356,268 @@ (key-place (inc column) row web-post-bl) (key-place (inc column) (inc row) web-post-tl)))))) -;;;;;;;;;;;; -;; Thumbs ;; -;;;;;;;;;;;; +(def inner-connectors + (if (true? inner-column) + (apply union + (concat + ;; Row connections + (for [column (range 0 1) + row (range 0 (- nrows 2))] + (triangle-hulls + (key-place (inc column) row web-post-tl) + (key-place column row web-post-tr) + (key-place (inc column) row web-post-bl) + (key-place column row web-post-br))) + + ;; Column connections + (for [row (range 0 (dec cornerrow))] + (triangle-hulls + (key-place innercolumn row web-post-bl) + (key-place innercolumn row web-post-br) + (key-place innercolumn (inc row) web-post-tl) + (key-place innercolumn (inc row) web-post-tr))) + + ;; Diagonal connections + (for [column (range 0 (dec ncols)) + row (range 0 2)] + (triangle-hulls + (key-place column row web-post-br) + (key-place column (inc row) web-post-tr) + (key-place (inc column) row web-post-bl) + (key-place (inc column) (inc row) web-post-tl))))))) + +(def extra-connectors + (if (true? extra-row) + (apply union + (concat + (for [column (range 3 ncols) + row (range cornerrow lastrow)] + (triangle-hulls + (key-place column row web-post-bl) + (key-place column row web-post-br) + (key-place column (inc row) web-post-tl) + (key-place column (inc row) web-post-tr))) + + (for [column (range 3 (dec ncols)) + row (range cornerrow lastrow)] + (triangle-hulls + (key-place column row web-post-br) + (key-place column (inc row) web-post-tr) + (key-place (inc column) row web-post-bl) + (key-place (inc column) (inc row) web-post-tl))) + + (for [column (range 4 (dec ncols)) + row (range lastrow nrows)] + (triangle-hulls + (key-place (inc column) row web-post-tl) + (key-place column row web-post-tr) + (key-place (inc column) row web-post-bl) + (key-place column row web-post-br))))))) + +;;;;;;;;;;;;;;;;;;; +;; Default Thumb ;; +;;;;;;;;;;;;;;;;;;; (def thumborigin - (map + (key-position 1 cornerrow [(/ mount-width 2) (- (/ mount-height 2)) 0]) + (map + (key-position (+ innercol-offset 1) cornerrow [(/ mount-width 2) (- (/ mount-height 2)) 0]) thumb-offsets)) (defn thumb-tr-place [shape] + (->> shape + (rotate (deg2rad 10) [1 0 0]) + (rotate (deg2rad -23) [0 1 0]) + (rotate (deg2rad 10) [0 0 1]) + (translate thumborigin) + (translate [-12 -16 3]) + )) +(defn thumb-tl-place [shape] + (->> shape + (rotate (deg2rad 10) [1 0 0]) + (rotate (deg2rad -23) [0 1 0]) + (rotate (deg2rad 10) [0 0 1]) + (translate thumborigin) + (translate [-32 -15 -2]))) +(defn thumb-mr-place [shape] + (->> shape + (rotate (deg2rad -6) [1 0 0]) + (rotate (deg2rad -34) [0 1 0]) + (rotate (deg2rad 48) [0 0 1]) + (translate thumborigin) + (translate [-29 -40 -13]) + )) +(defn thumb-ml-place [shape] + (->> shape + (rotate (deg2rad 6) [1 0 0]) + (rotate (deg2rad -34) [0 1 0]) + (rotate (deg2rad 40) [0 0 1]) + (translate thumborigin) + (translate [-51 -25 -12]))) +(defn thumb-br-place [shape] + (->> shape + (rotate (deg2rad -16) [1 0 0]) + (rotate (deg2rad -33) [0 1 0]) + (rotate (deg2rad 54) [0 0 1]) + (translate thumborigin) + (translate [-37.8 -55.3 -25.3]) + )) +(defn thumb-bl-place [shape] + (->> shape + (rotate (deg2rad -4) [1 0 0]) + (rotate (deg2rad -35) [0 1 0]) + (rotate (deg2rad 52) [0 0 1]) + (translate thumborigin) + (translate [-56.3 -43.3 -23.5]) + )) + +(defn thumb-1x-layout [shape] + (union + (thumb-mr-place shape) + (thumb-ml-place shape) + (thumb-br-place shape) + (thumb-bl-place shape))) + +(defn thumb-15x-layout [shape] + (union + (thumb-tr-place shape) + (thumb-tl-place shape))) + +(def thumbcaps + (union + (thumb-1x-layout (sa-cap 1)) + (thumb-15x-layout (rotate (/ π 2) [0 0 1] (sa-cap 1.5))))) + +(def thumb + (union + (thumb-1x-layout (rotate (/ π 2) [0 0 0] single-plate)) + (thumb-tr-place (rotate (/ π 2) [0 0 1] single-plate)) + (thumb-tr-place larger-plate) + (thumb-tl-place (rotate (/ π 2) [0 0 1] single-plate)) + (thumb-tl-place larger-plate-half))) + +(def thumb-post-tr (translate [(- (/ mount-width 2) post-adj) (- (/ mount-height 1.1) post-adj) 0] web-post)) +(def thumb-post-tl (translate [(+ (/ mount-width -2) post-adj) (- (/ mount-height 1.1) post-adj) 0] web-post)) +(def thumb-post-bl (translate [(+ (/ mount-width -2) post-adj) (+ (/ mount-height -1.1) post-adj) 0] web-post)) +(def thumb-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -1.1) post-adj) 0] web-post)) + +(def thumb-connectors + (union + (triangle-hulls ; top two + (thumb-tl-place thumb-post-tr) + (thumb-tl-place web-post-br) + (thumb-tr-place thumb-post-tl) + (thumb-tr-place thumb-post-bl)) + (triangle-hulls ; bottom two on the right + (thumb-br-place web-post-tr) + (thumb-br-place web-post-br) + (thumb-mr-place web-post-tl) + (thumb-mr-place web-post-bl)) + (triangle-hulls ; bottom two on the left + (thumb-bl-place web-post-tr) + (thumb-bl-place web-post-br) + (thumb-ml-place web-post-tl) + (thumb-ml-place web-post-bl)) + (triangle-hulls ; centers of the bottom four + (thumb-br-place web-post-tl) + (thumb-bl-place web-post-bl) + (thumb-br-place web-post-tr) + (thumb-bl-place web-post-br) + (thumb-mr-place web-post-tl) + (thumb-ml-place web-post-bl) + (thumb-mr-place web-post-tr) + (thumb-ml-place web-post-br)) + (triangle-hulls ; top two to the middle two, starting on the left + (thumb-tl-place thumb-post-tl) + (thumb-ml-place web-post-tr) + (thumb-tl-place web-post-bl) + (thumb-ml-place web-post-br) + (thumb-tl-place web-post-br) + (thumb-mr-place web-post-tr) + (thumb-tr-place thumb-post-bl) + (thumb-mr-place web-post-br) + (thumb-tr-place thumb-post-br)) + (triangle-hulls ; top two to the main keyboard, starting on the left + (thumb-tl-place thumb-post-tl) + (key-place (+ innercol-offset 0) cornerrow web-post-bl) + (thumb-tl-place thumb-post-tr) + (key-place (+ innercol-offset 0) cornerrow web-post-br) + (thumb-tr-place thumb-post-tl) + (key-place (+ innercol-offset 1) cornerrow web-post-bl) + (thumb-tr-place thumb-post-tr) + (key-place (+ innercol-offset 1) cornerrow web-post-br) + (key-place (+ innercol-offset 2) lastrow web-post-tl) + (key-place (+ innercol-offset 2) lastrow web-post-bl) + (thumb-tr-place thumb-post-tr) + (key-place (+ innercol-offset 2) lastrow web-post-bl) + (thumb-tr-place thumb-post-br) + (key-place (+ innercol-offset 2) lastrow web-post-br) + (key-place (+ innercol-offset 3) lastrow web-post-bl) + (key-place (+ innercol-offset 2) lastrow web-post-tr) + (key-place (+ innercol-offset 3) lastrow web-post-tl) + (key-place (+ innercol-offset 3) cornerrow web-post-bl) + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) cornerrow web-post-br)) + (triangle-hulls + (key-place (+ innercol-offset 1) cornerrow web-post-br) + (key-place (+ innercol-offset 2) lastrow web-post-tl) + (key-place (+ innercol-offset 2) cornerrow web-post-bl) + (key-place (+ innercol-offset 2) lastrow web-post-tr) + (key-place (+ innercol-offset 2) cornerrow web-post-br) + (key-place (+ innercol-offset 3) cornerrow web-post-bl)) + (if (true? extra-row) + (union + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) lastrow web-post-br) + (key-place (+ innercol-offset 4) lastrow web-post-tl) + (key-place (+ innercol-offset 4) lastrow web-post-bl)) + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) cornerrow web-post-br) + (key-place (+ innercol-offset 4) lastrow web-post-tl) + (key-place (+ innercol-offset 4) cornerrow web-post-bl))) + (union + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) lastrow web-post-br) + (key-place (+ innercol-offset 4) cornerrow web-post-bl)) + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) cornerrow web-post-br) + (key-place (+ innercol-offset 4) cornerrow web-post-bl)))))) + +;;;;;;;;;;;;;;;; +;; Mini Thumb ;; +;;;;;;;;;;;;;;;; + +(defn minithumb-tr-place [shape] (->> shape (rotate (deg2rad 14) [1 0 0]) (rotate (deg2rad -15) [0 1 0]) (rotate (deg2rad 10) [0 0 1]) ; original 10 (translate thumborigin) (translate [-15 -10 5]))) ; original 1.5u (translate [-12 -16 3]) -(defn thumb-tl-place [shape] +(defn minithumb-tl-place [shape] (->> shape (rotate (deg2rad 10) [1 0 0]) (rotate (deg2rad -23) [0 1 0]) (rotate (deg2rad 25) [0 0 1]) ; original 10 (translate thumborigin) (translate [-35 -16 -2]))) ; original 1.5u (translate [-32 -15 -2]))) - - -(defn thumb-mr-place [shape] +(defn minithumb-mr-place [shape] (->> shape (rotate (deg2rad 10) [1 0 0]) (rotate (deg2rad -23) [0 1 0]) (rotate (deg2rad 25) [0 0 1]) (translate thumborigin) (translate [-23 -34 -6]))) -(defn thumb-br-place [shape] +(defn minithumb-br-place [shape] (->> shape (rotate (deg2rad 6) [1 0 0]) (rotate (deg2rad -34) [0 1 0]) (rotate (deg2rad 35) [0 0 1]) (translate thumborigin) (translate [-39 -43 -16]))) -(defn thumb-bl-place [shape] +(defn minithumb-bl-place [shape] (->> shape (rotate (deg2rad 6) [1 0 0]) (rotate (deg2rad -32) [0 1 0]) @@ -356,113 +625,122 @@ (translate thumborigin) (translate [-51 -25 -11.5]))) ; (translate [-51 -25 -12]))) - -(defn thumb-1x-layout [shape] +(defn minithumb-1x-layout [shape] (union - (thumb-mr-place shape) - (thumb-br-place shape) - (thumb-tl-place shape) - (thumb-bl-place shape))) + (minithumb-mr-place shape) + (minithumb-br-place shape) + (minithumb-tl-place shape) + (minithumb-bl-place shape))) -(defn thumb-15x-layout [shape] +(defn minithumb-15x-layout [shape] (union - (thumb-tr-place shape))) + (minithumb-tr-place shape))) -(def larger-plate - (let [plate-height (- (/ (- sa-double-length mount-height) 3) 0.5) - top-plate (->> (cube mount-width plate-height web-thickness) - (translate [0 (/ (+ plate-height mount-height) 2) - (- plate-thickness (/ web-thickness 2))]))] - (union top-plate (mirror [0 1 0] top-plate)))) - -(def thumbcaps +(def minithumbcaps (union - (thumb-1x-layout (sa-cap 1)) - (thumb-15x-layout (rotate (/ π 2) [0 0 1] (sa-cap 1))))) + (minithumb-1x-layout (sa-cap 1)) + (minithumb-15x-layout (rotate (/ π 2) [0 0 1] (sa-cap 1))))) -(def thumb +(def minithumb (union - (thumb-1x-layout single-plate) - (thumb-15x-layout single-plate) - ; (thumb-15x-layout larger-plate) -)) + (minithumb-1x-layout single-plate) + (minithumb-15x-layout single-plate))) -(def thumb-post-tr (translate [(- (/ mount-width 2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) -(def thumb-post-tl (translate [(+ (/ mount-width -2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) -(def thumb-post-bl (translate [(+ (/ mount-width -2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) -(def thumb-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) +(def minithumb-post-tr (translate [(- (/ mount-width 2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) +(def minithumb-post-tl (translate [(+ (/ mount-width -2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post)) +(def minithumb-post-bl (translate [(+ (/ mount-width -2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) +(def minithumb-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post)) -(def thumb-connectors +(def minithumb-connectors (union (triangle-hulls ; top two - (thumb-tl-place web-post-tr) - (thumb-tl-place web-post-br) - (thumb-tr-place thumb-post-tl) - (thumb-tr-place thumb-post-bl)) + (minithumb-tl-place web-post-tr) + (minithumb-tl-place web-post-br) + (minithumb-tr-place minithumb-post-tl) + (minithumb-tr-place minithumb-post-bl)) (triangle-hulls ; bottom two - (thumb-br-place web-post-tr) - (thumb-br-place web-post-br) - (thumb-mr-place web-post-tl) - (thumb-mr-place web-post-bl)) + (minithumb-br-place web-post-tr) + (minithumb-br-place web-post-br) + (minithumb-mr-place web-post-tl) + (minithumb-mr-place web-post-bl)) (triangle-hulls - (thumb-mr-place web-post-tr) - (thumb-mr-place web-post-br) - (thumb-tr-place thumb-post-br)) + (minithumb-mr-place web-post-tr) + (minithumb-mr-place web-post-br) + (minithumb-tr-place minithumb-post-br)) (triangle-hulls ; between top row and bottom row - (thumb-br-place web-post-tl) - (thumb-bl-place web-post-bl) - (thumb-br-place web-post-tr) - (thumb-bl-place web-post-br) - (thumb-mr-place web-post-tl) - (thumb-tl-place web-post-bl) - (thumb-mr-place web-post-tr) - (thumb-tl-place web-post-br) - (thumb-tr-place web-post-bl) - (thumb-mr-place web-post-tr) - (thumb-tr-place web-post-br)) + (minithumb-br-place web-post-tl) + (minithumb-bl-place web-post-bl) + (minithumb-br-place web-post-tr) + (minithumb-bl-place web-post-br) + (minithumb-mr-place web-post-tl) + (minithumb-tl-place web-post-bl) + (minithumb-mr-place web-post-tr) + (minithumb-tl-place web-post-br) + (minithumb-tr-place web-post-bl) + (minithumb-mr-place web-post-tr) + (minithumb-tr-place web-post-br)) (triangle-hulls ; top two to the middle two, starting on the left - (thumb-tl-place web-post-tl) - (thumb-bl-place web-post-tr) - (thumb-tl-place web-post-bl) - (thumb-bl-place web-post-br) - (thumb-mr-place web-post-tr) - (thumb-tl-place web-post-bl) - (thumb-tl-place web-post-br) - (thumb-mr-place web-post-tr)) + (minithumb-tl-place web-post-tl) + (minithumb-bl-place web-post-tr) + (minithumb-tl-place web-post-bl) + (minithumb-bl-place web-post-br) + (minithumb-mr-place web-post-tr) + (minithumb-tl-place web-post-bl) + (minithumb-tl-place web-post-br) + (minithumb-mr-place web-post-tr)) (triangle-hulls ; top two to the main keyboard, starting on the left - (thumb-tl-place web-post-tl) - (key-place 0 cornerrow web-post-bl) - (thumb-tl-place web-post-tr) - (key-place 0 cornerrow web-post-br) - (thumb-tr-place thumb-post-tl) - (key-place 1 cornerrow web-post-bl) - (thumb-tr-place thumb-post-tr) - (key-place 1 cornerrow web-post-br) - (key-place 2 lastrow web-post-tl) - (key-place 2 lastrow web-post-bl) - (thumb-tr-place thumb-post-tr) - (key-place 2 lastrow web-post-bl) - (thumb-tr-place thumb-post-br) - (key-place 2 lastrow web-post-br) - (key-place 3 lastrow web-post-bl) - (key-place 2 lastrow web-post-tr) - (key-place 3 lastrow web-post-tl) - (key-place 3 cornerrow web-post-bl) - (key-place 3 lastrow web-post-tr) - (key-place 3 cornerrow web-post-br) - (key-place 4 cornerrow web-post-bl)) + (minithumb-tl-place web-post-tl) + (key-place (+ innercol-offset 0) cornerrow web-post-bl) + (minithumb-tl-place web-post-tr) + (key-place (+ innercol-offset 0) cornerrow web-post-br) + (minithumb-tr-place minithumb-post-tl) + (key-place (+ innercol-offset 1) cornerrow web-post-bl) + (minithumb-tr-place minithumb-post-tr) + (key-place (+ innercol-offset 1) cornerrow web-post-br) + (key-place (+ innercol-offset 2) lastrow web-post-tl) + (key-place (+ innercol-offset 2) lastrow web-post-bl) + (minithumb-tr-place minithumb-post-tr) + (key-place (+ innercol-offset 2) lastrow web-post-bl) + (minithumb-tr-place minithumb-post-br) + (key-place (+ innercol-offset 2) lastrow web-post-br) + (key-place (+ innercol-offset 3) lastrow web-post-bl) + (key-place (+ innercol-offset 2) lastrow web-post-tr) + (key-place (+ innercol-offset 3) lastrow web-post-tl) + (key-place (+ innercol-offset 3) cornerrow web-post-bl) + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) cornerrow web-post-br) + ) (triangle-hulls - (key-place 1 cornerrow web-post-br) - (key-place 2 lastrow web-post-tl) - (key-place 2 cornerrow web-post-bl) - (key-place 2 lastrow web-post-tr) - (key-place 2 cornerrow web-post-br) - (key-place 3 cornerrow web-post-bl)) - (triangle-hulls - (key-place 3 lastrow web-post-tr) - (key-place 3 lastrow web-post-br) - (key-place 3 lastrow web-post-tr) - (key-place 4 cornerrow web-post-bl)))) + (key-place (+ innercol-offset 1) cornerrow web-post-br) + (key-place (+ innercol-offset 2) lastrow web-post-tl) + (key-place (+ innercol-offset 2) cornerrow web-post-bl) + (key-place (+ innercol-offset 2) lastrow web-post-tr) + (key-place (+ innercol-offset 2) cornerrow web-post-br) + (key-place (+ innercol-offset 3) cornerrow web-post-bl)) + (if (true? extra-row) + (union + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) lastrow web-post-br) + (key-place (+ innercol-offset 4) lastrow web-post-tl) + (key-place (+ innercol-offset 4) lastrow web-post-bl)) + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) cornerrow web-post-br) + (key-place (+ innercol-offset 4) lastrow web-post-tl) + (key-place (+ innercol-offset 4) cornerrow web-post-bl))) + (union + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) lastrow web-post-br) + (key-place (+ innercol-offset 4) cornerrow web-post-bl)) + (triangle-hulls + (key-place (+ innercol-offset 3) lastrow web-post-tr) + (key-place (+ innercol-offset 3) cornerrow web-post-br) + (key-place (+ innercol-offset 4) cornerrow web-post-bl)))))) + +(if (true? mini-thumb) (def thumb-type minithumb) (def thumb-type thumb)) +(if (true? mini-thumb) (def thumb-connector-type minithumb-connectors) (def thumb-connector-type thumb-connectors)) ;;;;;;;;;; ;; Case ;; @@ -476,11 +754,11 @@ (defn bottom-hull [& p] (hull p (bottom 0.001 p))) -(def left-wall-x-offset 5) ; original 10 -(def left-wall-z-offset 3) ; original 3 +(def left-wall-x-offset 8) +(def left-wall-z-offset 3) (defn left-key-position [row direction] - (map - (key-position 0 row [(* mount-width -0.5) (* direction mount-height 0.5) 0]) [left-wall-x-offset 0 left-wall-z-offset])) + (map - (key-position 0 row [(* mount-width -0.5) (* direction mount-height 0.5) 0]) [left-wall-x-offset 0 left-wall-z-offset]) ) (defn left-key-place [row direction shape] (translate (left-key-position row direction) shape)) @@ -511,42 +789,120 @@ (partial key-place x2 y2) dx2 dy2 post2)) (def right-wall - (let [tr (if (true? pinky-15u) wide-post-tr web-post-tr) - br (if (true? pinky-15u) wide-post-br web-post-br)] - (union (key-wall-brace lastcol 0 0 1 tr lastcol 0 1 0 tr) - (for [y (range 0 lastrow)] (key-wall-brace lastcol y 1 0 tr lastcol y 1 0 br)) - (for [y (range 1 lastrow)] (key-wall-brace lastcol (dec y) 1 0 br lastcol y 1 0 tr)) - (key-wall-brace lastcol cornerrow 0 -1 br lastcol cornerrow 1 0 br)))) + (if (true? pinky-15u) + (union + ; corner between the right wall and back wall + (if (> first-15u-row 0) + (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 1 0 web-post-tr) + (union (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 0 1 wide-post-tr) + (key-wall-brace lastcol 0 0 1 wide-post-tr lastcol 0 1 0 wide-post-tr))) + ; corner between the right wall and front wall + (if (= last-15u-row extra-cornerrow) + (union (key-wall-brace lastcol extra-cornerrow 0 -1 web-post-br lastcol extra-cornerrow 0 -1 wide-post-br) + (key-wall-brace lastcol extra-cornerrow 0 -1 wide-post-br lastcol extra-cornerrow 1 0 wide-post-br)) + (key-wall-brace lastcol extra-cornerrow 0 -1 web-post-br lastcol extra-cornerrow 1 0 web-post-br)) -(def case-walls + (if (>= first-15u-row 2) + (for [y (range 0 (dec first-15u-row))] + (union (key-wall-brace lastcol y 1 0 web-post-tr lastcol y 1 0 web-post-br) + (key-wall-brace lastcol y 1 0 web-post-br lastcol (inc y) 1 0 web-post-tr)))) + + (if (>= first-15u-row 1) + (for [y (range (dec first-15u-row) first-15u-row)] (key-wall-brace lastcol y 1 0 web-post-tr lastcol (inc y) 1 0 wide-post-tr))) + + (for [y (range first-15u-row (inc last-15u-row))] (key-wall-brace lastcol y 1 0 wide-post-tr lastcol y 1 0 wide-post-br)) + (for [y (range first-15u-row last-15u-row)] (key-wall-brace lastcol (inc y) 1 0 wide-post-tr lastcol y 1 0 wide-post-br)) + + (if (<= last-15u-row (- extra-cornerrow 1)) + (for [y (range last-15u-row (inc last-15u-row))] (key-wall-brace lastcol y 1 0 wide-post-br lastcol (inc y) 1 0 web-post-br))) + + (if (<= last-15u-row (- extra-cornerrow 2)) + (for [y (range (inc last-15u-row) extra-cornerrow)] + (union (key-wall-brace lastcol y 1 0 web-post-br lastcol (inc y) 1 0 web-post-tr) + (key-wall-brace lastcol (inc y) 1 0 web-post-tr lastcol (inc y) 1 0 web-post-br)))) + ) + (union (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 1 0 web-post-tr) + (if (true? extra-row) + (union (for [y (range 0 (inc lastrow))] (key-wall-brace lastcol y 1 0 web-post-tr lastcol y 1 0 web-post-br)) + (for [y (range 1 (inc lastrow))] (key-wall-brace lastcol (dec y) 1 0 web-post-br lastcol y 1 0 web-post-tr))) + (union (for [y (range 0 lastrow)] (key-wall-brace lastcol y 1 0 web-post-tr lastcol y 1 0 web-post-br)) + (for [y (range 1 lastrow)] (key-wall-brace lastcol (dec y) 1 0 web-post-br lastcol y 1 0 web-post-tr))) + ) + (key-wall-brace lastcol extra-cornerrow 0 -1 web-post-br lastcol extra-cornerrow 1 0 web-post-br) + ))) + +(def mini-thumb-wall (union - right-wall - ; back wall - (for [x (range 0 ncols)] (key-wall-brace x 0 0 1 web-post-tl x 0 0 1 web-post-tr)) - (for [x (range 1 ncols)] (key-wall-brace x 0 0 1 web-post-tl (dec x) 0 0 1 web-post-tr)) + ; thumb walls + (wall-brace minithumb-mr-place 0 -1 web-post-br minithumb-tr-place 0 -1 minithumb-post-br) + (wall-brace minithumb-mr-place 0 -1 web-post-br minithumb-mr-place 0 -1 web-post-bl) + (wall-brace minithumb-br-place 0 -1 web-post-br minithumb-br-place 0 -1 web-post-bl) + (wall-brace minithumb-bl-place 0 1 web-post-tr minithumb-bl-place 0 1 web-post-tl) + (wall-brace minithumb-br-place -1 0 web-post-tl minithumb-br-place -1 0 web-post-bl) + (wall-brace minithumb-bl-place -1 0 web-post-tl minithumb-bl-place -1 0 web-post-bl) + ; minithumb corners + (wall-brace minithumb-br-place -1 0 web-post-bl minithumb-br-place 0 -1 web-post-bl) + (wall-brace minithumb-bl-place -1 0 web-post-tl minithumb-bl-place 0 1 web-post-tl) + ; minithumb tweeners + (wall-brace minithumb-mr-place 0 -1 web-post-bl minithumb-br-place 0 -1 web-post-br) + (wall-brace minithumb-bl-place -1 0 web-post-bl minithumb-br-place -1 0 web-post-tl) + (wall-brace minithumb-tr-place 0 -1 minithumb-post-br (partial key-place (+ innercol-offset 3) lastrow) 0 -1 web-post-bl) + ; clunky bit on the top left minithumb connection (normal connectors don't work well) + (bottom-hull + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate2 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate3 -1 0) web-post)) + (minithumb-bl-place (translate (wall-locate2 -0.3 1) web-post-tr)) + (minithumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr))) + (hull + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate2 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate3 -1 0) web-post)) + (minithumb-bl-place (translate (wall-locate2 -0.3 1) web-post-tr)) + (minithumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr)) + (minithumb-tl-place web-post-tl)) + (hull + (left-key-place (- cornerrow innercol-offset) -1 web-post) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate1 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate2 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate3 -1 0) web-post)) + (minithumb-tl-place web-post-tl)) + (hull + (left-key-place (- cornerrow innercol-offset) -1 web-post) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate1 -1 0) web-post)) + (key-place 0 (- cornerrow innercol-offset) web-post-bl) + (minithumb-tl-place web-post-tl)) + (hull + (minithumb-bl-place web-post-tr) + (minithumb-bl-place (translate (wall-locate1 -0.3 1) web-post-tr)) + (minithumb-bl-place (translate (wall-locate2 -0.3 1) web-post-tr)) + (minithumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr)) + (minithumb-tl-place web-post-tl)) + ; connectors below the inner column to the thumb & second column + (if (true? inner-column) + (union + (hull + (key-place 0 (dec cornerrow) web-post-bl) + (key-place 0 (dec cornerrow) web-post-br) + (key-place 0 cornerrow web-post-tr)) + (hull + (key-place 0 cornerrow web-post-tr) + (key-place 1 cornerrow web-post-tl) + (key-place 1 cornerrow web-post-bl)) + (hull + (key-place 0 (dec cornerrow) web-post-bl) + (key-place 0 cornerrow web-post-tr) + (key-place 1 cornerrow web-post-bl)) + (hull + (key-place 0 (dec cornerrow) web-post-bl) + (key-place 1 cornerrow web-post-bl) + (minithumb-tl-place minithumb-post-tl)))))) - ; left wall - (for [y (range 0 lastrow)] (union (wall-brace (partial left-key-place y 1) -1 0 web-post (partial left-key-place y -1) -1 0 web-post) - (hull (key-place 0 y web-post-tl) - (key-place 0 y web-post-bl) - (left-key-place y 1 web-post) - (left-key-place y -1 web-post)))) - (for [y (range 1 lastrow)] (union (wall-brace (partial left-key-place (dec y) -1) -1 0 web-post (partial left-key-place y 1) -1 0 web-post) - (hull (key-place 0 y web-post-tl) - (key-place 0 (dec y) web-post-bl) - (left-key-place y 1 web-post) - (left-key-place (dec y) -1 web-post)))) - (wall-brace (partial key-place 0 0) 0 1 web-post-tl (partial left-key-place 0 1) 0 1 web-post) - (wall-brace (partial left-key-place 0 1) 0 1 web-post (partial left-key-place 0 1) -1 0 web-post) - ; front wall - (key-wall-brace 3 lastrow 0 -1 web-post-bl 3 lastrow 0.5 -1 web-post-br) - (key-wall-brace 3 lastrow 0.5 -1 web-post-br 4 cornerrow 0.5 -1 web-post-bl) - (for [x (range 4 ncols)] (key-wall-brace x cornerrow 0 -1 web-post-bl x cornerrow 0 -1 web-post-br)) ; TODO fix extra wall - (for [x (range 5 ncols)] (key-wall-brace x cornerrow 0 -1 web-post-bl (dec x) cornerrow 0 -1 web-post-br)) +(def default-thumb-wall + (union ; thumb walls (wall-brace thumb-mr-place 0 -1 web-post-br thumb-tr-place 0 -1 thumb-post-br) (wall-brace thumb-mr-place 0 -1 web-post-br thumb-mr-place 0 -1 web-post-bl) (wall-brace thumb-br-place 0 -1 web-post-br thumb-br-place 0 -1 web-post-bl) + (wall-brace thumb-ml-place -0.3 1 web-post-tr thumb-ml-place 0 1 web-post-tl) (wall-brace thumb-bl-place 0 1 web-post-tr thumb-bl-place 0 1 web-post-tl) (wall-brace thumb-br-place -1 0 web-post-tl thumb-br-place -1 0 web-post-bl) (wall-brace thumb-bl-place -1 0 web-post-tl thumb-bl-place -1 0 web-post-bl) @@ -555,85 +911,111 @@ (wall-brace thumb-bl-place -1 0 web-post-tl thumb-bl-place 0 1 web-post-tl) ; thumb tweeners (wall-brace thumb-mr-place 0 -1 web-post-bl thumb-br-place 0 -1 web-post-br) + (wall-brace thumb-ml-place 0 1 web-post-tl thumb-bl-place 0 1 web-post-tr) (wall-brace thumb-bl-place -1 0 web-post-bl thumb-br-place -1 0 web-post-tl) - (wall-brace thumb-tr-place 0 -1 thumb-post-br (partial key-place 3 lastrow) 0 -1 web-post-bl) + (wall-brace thumb-tr-place 0 -1 thumb-post-br (partial key-place (+ innercol-offset 3) lastrow) 0 -1 web-post-bl) ; clunky bit on the top left thumb connection (normal connectors don't work well) (bottom-hull - (left-key-place cornerrow -1 (translate (wall-locate2 -1 0) web-post)) - (left-key-place cornerrow -1 (translate (wall-locate3 -1 0) web-post)) - (thumb-bl-place (translate (wall-locate2 -0.3 1) web-post-tr)) - (thumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr))) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate2 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate3 -1 0) web-post)) + (thumb-ml-place (translate (wall-locate2 -0.3 1) web-post-tr)) + (thumb-ml-place (translate (wall-locate3 -0.3 1) web-post-tr))) (hull - (left-key-place cornerrow -1 (translate (wall-locate2 -1 0) web-post)) - (left-key-place cornerrow -1 (translate (wall-locate3 -1 0) web-post)) - (thumb-bl-place (translate (wall-locate2 -0.3 1) web-post-tr)) - (thumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr)) - (thumb-tl-place web-post-tl)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate2 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate3 -1 0) web-post)) + (thumb-ml-place (translate (wall-locate2 -0.3 1) web-post-tr)) + (thumb-ml-place (translate (wall-locate3 -0.3 1) web-post-tr)) + (thumb-tl-place thumb-post-tl)) (hull - (left-key-place cornerrow -1 web-post) - (left-key-place cornerrow -1 (translate (wall-locate1 -1 0) web-post)) - (left-key-place cornerrow -1 (translate (wall-locate2 -1 0) web-post)) - (left-key-place cornerrow -1 (translate (wall-locate3 -1 0) web-post)) - (thumb-tl-place web-post-tl)) + (left-key-place (- cornerrow innercol-offset) -1 web-post) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate1 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate2 -1 0) web-post)) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate3 -1 0) web-post)) + (thumb-tl-place thumb-post-tl)) (hull - (left-key-place cornerrow -1 web-post) - (left-key-place cornerrow -1 (translate (wall-locate1 -1 0) web-post)) - (key-place 0 cornerrow web-post-bl) - (thumb-tl-place web-post-tl)) + (left-key-place (- cornerrow innercol-offset) -1 web-post) + (left-key-place (- cornerrow innercol-offset) -1 (translate (wall-locate1 -1 0) web-post)) + (key-place 0 (- cornerrow innercol-offset) web-post-bl) + (key-place 0 (- cornerrow innercol-offset) (translate (wall-locate1 -1 0) web-post-bl)) + (thumb-tl-place thumb-post-tl)) + ; connectors below the inner column to the thumb & second column + (if (true? inner-column) + (union + (hull + (key-place 0 (dec cornerrow) web-post-bl) + (key-place 0 (dec cornerrow) web-post-br) + (key-place 0 cornerrow web-post-tr)) + (hull + (key-place 0 cornerrow web-post-tr) + (key-place 1 cornerrow web-post-tl) + (key-place 1 cornerrow web-post-bl)) + (hull + (key-place 0 (dec cornerrow) web-post-bl) + (key-place 0 cornerrow web-post-tr) + (key-place 1 cornerrow web-post-bl)) + (hull + (key-place 0 (dec cornerrow) web-post-bl) + (key-place 1 cornerrow web-post-bl) + (thumb-tl-place thumb-post-tl)))) (hull - (thumb-bl-place web-post-tr) - (thumb-bl-place (translate (wall-locate1 -0.3 1) web-post-tr)) - (thumb-bl-place (translate (wall-locate2 -0.3 1) web-post-tr)) - (thumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr)) - (thumb-tl-place web-post-tl)))) + (thumb-ml-place web-post-tr) + (thumb-ml-place (translate (wall-locate1 -0.3 1) web-post-tr)) + (thumb-ml-place (translate (wall-locate2 -0.3 1) web-post-tr)) + (thumb-ml-place (translate (wall-locate3 -0.3 1) web-post-tr)) + (thumb-tl-place thumb-post-tl)))) +(if (true? mini-thumb) (def thumb-wall-type mini-thumb-wall) (def thumb-wall-type default-thumb-wall)) + +(def case-walls + (union + thumb-wall-type + right-wall + ; back wall + (for [x (range 0 ncols)] (key-wall-brace x 0 0 1 web-post-tl x 0 0 1 web-post-tr)) + (for [x (range 1 ncols)] (key-wall-brace x 0 0 1 web-post-tl (dec x) 0 0 1 web-post-tr)) + ; left wall + (for [y (range 0 (- lastrow innercol-offset))] (union (wall-brace (partial left-key-place y 1) -1 0 web-post (partial left-key-place y -1) -1 0 web-post) + (hull (key-place 0 y web-post-tl) + (key-place 0 y web-post-bl) + (left-key-place y 1 web-post) + (left-key-place y -1 web-post)))) + (for [y (range 1 (- lastrow innercol-offset))] (union + (wall-brace (partial left-key-place (dec y) -1) -1 0 web-post (partial left-key-place y 1) -1 0 web-post) + (hull (key-place 0 y web-post-tl) + (key-place 0 (dec y) web-post-bl) + (left-key-place y 1 web-post) + (left-key-place (dec y) -1 web-post) + ))) + (wall-brace (partial key-place 0 0) 0 1 web-post-tl (partial left-key-place 0 1) 0 1 web-post) + (wall-brace (partial left-key-place 0 1) 0 1 web-post (partial left-key-place 0 1) -1 0 web-post) + ; front wall + (key-wall-brace (+ innercol-offset 3) lastrow 0 -1 web-post-bl (+ innercol-offset 3) lastrow 0 -1 web-post-br) + (key-wall-brace (+ innercol-offset 3) lastrow 0 -1 web-post-br (+ innercol-offset 4) extra-cornerrow 0 -1 web-post-bl) + (for [x (range (+ innercol-offset 4) ncols)] (key-wall-brace x extra-cornerrow 0 -1 web-post-bl x extra-cornerrow 0 -1 web-post-br)) + (for [x (range (+ innercol-offset 5) ncols)] (key-wall-brace x extra-cornerrow 0 -1 web-post-bl (dec x) extra-cornerrow 0 -1 web-post-br)) + )) + +; Offsets for the controller/trrs holder cutout +(case nrows + 4 (def holder-offset -3.5) + 5 (def holder-offset 0) + 6 (def holder-offset 2.2) + ) +(if (and (false? inner-column) (= nrows 6)) + (def holder-offset (- holder-offset 1)) + ) + +; Cutout for controller/trrs jack holder (def usb-holder-ref (key-position 0 0 (map - (wall-locate2 0 -1) [0 (/ mount-height 2) 0]))) +(def usb-holder-position (map + [(+ 18.8 holder-offset) 18.7 1.3] [(first usb-holder-ref) (second usb-holder-ref) 2])) +(def usb-holder-cube (cube 28.666 30 12.6)) +(def usb-holder-space (translate (map + usb-holder-position [-1.5 (* -1 wall-thickness) 3]) usb-holder-cube)) -(def usb-holder-position (map + [17 19.3 0] [(first usb-holder-ref) (second usb-holder-ref) 2])) -(def usb-holder-cube (cube 15 12 2)) -(def usb-holder-space (translate (map + usb-holder-position [0 (* -1 wall-thickness) 1]) usb-holder-cube)) -(def usb-holder-holder (translate usb-holder-position (cube 19 12 4))) - -(def usb-jack (translate (map + usb-holder-position [0 10 3]) (cube 8.1 20 3.1))) - -(def pro-micro-position (map + (key-position 0 1 (wall-locate3 -1 0)) [-6 2 -15])) -(def pro-micro-space-size [4 10 12]) ; z has no wall; -(def pro-micro-wall-thickness 2) -(def pro-micro-holder-size [(+ pro-micro-wall-thickness (first pro-micro-space-size)) (+ pro-micro-wall-thickness (second pro-micro-space-size)) (last pro-micro-space-size)]) -(def pro-micro-space - (->> (cube (first pro-micro-space-size) (second pro-micro-space-size) (last pro-micro-space-size)) - (translate [(- (first pro-micro-position) (/ pro-micro-wall-thickness 2)) (- (second pro-micro-position) (/ pro-micro-wall-thickness 2)) (last pro-micro-position)]))) -(def pro-micro-holder - (difference - (->> (cube (first pro-micro-holder-size) (second pro-micro-holder-size) (last pro-micro-holder-size)) - (translate [(first pro-micro-position) (second pro-micro-position) (last pro-micro-position)])) - pro-micro-space)) - -(def trrs-holder-size [6.2 10 2]) ; trrs jack PJ-320A -(def trrs-holder-hole-size [6.2 10 6]) ; trrs jack PJ-320A -(def trrs-holder-position (map + usb-holder-position [-13.6 0 0])) -(def trrs-holder-thickness 2) -(def trrs-holder-thickness-2x (* 2 trrs-holder-thickness)) -(def trrs-holder - (union - (->> (cube (+ (first trrs-holder-size) trrs-holder-thickness-2x) (+ trrs-holder-thickness (second trrs-holder-size)) (+ (last trrs-holder-size) trrs-holder-thickness)) - (translate [(first trrs-holder-position) (second trrs-holder-position) (/ (+ (last trrs-holder-size) trrs-holder-thickness) 2)])))) -(def trrs-holder-hole - (union - - ; circle trrs hole - (->> - (->> (binding [*fn* 30] (cylinder 2.55 20))) ; 5mm trrs jack - (rotate (deg2rad 90) [1 0 0]) - (translate [(first trrs-holder-position) (+ (second trrs-holder-position) (/ (+ (second trrs-holder-size) trrs-holder-thickness) 2)) (+ 3 (/ (+ (last trrs-holder-size) trrs-holder-thickness) 2))])) ;1.5 padding - - ; rectangular trrs holder - (->> (apply cube trrs-holder-hole-size) (translate [(first trrs-holder-position) (+ (/ trrs-holder-thickness -2) (second trrs-holder-position)) (+ (/ (last trrs-holder-hole-size) 2) trrs-holder-thickness)])))) - +; Screw insert definition & position (defn screw-insert-shape [bottom-radius top-radius height] (union (->> (binding [*fn* 30] - (cylinder [bottom-radius top-radius] height))) + (cylinder [bottom-radius top-radius] height))) (translate [0 0 (/ height 2)] (->> (binding [*fn* 30] (sphere top-radius)))))) (defn screw-insert [column row bottom-radius top-radius height offset] @@ -642,77 +1024,93 @@ shift-up (and (not (or shift-right shift-left)) (= row 0)) shift-down (and (not (or shift-right shift-left)) (>= row lastrow)) position (if shift-up (key-position column row (map + (wall-locate2 0 1) [0 (/ mount-height 2) 0])) - (if shift-down (key-position column row (map - (wall-locate2 0 -1) [0 (/ mount-height 2) 0])) - (if shift-left (map + (left-key-position row 0) (wall-locate3 -1 0)) - (key-position column row (map + (wall-locate2 1 0) [(/ mount-width 2) 0 0])))))] + (if shift-down (key-position column row (map - (wall-locate2 0 -2.5) [0 (/ mount-height 2) 0])) + (if shift-left (map + (left-key-position row 0) (wall-locate3 -1 0)) + (key-position column row (map + (wall-locate2 1 0) [(/ mount-width 2) 0 0])))))] (->> (screw-insert-shape bottom-radius top-radius height) (translate (map + offset [(first position) (second position) (/ height 2)]))))) (defn screw-insert-all-shapes [bottom-radius top-radius height] - (union (screw-insert 0 0 bottom-radius top-radius height [11 10 0]) - (screw-insert 0 lastrow bottom-radius top-radius height [0 0 0]) - ; (screw-insert lastcol lastrow bottom-radius top-radius height [-5 13 0]) - ; (screw-insert lastcol 0 bottom-radius top-radius height [-3 6 0]) - (screw-insert lastcol lastrow bottom-radius top-radius height [0 12 0]) - (screw-insert lastcol 0 bottom-radius top-radius height [0 7 0]) - (screw-insert 1 lastrow bottom-radius top-radius height [0 -16 0]))) + (union (screw-insert 0 0 bottom-radius top-radius height [7 6.5 0]) + (screw-insert 0 lastrow bottom-radius top-radius height [9 -6.5 0]) + (screw-insert lastcol lastrow bottom-radius top-radius height [7 14 0]) + (screw-insert lastcol 0 bottom-radius top-radius height [1 7 0]) + (screw-insert 2 lastrow bottom-radius top-radius height [15 3.2 0]))) ; Hole Depth Y: 4.4 (def screw-insert-height 4) ; Hole Diameter C: 4.1-4.4 -(def screw-insert-bottom-radius (/ 4.4 2)) -(def screw-insert-top-radius (/ 4.4 2)) +(def screw-insert-bottom-radius (/ 4.0 2)) +(def screw-insert-top-radius (/ 3.9 2)) (def screw-insert-holes (screw-insert-all-shapes screw-insert-bottom-radius screw-insert-top-radius screw-insert-height)) ; Wall Thickness W:\t1.65 (def screw-insert-outers (screw-insert-all-shapes (+ screw-insert-bottom-radius 1.65) (+ screw-insert-top-radius 1.65) (+ screw-insert-height 1.5))) (def screw-insert-screw-holes (screw-insert-all-shapes 1.7 1.7 350)) +; Connectors between outer column and right wall when 1.5u keys are used (def pinky-connectors - (apply union - (concat - ;; Row connections - (for [row (range 0 lastrow)] - (triangle-hulls - (key-place lastcol row web-post-tr) - (key-place lastcol row wide-post-tr) - (key-place lastcol row web-post-br) - (key-place lastcol row wide-post-br))) + (if (true? pinky-15u) + (apply union + (concat + ;; Row connections + (for [row (range first-15u-row (inc last-15u-row))] + (triangle-hulls + (key-place lastcol row web-post-tr) + (key-place lastcol row wide-post-tr) + (key-place lastcol row web-post-br) + (key-place lastcol row wide-post-br))) + (if-not (= last-15u-row extra-cornerrow) (for [row (range last-15u-row (inc last-15u-row))] + (triangle-hulls + (key-place lastcol (inc row) web-post-tr) + (key-place lastcol row wide-post-br) + (key-place lastcol (inc row) web-post-br)))) + (if-not (= first-15u-row 0) (for [row (range (dec first-15u-row) first-15u-row)] + (triangle-hulls + (key-place lastcol row web-post-tr) + (key-place lastcol (inc row) wide-post-tr) + (key-place lastcol row web-post-br)))) - ;; Column connections - (for [row (range 0 cornerrow)] - (triangle-hulls - (key-place lastcol row web-post-br) - (key-place lastcol row wide-post-br) - (key-place lastcol (inc row) web-post-tr) - (key-place lastcol (inc row) wide-post-tr))) - ;; -))) - -(def pinky-walls - (union - (key-wall-brace lastcol cornerrow 0 -1 web-post-br lastcol cornerrow 0 -1 wide-post-br) - (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 0 1 wide-post-tr))) + ;; Column connections + (for [row (range first-15u-row last-15u-row)] + (triangle-hulls + (key-place lastcol row web-post-br) + (key-place lastcol row wide-post-br) + (key-place lastcol (inc row) web-post-tr) + (key-place lastcol (inc row) wide-post-tr))) + (if-not (= last-15u-row extra-cornerrow) (for [row (range last-15u-row (inc last-15u-row))] + (triangle-hulls + (key-place lastcol row web-post-br) + (key-place lastcol row wide-post-br) + (key-place lastcol (inc row) web-post-tr)))) + (if-not (= first-15u-row 0) (for [row (range (dec first-15u-row) first-15u-row)] + (triangle-hulls + (key-place lastcol row web-post-br) + (key-place lastcol (inc row) wide-post-tr) + (key-place lastcol (inc row) web-post-tr)))) +)))) (def model-right (difference (union key-holes + key-holes-inner pinky-connectors - pinky-walls + extra-connectors connectors - thumb - thumb-connectors + inner-connectors + thumb-type + thumb-connector-type (difference (union case-walls screw-insert-outers - pro-micro-holder - usb-holder-holder - trrs-holder) + ) usb-holder-space - usb-jack - trrs-holder-hole - screw-insert-holes)) - (translate [0 0 -20] (cube 350 350 40)))) + screw-insert-holes) +; thumbcaps +; caps + ) + (translate [0 0 -20] (cube 350 350 40)) + )) (spit "things/right.scad" (write-scad model-right)) @@ -722,31 +1120,32 @@ (spit "things/right-test.scad" (write-scad - (difference - (union - key-holes - pinky-connectors - pinky-walls - connectors - thumb - thumb-connectors - case-walls - thumbcaps - caps) - - (translate [0 0 -20] (cube 350 350 40))))) + (union + key-holes + key-holes-inner + connectors + inner-connectors + thumb + thumb-connectors + case-walls + thumbcaps + caps + ))) (spit "things/right-plate.scad" (write-scad (cut (translate [0 0 -0.1] (difference (union case-walls - pinky-walls screw-insert-outers) - (translate [0 0 -10] screw-insert-screw-holes)))))) + (translate [0 0 -10] screw-insert-screw-holes)))) -(spit "things/test.scad" - (write-scad - (difference trrs-holder trrs-holder-hole))) + )) -(defn -main [dum] 1) ; dummy to make it easier to batch +;(spit "things/test.scad" +; (write-scad +; )) + + + +(defn -main [dum] 1) ; dummy to make it easier to batch \ No newline at end of file