Skip to content

Commit

Permalink
fixes #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibnuda committed Apr 9, 2020
1 parent a48c3d6 commit 3011c24
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 62 deletions.
1 change: 1 addition & 0 deletions resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ <h4>How to use this site:</h4>
Licenced under the<a href="https://github.com/ibnuda/dactyl-keyboard/tree/refaktor#license"
rel="noopener" target="_blank" title="GNU Affero General Public License Version 3"> GNU
Affero General Public License V3</a>.
</p>
</div>
</div>
</footer>
Expand Down
13 changes: 9 additions & 4 deletions resources/lightcycle.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h3>Curvature & Tenting</h3>
<option value=30>pi/30</option>
</select>
<label for="tenting-angle">Tenting Angle</label>
<select id="tenting-angle" name="tenting-angle" value=12>
<select id="tenting-angle" name="tenting-angle" value=9>
<option value=15>pi/15</option>
<option value=14>pi/14</option>
<option value=13>pi/13</option>
Expand Down Expand Up @@ -132,14 +132,19 @@ <h3>Form of the Case</h3>
<option value=10>10 mm</option>
</select>
</fieldset>
<label for="Miscelania">
<label for="miscelania">
<h3>Miscelania</h3>
</label>
<fieldset name="keycaps" id="keycaps">
<label for="show-keycaps">Show Keycaps?</label>
<fieldset name="miscelania" id="miscelania">
<!--label for="show-keycaps">Show Keycaps?</label>
<select id="show-keycaps" name="show-keycaps">
<option value="false">No</option>
<option value="true">Yes</option>
</select-->
<label for="right-side">Right side or left side?</label>
<select id="right-side" name="right-side">
<option value="true">Right</option>
<option value="false">Left</option>
</select>
</fieldset>
<input class="button-primary" type="submit" name="generate-case" value="Generate Case">
Expand Down
9 changes: 7 additions & 2 deletions resources/manuform.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ <h3>Form of the Case</h3>
<option value="true">Screw inserts</option>
</select>
</fieldset>
<label for="Miscelania">
<label for="miscelania">
<h3>Miscelania</h3>
</label>
<fieldset name="keycaps" id="keycaps">
<fieldset name="miscelania" id="miscelania">
<label for="show-keycaps">Show Keycaps?</label>
<select id="show-keycaps" name="show-keycaps">
<option value="false">No</option>
Expand All @@ -186,6 +186,11 @@ <h3>Miscelania</h3>
<option value="false">No</option>
<option value="true">Yes</option>
</select>
<label for="right-side">Right side or left side?</label>
<select id="right-side" name="right-side">
<option value="true">Right</option>
<option value="false">Left</option>
</select>
</fieldset>
<input class="button-primary" type="submit" name="generate-case" value="Generate Case">
<input class="button-primary" type="submit" name="generate-plate" value="Generate Plate">
Expand Down
76 changes: 42 additions & 34 deletions src/dactyl_keyboard/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@
(defn parse-bool [s]
(Boolean/valueOf s))

(defn generate-case-dl [confs]
(write-scad (dl/dactyl-top-right confs)))
(defn generate-case-dl [confs is-right?]
(write-scad (if is-right?
(dl/dactyl-top-right confs)
(dl/dactyl-top-left confs))))

(defn generate-case-dm [confs]
(write-scad (dm/model-right confs)))
(defn generate-case-dm [confs is-right?]
(write-scad (if is-right?
(dm/model-right confs)
(dm/model-left confs))))

(defn generate-plate-dm [confs]
(write-scad (dm/right-plate confs)))
(defn generate-plate-dm [confs is-right?]
(write-scad (if is-right?
(dm/plate-right confs)
(dm/plate-left confs))))

(defn home [_]
(render-file "index.html" {}))
Expand All @@ -34,36 +40,37 @@
(render-file "lightcycle.html" {}))

