Cleanup code
This commit is contained in:
parent
1b450e5f67
commit
262340fad8
|
@ -32,17 +32,15 @@
|
||||||
|
|
||||||
(def column-style :standard)
|
(def column-style :standard)
|
||||||
|
|
||||||
(if (true? inner-column)
|
(defn column-offset [column]
|
||||||
(defn column-offset [column] (cond
|
(if inner-column
|
||||||
(<= column 1) [0 -2 0]
|
(cond (<= column 1) [0 -2 0]
|
||||||
(= column 3) [0 2.82 -4.5]
|
(= column 3) [0 2.82 -4.5]
|
||||||
(>= column 5) [0 -12 5.64] ; original [0 -5.8 5.64]
|
(>= column 5) [0 -12 5.64] ; original [0 -5.8 5.64]
|
||||||
:else [0 0 0]))
|
:else [0 0 0])
|
||||||
(defn column-offset [column] (cond
|
(cond (= column 2) [0 2.82 -4.5]
|
||||||
(= column 2) [0 2.82 -4.5]
|
(>= column 4) [0 -12 5.64] ; original [0 -5.8 5.64]
|
||||||
(>= column 4) [0 -12 5.64] ; original [0 -5.8 5.64]
|
:else [0 0 0])))
|
||||||
:else [0 0 0]))
|
|
||||||
)
|
|
||||||
|
|
||||||
(def thumb-offsets [6 -3 7])
|
(def thumb-offsets [6 -3 7])
|
||||||
|
|
||||||
|
@ -76,8 +74,8 @@
|
||||||
(def lastrow (dec nrows))
|
(def lastrow (dec nrows))
|
||||||
(def cornerrow (dec lastrow))
|
(def cornerrow (dec lastrow))
|
||||||
(def lastcol (dec ncols))
|
(def lastcol (dec ncols))
|
||||||
(if (true? extra-row) (def extra-cornerrow lastrow) (def extra-cornerrow cornerrow))
|
(def extra-cornerrow (if extra-row lastrow cornerrow))
|
||||||
(if (true? inner-column) (def innercol-offset 1) (def innercol-offset 0))
|
(def innercol-offset (if inner-column 1 0))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;
|
||||||
;; Switch Hole ;;
|
;; Switch Hole ;;
|
||||||
|
@ -172,9 +170,8 @@
|
||||||
(color [240/255 223/255 175/255 1])))})
|
(color [240/255 223/255 175/255 1])))})
|
||||||
|
|
||||||
;; Fill the keyholes instead of placing a a keycap over them
|
;; Fill the keyholes instead of placing a a keycap over them
|
||||||
(def keyhole-fill (let [fill (cube keyswitch-height keyswitch-width plate-thickness)]
|
(def keyhole-fill (->> (cube keyswitch-height keyswitch-width plate-thickness)
|
||||||
(->> fill
|
(translate [0 0 (/ plate-thickness 2)])))
|
||||||
(translate [0 0 (/ plate-thickness 2)]))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Placement Functions ;;
|
;; Placement Functions ;;
|
||||||
|
@ -196,7 +193,12 @@
|
||||||
(def column-x-delta (+ -1 (- (* column-radius (Math/sin β)))))
|
(def column-x-delta (+ -1 (- (* column-radius (Math/sin β)))))
|
||||||
|
|
||||||
(defn offset-for-column [col, row]
|
(defn offset-for-column [col, row]
|
||||||
(if (and (true? pinky-15u) (= col lastcol) (<= row last-15u-row) (>= row first-15u-row)) 4.7625 0))
|
(if (and 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]
|
(defn apply-key-geometry [translate-fn rotate-x-fn rotate-y-fn column row shape]
|
||||||
(let [column-angle (* β (- centercol column))
|
(let [column-angle (* β (- centercol column))
|
||||||
|
@ -259,9 +261,9 @@
|
||||||
(for [column columns
|
(for [column columns
|
||||||
row rows
|
row rows
|
||||||
:when (or (.contains [(+ innercol-offset 2) (+ innercol-offset 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) (+ innercol-offset 5)] column) extra-row (= ncols (+ innercol-offset 6)))
|
||||||
(and (.contains [(+ innercol-offset 4)] column) (true? extra-row) (= ncols (+ innercol-offset 5)))
|
(and (.contains [(+ innercol-offset 4)] column) extra-row (= ncols (+ innercol-offset 5)))
|
||||||
(and (true? inner-column) (not= row cornerrow)(= column 0))
|
(and inner-column (not= row cornerrow)(= column 0))
|
||||||
(not= row lastrow))]
|
(not= row lastrow))]
|
||||||
(->> single-plate
|
(->> single-plate
|
||||||
; (rotate (/ π 2) [0 0 1])
|
; (rotate (/ π 2) [0 0 1])
|
||||||
|
@ -273,7 +275,7 @@
|
||||||
:when (or (and (= column 0) (< row 3))
|
:when (or (and (= column 0) (< row 3))
|
||||||
(and (.contains [1 2] column) (< row 4))
|
(and (.contains [1 2] column) (< row 4))
|
||||||
(.contains [3 4 5 6] column))]
|
(.contains [3 4 5 6] column))]
|
||||||
(->> (sa-cap (if (and (true? pinky-15u) (= column lastcol) (not= row lastrow)) 1.5 1))
|
(->> (sa-cap (if (and pinky-15u (= column lastcol) (not= row lastrow)) 1.5 1))
|
||||||
(key-place column row)))
|
(key-place column row)))
|
||||||
(list (key-place 0 0 (sa-cap 1))
|
(list (key-place 0 0 (sa-cap 1))
|
||||||
(key-place 0 1 (sa-cap 1))
|
(key-place 0 1 (sa-cap 1))
|
||||||
|
@ -293,7 +295,7 @@
|
||||||
|
|
||||||
;placement for the innermost column
|
;placement for the innermost column
|
||||||
(def key-holes-inner
|
(def key-holes-inner
|
||||||
(if (true? inner-column)
|
(if inner-column
|
||||||
(apply union
|
(apply union
|
||||||
(for [row innerrows]
|
(for [row innerrows]
|
||||||
(->> single-plate
|
(->> single-plate
|
||||||
|
@ -317,7 +319,7 @@
|
||||||
(def web-post-br (translate [(- (/ mount-width 2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post))
|
(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
|
; wide posts for 1.5u keys in the main cluster
|
||||||
(if (true? pinky-15u)
|
(if pinky-15u
|
||||||
(do (def wide-post-tr (translate [(- (/ mount-width 1.2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post))
|
(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-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-bl (translate [(+ (/ mount-width -1.2) post-adj) (+ (/ mount-height -2) post-adj) 0] web-post))
|
||||||
|
@ -363,7 +365,7 @@
|
||||||
(key-place (inc column) (inc row) web-post-tl))))))
|
(key-place (inc column) (inc row) web-post-tl))))))
|
||||||
|
|
||||||
(def inner-connectors
|
(def inner-connectors
|
||||||
(if (true? inner-column)
|
(if inner-column
|
||||||
(apply union
|
(apply union
|
||||||
(concat
|
(concat
|
||||||
;; Row connections
|
;; Row connections
|
||||||
|
@ -393,7 +395,7 @@
|
||||||
(key-place (inc column) (inc row) web-post-tl)))))))
|
(key-place (inc column) (inc row) web-post-tl)))))))
|
||||||
|
|
||||||
(def extra-connectors
|
(def extra-connectors
|
||||||
(if (true? extra-row)
|
(if extra-row
|
||||||
(apply union
|
(apply union
|
||||||
(concat
|
(concat
|
||||||
(for [column (range 3 ncols)
|
(for [column (range 3 ncols)
|
||||||
|
@ -590,7 +592,7 @@
|
||||||
(key-place (+ innercol-offset 2) lastrow web-post-tr)
|
(key-place (+ innercol-offset 2) lastrow web-post-tr)
|
||||||
(key-place (+ innercol-offset 2) cornerrow web-post-br)
|
(key-place (+ innercol-offset 2) cornerrow web-post-br)
|
||||||
(key-place (+ innercol-offset 3) cornerrow web-post-bl))
|
(key-place (+ innercol-offset 3) cornerrow web-post-bl))
|
||||||
(if (true? extra-row)
|
(if extra-row
|
||||||
(union
|
(union
|
||||||
(triangle-hulls
|
(triangle-hulls
|
||||||
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
||||||
|
@ -749,7 +751,7 @@
|
||||||
(key-place (+ innercol-offset 2) lastrow web-post-tr)
|
(key-place (+ innercol-offset 2) lastrow web-post-tr)
|
||||||
(key-place (+ innercol-offset 2) cornerrow web-post-br)
|
(key-place (+ innercol-offset 2) cornerrow web-post-br)
|
||||||
(key-place (+ innercol-offset 3) cornerrow web-post-bl))
|
(key-place (+ innercol-offset 3) cornerrow web-post-bl))
|
||||||
(if (true? extra-row)
|
(if extra-row
|
||||||
(union
|
(union
|
||||||
(triangle-hulls
|
(triangle-hulls
|
||||||
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
||||||
|
@ -770,7 +772,7 @@
|
||||||
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
||||||
(key-place (+ innercol-offset 3) cornerrow web-post-br)
|
(key-place (+ innercol-offset 3) cornerrow web-post-br)
|
||||||
(key-place (+ innercol-offset 4) cornerrow web-post-bl))))))
|
(key-place (+ innercol-offset 4) cornerrow web-post-bl))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;
|
||||||
;; New Thumb ;;
|
;; New Thumb ;;
|
||||||
;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;
|
||||||
|
@ -925,7 +927,7 @@
|
||||||
(key-place (+ innercol-offset 2) lastrow web-post-tr)
|
(key-place (+ innercol-offset 2) lastrow web-post-tr)
|
||||||
(key-place (+ innercol-offset 2) cornerrow web-post-br)
|
(key-place (+ innercol-offset 2) cornerrow web-post-br)
|
||||||
(key-place (+ innercol-offset 3) cornerrow web-post-bl))
|
(key-place (+ innercol-offset 3) cornerrow web-post-bl))
|
||||||
(if (true? extra-row)
|
(if extra-row
|
||||||
(union
|
(union
|
||||||
(triangle-hulls
|
(triangle-hulls
|
||||||
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
(key-place (+ innercol-offset 3) lastrow web-post-tr)
|
||||||
|
@ -949,26 +951,23 @@
|
||||||
|
|
||||||
|
|
||||||
;switching connectors, switchplates, etc. depending on thumb-style used
|
;switching connectors, switchplates, etc. depending on thumb-style used
|
||||||
(cond
|
(when (= thumb-style "default")
|
||||||
(= thumb-style "default") (when true
|
(def thumb-type thumb)
|
||||||
(def thumb-type thumb)
|
(def thumb-connector-type thumb-connectors)
|
||||||
(def thumb-connector-type thumb-connectors)
|
(def thumbcaps-type thumbcaps)
|
||||||
(def thumbcaps-type thumbcaps)
|
(def thumbcaps-fill-type thumbcaps-fill))
|
||||||
(def thumbcaps-fill-type thumbcaps-fill)))
|
|
||||||
|
|
||||||
(cond
|
(when (= thumb-style "new")
|
||||||
(= thumb-style "new") (when true
|
(def thumb-type newthumb)
|
||||||
(def thumb-type newthumb)
|
(def thumb-connector-type newthumb-connectors)
|
||||||
(def thumb-connector-type newthumb-connectors)
|
(def thumbcaps-type newthumbcaps)
|
||||||
(def thumbcaps-type newthumbcaps)
|
(def thumbcaps-fill-type newthumbcaps-fill))
|
||||||
(def thumbcaps-fill-type newthumbcaps-fill)))
|
|
||||||
|
|
||||||
(cond
|
(when (= thumb-style "mini")
|
||||||
(= thumb-style "mini") (when true
|
(def thumb-type minithumb)
|
||||||
(def thumb-type minithumb)
|
(def thumb-connector-type minithumb-connectors)
|
||||||
(def thumb-connector-type minithumb-connectors)
|
(def thumbcaps-type minithumbcaps)
|
||||||
(def thumbcaps-type minithumbcaps)
|
(def thumbcaps-fill-type minithumbcaps-fill))
|
||||||
(def thumbcaps-fill-type minithumbcaps-fill)))
|
|
||||||
|
|
||||||
;;;;;;;;;;
|
;;;;;;;;;;
|
||||||
;; Case ;;
|
;; Case ;;
|
||||||
|
@ -1017,7 +1016,7 @@
|
||||||
(partial key-place x2 y2) dx2 dy2 post2))
|
(partial key-place x2 y2) dx2 dy2 post2))
|
||||||
|
|
||||||
(def right-wall
|
(def right-wall
|
||||||
(if (true? pinky-15u)
|
(if pinky-15u
|
||||||
(union
|
(union
|
||||||
; corner between the right wall and back wall
|
; corner between the right wall and back wall
|
||||||
(if (> first-15u-row 0)
|
(if (> first-15u-row 0)
|
||||||
|
@ -1050,7 +1049,7 @@
|
||||||
(key-wall-brace lastcol (inc y) 1 0 web-post-tr lastcol (inc y) 1 0 web-post-br))))
|
(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)
|
(union (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 1 0 web-post-tr)
|
||||||
(if (true? extra-row)
|
(if 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))
|
(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)))
|
(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))
|
(union (for [y (range 0 lastrow)] (key-wall-brace lastcol y 1 0 web-post-tr lastcol y 1 0 web-post-br))
|
||||||
|
@ -1105,7 +1104,7 @@
|
||||||
(newthumb-bl-place (translate (wall-locate3 -0.3 1) thumb-post-tr))
|
(newthumb-bl-place (translate (wall-locate3 -0.3 1) thumb-post-tr))
|
||||||
(newthumb-ml-place thumb-post-tl))
|
(newthumb-ml-place thumb-post-tl))
|
||||||
; connectors below the inner column to the thumb & second column
|
; connectors below the inner column to the thumb & second column
|
||||||
(if (true? inner-column)
|
(if inner-column
|
||||||
(union
|
(union
|
||||||
(hull
|
(hull
|
||||||
(key-place 0 (dec cornerrow) web-post-bl)
|
(key-place 0 (dec cornerrow) web-post-bl)
|
||||||
|
@ -1170,7 +1169,7 @@
|
||||||
(minithumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr))
|
(minithumb-bl-place (translate (wall-locate3 -0.3 1) web-post-tr))
|
||||||
(minithumb-tl-place web-post-tl))
|
(minithumb-tl-place web-post-tl))
|
||||||
; connectors below the inner column to the thumb & second column
|
; connectors below the inner column to the thumb & second column
|
||||||
(if (true? inner-column)
|
(if inner-column
|
||||||
(union
|
(union
|
||||||
(hull
|
(hull
|
||||||
(key-place 0 (dec cornerrow) web-post-bl)
|
(key-place 0 (dec cornerrow) web-post-bl)
|
||||||
|
@ -1232,7 +1231,7 @@
|
||||||
(key-place 0 (- cornerrow innercol-offset) (translate (wall-locate1 0 0) web-post-bl))
|
(key-place 0 (- cornerrow innercol-offset) (translate (wall-locate1 0 0) web-post-bl))
|
||||||
(thumb-tl-place thumb-post-tl))
|
(thumb-tl-place thumb-post-tl))
|
||||||
; connectors below the inner column to the thumb & second column
|
; connectors below the inner column to the thumb & second column
|
||||||
(if (true? inner-column)
|
(if inner-column
|
||||||
(union
|
(union
|
||||||
(hull
|
(hull
|
||||||
(key-place 0 (dec cornerrow) web-post-bl)
|
(key-place 0 (dec cornerrow) web-post-bl)
|
||||||
|
@ -1256,19 +1255,13 @@
|
||||||
(thumb-ml-place (translate (wall-locate2 -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-ml-place (translate (wall-locate3 -0.3 1) web-post-tr))
|
||||||
(thumb-tl-place thumb-post-tl))))
|
(thumb-tl-place thumb-post-tl))))
|
||||||
|
|
||||||
;switching walls depending on thumb-style used
|
;switching walls depending on thumb-style used
|
||||||
(cond
|
(def thumb-wall-type
|
||||||
(= thumb-style "default") (when true
|
(case thumb-style
|
||||||
(def thumb-wall-type default-thumb-wall)))
|
"default" default-thumb-wall
|
||||||
|
"new" new-thumb-wall
|
||||||
(cond
|
"mini" mini-thumb-wall))
|
||||||
(= thumb-style "new") (when true
|
|
||||||
(def thumb-wall-type new-thumb-wall)))
|
|
||||||
|
|
||||||
(cond
|
|
||||||
(= thumb-style "mini") (when true
|
|
||||||
(def thumb-wall-type mini-thumb-wall)))
|
|
||||||
|
|
||||||
(def case-walls
|
(def case-walls
|
||||||
(union
|
(union
|
||||||
|
@ -1300,19 +1293,19 @@
|
||||||
))
|
))
|
||||||
|
|
||||||
; Offsets for the controller/trrs holder cutout
|
; Offsets for the controller/trrs holder cutout
|
||||||
(case nrows
|
(def holder-offset
|
||||||
4 (def holder-offset -3.5)
|
(case nrows
|
||||||
5 (def holder-offset 0)
|
4 -3.5
|
||||||
6 (def holder-offset 3.2))
|
5 0
|
||||||
|
6 (if inner-column
|
||||||
(if (and (false? inner-column) (= nrows 6))
|
3.2
|
||||||
(def holder-offset (- holder-offset 1))
|
2.2)))
|
||||||
)
|
|
||||||
|
(def notch-offset
|
||||||
(case nrows
|
(case nrows
|
||||||
4 (def notch-offset 3.15)
|
4 3.15
|
||||||
5 (def notch-offset 0)
|
5 0
|
||||||
6 (def notch-offset -5.07))
|
6 -5.07))
|
||||||
|
|
||||||
; Cutout for controller/trrs jack holder
|
; 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-ref (key-position 0 0 (map - (wall-locate2 0 -1) [0 (/ mount-height 2) 0])))
|
||||||
|
@ -1361,7 +1354,7 @@
|
||||||
|
|
||||||
; Connectors between outer column and right wall when 1.5u keys are used
|
; Connectors between outer column and right wall when 1.5u keys are used
|
||||||
(def pinky-connectors
|
(def pinky-connectors
|
||||||
(if (true? pinky-15u)
|
(if pinky-15u
|
||||||
(apply union
|
(apply union
|
||||||
(concat
|
(concat
|
||||||
;; Row connections
|
;; Row connections
|
||||||
|
@ -1456,8 +1449,6 @@
|
||||||
(translate [0 0 -0.1]
|
(translate [0 0 -0.1]
|
||||||
(difference (union case-walls
|
(difference (union case-walls
|
||||||
screw-insert-outers)
|
screw-insert-outers)
|
||||||
(translate [0 0 -10] screw-insert-screw-holes))))
|
(translate [0 0 -10] screw-insert-screw-holes))))))
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
(defn -main [dum] 1) ; dummy to make it easier to batch
|
(defn -main [dum] 1) ; dummy to make it easier to batch
|
||||||
|
|
Loading…
Reference in a new issue