diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj index 0dd9c89..67c2bc7 100644 --- a/src/dactyl_keyboard/dactyl.clj +++ b/src/dactyl_keyboard/dactyl.clj @@ -5,7 +5,6 @@ [scad-clj.model :refer :all] [unicode-math.core :refer :all])) - (defn deg2rad [degrees] (* (/ degrees 180) pi)) @@ -26,18 +25,18 @@ ; (def column-style :fixed) (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])) + (= 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 4) ; 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 -15) ; length of the first downward-sloping part of the wall (negative) +(def wall-z-offset -5) ; original=-15 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 @@ -179,20 +178,19 @@ (rotate-x-fn (* α (- centerrow row))) (translate-fn [0 0 (+ row-radius (nth fixed-z column))]) (rotate-y-fn fixed-tenting) - (translate-fn [0 (second (column-offset column)) 0]) - )] + (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])))) (defn key-place [column row shape] (apply-key-geometry translate - (fn [angle obj] (rotate angle [1 0 0] obj)) - (fn [angle obj] (rotate angle [0 1 0] obj)) - column row shape)) + (fn [angle obj] (rotate angle [1 0 0] obj)) + (fn [angle obj] (rotate angle [0 1 0] obj)) + column row shape)) (defn rotate-around-x [angle position] (mmul @@ -211,7 +209,6 @@ (defn key-position [column row position] (apply-key-geometry (partial map +) rotate-around-x rotate-around-y column row position)) - (def key-holes (apply union (for [column columns @@ -290,7 +287,7 @@ (def thumborigin (map + (key-position 1 cornerrow [(/ mount-width 2) (- (/ mount-height 2)) 0]) - thumb-offsets)) + thumb-offsets)) ; (pr thumborigin) (defn thumb-tr-place [shape] @@ -300,10 +297,9 @@ ; (rotate (deg2rad -3) [0 0 1]) (rotate (deg2rad 10) [1 0 0]) (rotate (deg2rad -23) [0 1 0]) - (rotate (deg2rad 10) [0 0 1]) + (rotate (deg2rad 10) [0 0 1]) ; original 10 (translate thumborigin) - (translate [-12 -16 3]) - )) + (translate [-12 -12 3]))) ; original 1.5u (translate [-12 -16 3]) (defn thumb-tl-place [shape] (->> shape ; (rotate (deg2rad 10) [1 0 0]) @@ -311,17 +307,18 @@ ; (rotate (deg2rad -3) [0 0 1]) (rotate (deg2rad 10) [1 0 0]) (rotate (deg2rad -23) [0 1 0]) - (rotate (deg2rad 10) [0 0 1]) + (rotate (deg2rad 25) [0 0 1]) ; original 10 (translate thumborigin) - (translate [-32 -15 -2]))) + (translate [-35 -16 -2]))) ; original 1.5u (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]) + (rotate (deg2rad 10) [1 0 0]) + (rotate (deg2rad -23) [0 1 0]) + (rotate (deg2rad 25) [0 0 1]) (translate thumborigin) - (translate [-29 -40 -13]) - )) + (translate [-21 -36 -10]))) (defn thumb-ml-place [shape] (->> shape (rotate (deg2rad 6) [1 0 0]) @@ -331,25 +328,24 @@ (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]) + (rotate (deg2rad 6) [1 0 0]) + (rotate (deg2rad -34) [0 1 0]) + (rotate (deg2rad 35) [0 0 1]) (translate thumborigin) - (translate [-37.8 -55.3 -25.3]) - )) + (translate [-36 -45 -19]))) (defn thumb-bl-place [shape] (->> shape - (rotate (deg2rad -4) [1 0 0]) - (rotate (deg2rad -35) [0 1 0]) - (rotate (deg2rad 52) [0 0 1]) + (rotate (deg2rad 6) [1 0 0]) + (rotate (deg2rad -34) [0 1 0]) + (rotate (deg2rad 35) [0 0 1]) (translate thumborigin) - (translate [-56.3 -43.3 -23.5]) - )) + (translate [-51 -25 -12]))) ; (translate [-51 -25 -12]))) + (defn thumb-1x-layout [shape] (union (thumb-mr-place shape) - (thumb-ml-place shape) + ;(thumb-ml-place shape) (thumb-br-place shape) (thumb-bl-place shape))) @@ -362,100 +358,101 @@ (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))])) - ] + (- plate-thickness (/ web-thickness 2))]))] (union top-plate (mirror [0 1 0] top-plate)))) (def thumbcaps (union (thumb-1x-layout (sa-cap 1)) - (thumb-15x-layout (rotate (/ π 2) [0 0 1] (sa-cap 1.5))))) - + (thumb-15x-layout (rotate (/ π 2) [0 0 1] (sa-cap 1))))) (def thumb (union (thumb-1x-layout single-plate) (thumb-15x-layout single-plate) - (thumb-15x-layout single-plate) - )) + (thumb-15x-layout single-plate))) -(def thumb-post-tr (translate [(- (/ mount-width 2) post-adj) (- (/ mount-height 1.15) post-adj) 0] web-post)) -(def thumb-post-tl (translate [(+ (/ mount-width -2) post-adj) (- (/ mount-height 1.15) post-adj) 0] web-post)) -(def thumb-post-bl (translate [(+ (/ mount-width -2) post-adj) (+ (/ mount-height -1.15) post-adj) 0] web-post)) -(def thumb-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -1.15) post-adj) 0] web-post)) +(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 thumb-connectors (union - (triangle-hulls ; top two - (thumb-tl-place thumb-post-tr) - (thumb-tl-place thumb-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 thumb-post-bl) - (thumb-ml-place web-post-br) - (thumb-tl-place thumb-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 0 cornerrow web-post-bl) - (thumb-tl-place thumb-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)) - (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)) - )) + (triangle-hulls ; top two + (thumb-tl-place thumb-post-tr) + (thumb-tl-place thumb-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 ; tr, mr and wall + (thumb-mr-place web-post-tr) + (thumb-mr-place web-post-br) + (thumb-tr-place thumb-post-br)) + + ; (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-mr-place web-post-tr) + (thumb-bl-place web-post-br)) + (triangle-hulls ; top two to the middle two, starting on the left + (thumb-tl-place thumb-post-tl) + (thumb-bl-place web-post-tr) + (thumb-tl-place thumb-post-bl) + (thumb-bl-place web-post-br) + (thumb-tl-place thumb-post-br) + (thumb-mr-place web-post-tr) + (thumb-tr-place thumb-post-bl) + ; (thumb-mr-place thumb-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 0 cornerrow web-post-bl) + (thumb-tl-place thumb-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)) + (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)))) ;;;;;;;;;; ;; Case ;; @@ -469,37 +466,35 @@ (defn bottom-hull [& p] (hull p (bottom 0.001 p))) -(def left-wall-x-offset 10) -(def left-wall-z-offset 3) +(def left-wall-x-offset 5) ; original 10 +(def left-wall-z-offset 3) ; original 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)) - (defn wall-locate1 [dx dy] [(* dx wall-thickness) (* dy wall-thickness) -1]) (defn wall-locate2 [dx dy] [(* dx wall-xy-offset) (* dy wall-xy-offset) wall-z-offset]) (defn wall-locate3 [dx dy] [(* dx (+ wall-xy-offset wall-thickness)) (* dy (+ wall-xy-offset wall-thickness)) wall-z-offset]) (defn wall-brace [place1 dx1 dy1 post1 place2 dx2 dy2 post2] (union - (hull - (place1 post1) - (place1 (translate (wall-locate1 dx1 dy1) post1)) - (place1 (translate (wall-locate2 dx1 dy1) post1)) - (place1 (translate (wall-locate3 dx1 dy1) post1)) - (place2 post2) - (place2 (translate (wall-locate1 dx2 dy2) post2)) - (place2 (translate (wall-locate2 dx2 dy2) post2)) - (place2 (translate (wall-locate3 dx2 dy2) post2))) - (bottom-hull - (place1 (translate (wall-locate2 dx1 dy1) post1)) - (place1 (translate (wall-locate3 dx1 dy1) post1)) - (place2 (translate (wall-locate2 dx2 dy2) post2)) - (place2 (translate (wall-locate3 dx2 dy2) post2))) - )) + (hull + (place1 post1) + (place1 (translate (wall-locate1 dx1 dy1) post1)) + (place1 (translate (wall-locate2 dx1 dy1) post1)) + (place1 (translate (wall-locate3 dx1 dy1) post1)) + (place2 post2) + (place2 (translate (wall-locate1 dx2 dy2) post2)) + (place2 (translate (wall-locate2 dx2 dy2) post2)) + (place2 (translate (wall-locate3 dx2 dy2) post2))) + (bottom-hull + (place1 (translate (wall-locate2 dx1 dy1) post1)) + (place1 (translate (wall-locate3 dx1 dy1) post1)) + (place2 (translate (wall-locate2 dx2 dy2) post2)) + (place2 (translate (wall-locate3 dx2 dy2) post2))))) (defn key-wall-brace [x1 y1 dx1 dy1 post1 x2 y2 dx2 dy2 post2] (wall-brace (partial key-place x1 y1) dx1 dy1 post1 @@ -532,13 +527,13 @@ (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 1 0 web-post-tr) (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 1 -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)) + (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)) ; 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.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) @@ -547,60 +542,80 @@ (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-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) ; 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-ml-place (translate (wall-locate2 -0.3 1) web-post-tr)) - (thumb-ml-place (translate (wall-locate3 -0.3 1) web-post-tr))) + (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))) (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-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)) + (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 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 thumb-post-tl)) + (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 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) - (key-place 0 cornerrow (translate (wall-locate1 -1 0) web-post-bl)) - (thumb-tl-place thumb-post-tl)) + (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) + (key-place 0 cornerrow (translate (wall-locate1 -1 0) web-post-bl)) + (thumb-tl-place thumb-post-tl)) (hull - (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)) - )) + (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 thumb-post-tl)))) +(def rj9-start (map + [0 -3 0] (key-position 1 0 (map + (wall-locate3 0 1) [0 (/ mount-height 2) 0])))) +(def rj9-ref (key-position 0 0 (map + (wall-locate2 0 1) [0 (/ mount-height 2) 0]))) +(def rj9-position (map + [12.5 -6 0] [(first rj9-ref) (second rj9-ref) 4.5])) +(def rj9-cube (cube 15 10 9)) +(def rj9-space (translate (map + rj9-position [0 0 2]) rj9-cube)) +(def rj9-holder (translate rj9-position (cube 19 10 9))) -(def rj9-start (map + [0 -3 0] (key-position 0 0 (map + (wall-locate3 0 1) [0 (/ mount-height 2) 0])))) -(def rj9-position [(first rj9-start) (second rj9-start) 11]) -(def rj9-cube (cube 14.78 13 22.38)) -(def rj9-space (translate rj9-position rj9-cube)) -(def rj9-holder (translate rj9-position - (difference rj9-cube - (union (translate [0 2 0] (cube 10.78 9 18.38)) - (translate [0 0 5] (cube 10.78 13 5)))))) +(def usb-micro-jack (translate (map + rj9-position [0 10 1.5]) (cube 8 20 3))) -(def usb-holder-position (key-position 1 0 (map + (wall-locate2 0 1) [0 (/ mount-height 2) 0]))) -(def usb-holder-size [6.5 10.0 13.6]) -(def usb-holder-thickness 4) +(def pro-micro-position (map + (key-position 0 2 (wall-locate3 -1 0)) [-5 0 -20])) +(def pro-micro-space-size [4 18 12]) ; z has no wall; +(def pro-micro-wall-thickness 4) +(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-holder + (->> (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)]))) +(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)) (+ (/ pro-micro-wall-thickness 2) (second pro-micro-position)) (last pro-micro-position)]))) + +(def usb-holder-size [6.2 13 6]) ; trrs jack PJ-320A +;(def usb-holder-position (key-position 0 0 [-3 5.99 0])) +(def usb-holder-position (map + rj9-position [-13.6 -4 0])) +(def usb-holder-thickness 3) +(def usb-holder-thickness-2x (* 2 usb-holder-thickness)) (def usb-holder - (->> (cube (+ (first usb-holder-size) usb-holder-thickness) (second usb-holder-size) (+ (last usb-holder-size) usb-holder-thickness)) - (translate [(first usb-holder-position) (second usb-holder-position) (/ (+ (last usb-holder-size) usb-holder-thickness) 2)]))) + (union + (->> (cube (+ (first usb-holder-size) usb-holder-thickness-2x) (+ wall-thickness (second usb-holder-size) usb-holder-thickness) (+ (last usb-holder-size) usb-holder-thickness)) + (translate [(first usb-holder-position) (+ wall-thickness (second usb-holder-position)) (/ (+ (last usb-holder-size) usb-holder-thickness) 2)])))) (def usb-holder-hole - (->> (apply cube usb-holder-size) - (translate [(first usb-holder-position) (second usb-holder-position) (/ (+ (last usb-holder-size) usb-holder-thickness) 2)]))) + (union + + ; circle trrs hole + (->> + (->> (binding [*fn* 30] (cylinder 2.5 20))) ; 5mm trrs jack + (rotate (deg2rad 90) [1 0 0]) + (translate [(first usb-holder-position) (+ (second usb-holder-position) (+ wall-thickness (/ (+ (second usb-holder-size) usb-holder-thickness) 2))) (+ 1.5 (/ (+ (last usb-holder-size) usb-holder-thickness) 2))])) ;1.5 padding + + ; rectangular trrs holder + (->> (apply cube usb-holder-size) (translate [(first usb-holder-position) (+ (/ wall-thickness 2) (second usb-holder-position) (/ usb-holder-thickness 2)) (+ (/ (last usb-holder-size) 2) usb-holder-thickness)])))) (def teensy-width 20) (def teensy-height 12) @@ -618,50 +633,49 @@ (def teensy-holder-top-offset (- (/ teensy-holder-top-length 2) teensy-holder-length)) (def teensy-holder - (->> - (union - (->> (cube 3 teensy-holder-length (+ 6 teensy-width)) - (translate [1.5 teensy-holder-offset 0])) - (->> (cube teensy-pcb-thickness teensy-holder-length 3) - (translate [(+ (/ teensy-pcb-thickness 2) 3) teensy-holder-offset (- -1.5 (/ teensy-width 2))])) - (->> (cube 4 teensy-holder-length 4) - (translate [(+ teensy-pcb-thickness 5) teensy-holder-offset (- -1 (/ teensy-width 2))])) - (->> (cube teensy-pcb-thickness teensy-holder-top-length 3) - (translate [(+ (/ teensy-pcb-thickness 2) 3) teensy-holder-top-offset (+ 1.5 (/ teensy-width 2))])) - (->> (cube 4 teensy-holder-top-length 4) - (translate [(+ teensy-pcb-thickness 5) teensy-holder-top-offset (+ 1 (/ teensy-width 2))]))) - (translate [(- teensy-holder-width) 0 0]) - (translate [-1.4 0 0]) - (translate [(first teensy-top-xy) - (- (second teensy-top-xy) 1) - (/ (+ 6 teensy-width) 2)]) - )) + (->> + (union + (->> (cube 3 teensy-holder-length (+ 6 teensy-width)) + (translate [1.5 teensy-holder-offset 0])) + (->> (cube teensy-pcb-thickness teensy-holder-length 3) + (translate [(+ (/ teensy-pcb-thickness 2) 3) teensy-holder-offset (- -1.5 (/ teensy-width 2))])) + (->> (cube 4 teensy-holder-length 4) + (translate [(+ teensy-pcb-thickness 5) teensy-holder-offset (- -1 (/ teensy-width 2))])) + (->> (cube teensy-pcb-thickness teensy-holder-top-length 3) + (translate [(+ (/ teensy-pcb-thickness 2) 3) teensy-holder-top-offset (+ 1.5 (/ teensy-width 2))])) + (->> (cube 4 teensy-holder-top-length 4) + (translate [(+ teensy-pcb-thickness 5) teensy-holder-top-offset (+ 1 (/ teensy-width 2))]))) + (translate [(- teensy-holder-width) 0 0]) + (translate [-1.4 0 0]) + (translate [(first teensy-top-xy) + (- (second teensy-top-xy) 1) + (/ (+ 6 teensy-width) 2)]))) (defn screw-insert-shape [bottom-radius top-radius height] - (union (cylinder [bottom-radius top-radius] height) - (translate [0 0 (/ height 2)] (sphere top-radius)))) + (union + (->> (binding [*fn* 30] + (cylinder [bottom-radius top-radius] height))) + (translate [0 0 (/ height 2)] (sphere top-radius)))) -(defn screw-insert [column row bottom-radius top-radius height] +(defn screw-insert [column row bottom-radius top-radius height offset] (let [shift-right (= column lastcol) shift-left (= column 0) 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 -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])))))] (->> (screw-insert-shape bottom-radius top-radius height) - (translate [(first position) (second position) (/ height 2)]) - ))) + (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) - (screw-insert 0 lastrow bottom-radius top-radius height) - (screw-insert 2 (+ lastrow 0.3) bottom-radius top-radius height) - (screw-insert 3 0 bottom-radius top-radius height) - (screw-insert lastcol 1 bottom-radius top-radius height) - )) + (union (screw-insert 0 0 bottom-radius top-radius height [9 10 0]) + (screw-insert 0 lastrow bottom-radius top-radius height [0 8 0]) + (screw-insert 3 lastrow bottom-radius top-radius height [9 4 0]) + (screw-insert 3 0 bottom-radius top-radius height [6 -4 0]) + ;(screw-insert lastcol 1 bottom-radius top-radius height) +)) (def screw-insert-height 3.8) (def screw-insert-bottom-radius (/ 5.31 2)) (def screw-insert-top-radius (/ 5.1 2)) @@ -673,45 +687,45 @@ (def wire-post-overhang 3.5) (def wire-post-diameter 2.6) (defn wire-post [direction offset] - (->> (union (translate [0 (* wire-post-diameter -0.5 direction) 0] (cube wire-post-diameter wire-post-diameter wire-post-height)) - (translate [0 (* wire-post-overhang -0.5 direction) (/ wire-post-height -2)] (cube wire-post-diameter wire-post-overhang wire-post-diameter))) - (translate [0 (- offset) (+ (/ wire-post-height -2) 3) ]) - (rotate (/ α -2) [1 0 0]) - (translate [3 (/ mount-height -2) 0]))) + (->> (union (translate [0 (* wire-post-diameter -0.5 direction) 0] (cube wire-post-diameter wire-post-diameter wire-post-height)) + (translate [0 (* wire-post-overhang -0.5 direction) (/ wire-post-height -2)] (cube wire-post-diameter wire-post-overhang wire-post-diameter))) + (translate [0 (- offset) (+ (/ wire-post-height -2) 3)]) + (rotate (/ α -2) [1 0 0]) + (translate [3 (/ mount-height -2) 0]))) (def wire-posts (union - (thumb-ml-place (translate [-5 0 -2] (wire-post 1 0))) - (thumb-ml-place (translate [ 0 0 -2.5] (wire-post -1 6))) - (thumb-ml-place (translate [ 5 0 -2] (wire-post 1 0))) - (for [column (range 0 lastcol) - row (range 0 cornerrow)] - (union - (key-place column row (translate [-5 0 0] (wire-post 1 0))) - (key-place column row (translate [0 0 0] (wire-post -1 6))) - (key-place column row (translate [5 0 0] (wire-post 1 0))))))) - + (thumb-ml-place (translate [-5 0 -2] (wire-post 1 0))) + (thumb-ml-place (translate [0 0 -2.5] (wire-post -1 6))) + (thumb-ml-place (translate [5 0 -2] (wire-post 1 0))) + (for [column (range 0 lastcol) + row (range 0 cornerrow)] + (union + (key-place column row (translate [-5 0 0] (wire-post 1 0))) + (key-place column row (translate [0 0 0] (wire-post -1 6))) + (key-place column row (translate [5 0 0] (wire-post 1 0))))))) (def model-right (difference - (union - key-holes - connectors - thumb - thumb-connectors - (difference (union case-walls - screw-insert-outers - teensy-holder - usb-holder) - rj9-space - usb-holder-hole - screw-insert-holes) - rj9-holder + (union + key-holes + connectors + thumb + thumb-connectors + (difference (union case-walls + screw-insert-outers + pro-micro-holder + rj9-holder + usb-holder) + rj9-space + usb-micro-jack + pro-micro-space + usb-holder-hole + screw-insert-holes) ; wire-posts ; thumbcaps ; caps - ) - (translate [0 0 -20] (cube 350 350 40)) - )) +) + (translate [0 0 -20] (cube 350 350 40)))) (spit "things/right.scad" (write-scad model-right)) @@ -721,17 +735,17 @@ (spit "things/right-test.scad" (write-scad - (union - key-holes - connectors - thumb - thumb-connectors - case-walls - thumbcaps - caps - teensy-holder - rj9-holder - usb-holder-hole + (union + key-holes + connectors + thumb + thumb-connectors + case-walls + thumbcaps + caps + pro-micro-holder + rj9-holder + usb-holder-hole ; usb-holder-hole ; ; teensy-holder-hole ; screw-insert-outers @@ -740,23 +754,21 @@ ; usb-cutout ; rj9-space ; wire-posts - ))) +))) (spit "things/right-plate.scad" (write-scad - (cut - (translate [0 0 -0.1] - (difference (union case-walls - teensy-holder + (cut + (translate [0 0 -0.1] + (difference (union case-walls + teensy-holder + pro-micro-holder ; rj9-holder - screw-insert-outers) - (translate [0 0 -10] screw-insert-screw-holes)) - )))) + screw-insert-outers) + (translate [0 0 -10] screw-insert-screw-holes)))))) (spit "things/test.scad" (write-scad - (difference usb-holder usb-holder-hole))) - - + (difference usb-holder usb-holder-hole))) (defn -main [dum] 1) ; dummy to make it easier to batch