(defn generate-manuform [req]
(let [params (:form-params req)
param-ncols (parse-int (get params "ncols"))
param-nrows (parse-int (get params "nrows"))
param-minidox (parse-bool (get params "minidox"))
param-last-row-count (case (get params "last-row")
(let [p (:form-params req)
param-ncols (parse-int (get p "ncols"))
param-nrows (parse-int (get p "nrows"))
param-minidox (parse-bool (get p "minidox"))
param-last-row-count (case (get p "last-row")
"zero" :zero
"full" :full
:two)
keyswitch-type (get params "switch-type")
keyswitch-type (get p "switch-type")
param-use-alps (case keyswitch-type "alps" true false)
param-side-nub (case keyswitch-type "mx" true false)
param-inner-column (parse-bool (get params "inner-column"))

param-alpha (parse-int (get params "alpha"))
param-beta (parse-int (get params "beta"))
param-centercol (parse-int (get params "centercol"))
param-tenting-angle (parse-int (get params "tenting-angle"))

param-trrs-connector (parse-bool (get params "trrs-connector"))
param-use-promicro-usb-hole (parse-bool (get params "usb-hole"))

param-hotswap (parse-bool (get params "hotswap"))
param-ortho (parse-bool (get params "ortho"))
param-keyboard-z-offset (parse-int (get params "keyboard-z-offset"))
param-wide-pinky (parse-bool (get params "wide-pinky"))
param-wire-post (parse-bool (get params "wire-post"))
param-screw-inserts (parse-bool (get params "screw-inserts"))
param-show-keycaps (parse-bool (get params "show-keycaps"))
param-wrist-rest (parse-bool (get params "wrist-rest"))
param-generate-plate (get params "generate-plate")
param-inner-column (parse-bool (get p "inner-column"))

param-alpha (parse-int (get p "alpha"))
param-beta (parse-int (get p "beta"))
param-centercol (parse-int (get p "centercol"))
param-tenting-angle (parse-int (get p "tenting-angle"))

param-trrs-connector (parse-bool (get p "trrs-connector"))
param-use-promicro-usb-hole (parse-bool (get p "usb-hole"))

param-hotswap (parse-bool (get p "hotswap"))
param-ortho (parse-bool (get p "ortho"))
param-keyboard-z-offset (parse-int (get p "keyboard-z-offset"))
param-wide-pinky (parse-bool (get p "wide-pinky"))
param-wire-post (parse-bool (get p "wire-post"))
param-screw-inserts (parse-bool (get p "screw-inserts"))
param-show-keycaps (parse-bool (get p "show-keycaps"))
param-wrist-rest (parse-bool (get p "wrist-rest"))
param-generate-plate (get p "generate-plate")
is-right? (parse-bool (get p "right-side"))
generate-plate? (some? param-generate-plate)
c {:configuration-nrows param-nrows
:configuration-ncols param-ncols
Expand All @@ -90,8 +97,8 @@
:configuration-use-screw-inserts? param-screw-inserts
:configuration-use-wrist-rest? param-wrist-rest}
generated-scad (if generate-plate?
(generate-plate-dm c)
(generate-case-dm c))]
(generate-plate-dm c is-right?)
(generate-case-dm c is-right?))]
{:status 200
:headers {"Content-Type" "application/octet-stream"
"Content-Disposition" "inline; filename=\"myfile.scad\""}
Expand All @@ -113,6 +120,7 @@
param-z-offset (parse-int (get p "z-offset"))
param-thumb-offset-x (parse-int (get p "thumb-offset-x"))
param-thumb-offset-y (parse-int (get p "thumb-offset-y"))
is-right? (parse-bool (get p "right-side"))
param-thumb-offset-z (parse-int (get p "thumb-offset-z"))
c {:configuration-ncols param-ncols
:configuration-use-numrow? param-use-numrow?
Expand All @@ -127,7 +135,7 @@
:configuration-thumb-offset-x (- 0 param-thumb-offset-x)
:configuration-thumb-offset-y (- 0 param-thumb-offset-y)
:configuration-thumb-offset-z param-thumb-offset-z}
generated-scad (generate-case-dl c)]
generated-scad (generate-case-dl c is-right?)]
{:status 200
:headers {"Content-Type" "application/octet-stream"
"Content-Disposition" "inline; filename=\"myfile.scad\""}
Expand Down
18 changes: 5 additions & 13 deletions src/dactyl_keyboard/lightcycle.clj
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,6 @@
(defn fpenultcol [ncols] (dec ncols))
(defn fantecol [ncols] (dec (fpenultcol ncols)))

#_(def columns (range 0 ncols))
#_(def rows (range (if use-numrow? 0 1) nrows))

#_(def alpha (/ pi 12))
#_(def beta (/ pi 36))

#_(def tenting-angle (/ pi 9))
#_(def thumb-tenting-angle (/ pi 24))

#_(def z-offset 18)
#_(def thumb-offset [-48 -45 (+ z-offset 27)])

(defn fthumb-offset [c]
(let [thumb-offset-x (get c :configuration-thumb-offset-x)
thumb-offset-y (get c :configuration-thumb-offset-y)
Expand Down Expand Up @@ -981,6 +969,9 @@
#_(thumbcaps c))
(usb-holder-hole c)))

(defn dactyl-top-left [c]
(mirror [-1 0 0] (dactyl-top-right c)))

(def c
{:configuration-ncols 5
:configuration-use-numrow? false
Expand All @@ -993,7 +984,8 @@
:configuration-thumb-tenting-angle (/ pi 24)
:configuration-thumb-offset-x -48
:configuration-thumb-offset-y -45
:configuration-thumb-offset-z 27})
:configuration-thumb-offset-z 27
:configuration-show-caps? false})

#_(spit "things/lightcycle-cherry-top-right.scad"
(write-scad (dactyl-top-right c)))
24 changes: 15 additions & 9 deletions src/dactyl_keyboard/manuform.clj
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,15 @@
(partial inner-key-place confs)
(partial left-key-place confs)) (dec y) -1 web-post))))
(wall-brace (partial key-place confs (if use-inner-column? -1 0) 0) 0 1 web-post-tl
(partial (if use-inner-column?
(partial inner-key-place confs)
(partial left-key-place confs)) 0 1) 0 1 web-post)
(partial (if use-inner-column?
(partial inner-key-place confs)
(partial left-key-place confs)) 0 1) 0 1 web-post)
(wall-brace (partial (if use-inner-column?
(partial inner-key-place confs)
(partial left-key-place confs)) 0 1) 0 1 web-post
(partial (if use-inner-column?
(partial inner-key-place confs)
(partial left-key-place confs)) 0 1) -1 0 web-post))))
(partial inner-key-place confs)
(partial left-key-place confs)) 0 1) 0 1 web-post
(partial (if use-inner-column?
(partial inner-key-place confs)
(partial left-key-place confs)) 0 1) -1 0 web-post))))
(defn front-wall [confs]
(let [ncols (get confs :configuration-ncols)
nrows (get confs :configuration-nrows)
Expand Down Expand Up @@ -1574,14 +1574,20 @@
(usb-holder-hole c))))
(translate [0 0 -60] (cube 350 350 120)))))

(defn right-plate [c]
(defn model-left [c]
(mirror [-1 0 0] (model-right c)))

(defn plate-right [c]
(cut (translate [0 0 -0.1]
(difference (union (case-walls c)
(rj9-holder c)
(usb-holder c)
(screw-insert-outers c))
(translate [0 0 -10] (screw-insert-screw-holes c))))))

(defn plate-left [c]
(mirror [-1 0 0] (plate-right c)))

(def c (hash-map :configuration-nrows 4
:configuration-ncols 5
:configuration-create-side-nub? false
Expand Down

0 comments on commit 3011c24

Please sign in to comment.