summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoshreve <j.a.shreve@gmail.com>2020-08-16 21:13:16 -0400
committerjoshreve <j.a.shreve@gmail.com>2020-08-16 21:13:16 -0400
commit889e50856945e5fbf7febe3bb1516789e3b53f94 (patch)
tree9ede8a7dbb8c8d865e9d24ed313c2266e8868077
parent7b26338842899833d0da75a9b0e75466d0553af5 (diff)
Conversion to Python 3 based file generation. Removed Clojure files and updated README.md.
-rw-r--r--4x6.patch30
-rw-r--r--5x6.patch30
-rw-r--r--6x6.patch30
-rw-r--r--README.md44
-rw-r--r--create-models.sh43
-rw-r--r--doc/intro.md3
-rw-r--r--project.clj11
-rw-r--r--src/dactyl_keyboard/dactyl.clj762
-rw-r--r--src/dactyl_manuform.py1017
-rw-r--r--tags6
-rw-r--r--test/dactyl_cave/core_test.clj7
11 files changed, 1042 insertions, 941 deletions
diff --git a/4x6.patch b/4x6.patch
deleted file mode 100644
index 76f079e..0000000
--- a/4x6.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj
-index d8861fb..e58302f 100644
---- a/src/dactyl_keyboard/dactyl.clj
-+++ b/src/dactyl_keyboard/dactyl.clj
-@@ -13,13 +13,13 @@
- ;; Shape parameters ;;
- ;;;;;;;;;;;;;;;;;;;;;;
-
--(def nrows 4)
--(def ncols 5)
-+(def nrows 4)
-+(def ncols 6)
-
- (def α (/ π 12)) ; curvature of the columns
- (def β (/ π 36)) ; curvature of the rows
- (def centerrow (- nrows 3)) ; controls front-back tilt
--(def centercol 3) ; controls left-right tilt / tenting (higher number is more tenting)
-+(def centercol 2) ; 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
-@@ -32,7 +32,7 @@
-
- (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 16) ; 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
diff --git a/5x6.patch b/5x6.patch
deleted file mode 100644
index 5a00e3f..0000000
--- a/5x6.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj
-index d8861fb..e58302f 100644
---- a/src/dactyl_keyboard/dactyl.clj
-+++ b/src/dactyl_keyboard/dactyl.clj
-@@ -13,13 +13,13 @@
- ;; Shape parameters ;;
- ;;;;;;;;;;;;;;;;;;;;;;
-
--(def nrows 4)
--(def ncols 5)
-+(def nrows 5)
-+(def ncols 6)
-
- (def α (/ π 12)) ; curvature of the columns
- (def β (/ π 36)) ; curvature of the rows
- (def centerrow (- nrows 3)) ; controls front-back tilt
--(def centercol 3) ; controls left-right tilt / tenting (higher number is more tenting)
-+(def centercol 2) ; 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
-@@ -32,7 +32,7 @@
-
- (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 16) ; 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
diff --git a/6x6.patch b/6x6.patch
deleted file mode 100644
index d48e556..0000000
--- a/6x6.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj
-index d8861fb..e58302f 100644
---- a/src/dactyl_keyboard/dactyl.clj
-+++ b/src/dactyl_keyboard/dactyl.clj
-@@ -13,13 +13,13 @@
- ;; Shape parameters ;;
- ;;;;;;;;;;;;;;;;;;;;;;
-
--(def nrows 4)
--(def ncols 5)
-+(def nrows 6)
-+(def ncols 6)
-
- (def α (/ π 12)) ; curvature of the columns
- (def β (/ π 36)) ; curvature of the rows
- (def centerrow (- nrows 3)) ; controls front-back tilt
--(def centercol 3) ; controls left-right tilt / tenting (higher number is more tenting)
-+(def centercol 2) ; 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
-@@ -32,7 +32,7 @@
-
- (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 16) ; 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
diff --git a/README.md b/README.md
index 859154f..b78fdac 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,11 @@
-# The Dactyl-ManuForm Keyboard
-This is a fork of the [Dactyl](https://github.com/adereth/dactyl-keyboard), a parameterized, split-hand, concave, columnar, ergonomic keyboard.
+# The Dactyl-ManuForm Keyboard - Python 3
+This is a fork of [Dactyl-Manuform](https://github.com/tshort/dactyl-keyboard) by Tom Short, which itself is a fork of [Dactyl](https://github.com/adereth/dactyl-keyboard) by Matthew Adereth, a parameterized, split-hand, concave, columnar, ergonomic keyboard.
+
+The major change is switching to a python based file generator. Both predecessors were exceptional contributions to the ergo keyboard community by the authors but used a rather esoteric programming language, Clojure. My hope is that by converting the code to Python, the community will have an easier time modifying and evolving this design. I am planning to build this keyboard in the next several weeks and will update with my build information and BOM.
+
+I am also planning to create an entirely new object-oriented generator and will add a link when it is complete. In the mean time wanted to add my contribution of a faithful translation of the existing code and general structure into Python. The only geometry addition was an option to add the kalih hot-swap mounting through an STL file.
+
+**The majority of the the rest of the below content is as defined by previous authors, except where noted.**
![Imgur](http://i.imgur.com/LdjEhrR.jpg)
@@ -22,28 +28,28 @@ I built a 4x5 version (40% size) for myself. The default has a bit more tenting
## Assembly
-### Generating a Design
+### Generating a Design - Modified for Python Implementation
-**Setting up the Clojure environment**
-* [Install the Clojure runtime](https://clojure.org)
-* [Install the Leiningen project manager](http://leiningen.org/)
+**Setting up the Python environment - NEW**
+* [Install Python 3.X](https://www.python.org/downloads/release/python-385/) or use your [favorite distro / platform (Anaconda)](https://www.anaconda.com/products/individual)
+* It is advisable, but not necessary, to setup a virtual environment to prevent package/library incompatibility
+* [Install SolidPython](https://pypi.org/project/solidpython/), easiest method is `pip install solidpython` or `pip3 install solidpython` on linux.
+* [Install Numpy](https://pypi.org/project/numpy/), easiest method is `pip install numpy` or `pip3 install numpy` on linux.
* [Install OpenSCAD](http://www.openscad.org/)
-**Generating the design**
-* Run `lein repl`
-* Load the file `(load-file "src/dactyl_keyboard/dactyl.clj")`
+**Generating the design - NEW**
+* Run `python dactyl_manuform.py` or `python3 dactyl_manuform.py`
* This will regenerate the `things/*.scad` files
+ * `left_py.scad`
+ * `right_py.scad`
+ * `plate_py.scad`
* Use OpenSCAD to open a `.scad` file.
-* Make changes to design, repeat `load-file`, OpenSCAD will watch for changes and rerender.
+* Make changes to design, repeat run step, OpenSCAD will watch for changes and re-render.
* When done, use OpenSCAD to export STL files
-**Tips**
-* [Some other ways to evaluate the clojure design file](http://stackoverflow.com/a/28213489)
-* [Example designing with clojure](http://adereth.github.io/blog/2014/04/09/3d-printing-with-clojure/)
-
### Printing
-Pregenerated STL files are available in the [things/](things/) directory.
+Pre-generated STL files are available in the [things/](things/) directory.
When a model is generated, it also generates a `.scad` model for a bottom plate.
This can be exported to a DXF file in OpenSCAD.
The [things/](things/) directory also has DXF files for the bottom plate.
@@ -63,7 +69,7 @@ If printed at Shapeways or other professional shops, I would not expect such pro
### Wiring
-Here are materials I used for wiring.
+Here are materials I (tshort) used for wiring.
* Two Arduino Pro Micros
* [Heat-set inserts](https://www.mcmaster.com/#94180a331/=16yfrx1)
@@ -115,9 +121,9 @@ This is how the rows/columns wire to the keys and the ProMicro
NOTE: you also make sure the firmware is set up correctly (ex: change row pins with col pins)
-![Left Wire Diagram](/resources/dactyl_manuform_left_wire_diagram.png)
+![Left Wire Diagram](./resources/dactyl_manuform_left_wire_diagram.png)
-![Left Wire Diagram](/resources/dactyl_manuform_right_wire_diagram.png)
+![Left Wire Diagram](./resources/dactyl_manuform_right_wire_diagram.png)
### Firmware
@@ -129,6 +135,6 @@ This site also shows connections for the Arduino Pro Micro controllers.
## License
-Copyright © 2015-2017 Matthew Adereth and Tom Short
+Copyright © 2015-2020 Matthew Adereth, Tom Short, and Joshua Shreve
The source code for generating the models (everything excluding the [things/](things/) and [resources/](resources/) directories is distributed under the [GNU AFFERO GENERAL PUBLIC LICENSE Version 3](LICENSE). The generated models and PCB designs are distributed under the [Creative Commons Attribution-NonCommercial-ShareAlike License Version 3.0](LICENSE-models).
diff --git a/create-models.sh b/create-models.sh
deleted file mode 100644
index a53c9dc..0000000
--- a/create-models.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-lein run src/dactyl_keyboard/dactyl.clj
-cp things/right.scad things/right-4x5.scad
-cp things/left.scad things/left-4x5.scad
-cp things/right-plate.scad things/right-4x5-plate.scad
-openscad -o things/right-4x5-plate.dxf things/right-4x5-plate.scad >/dev/null 2>&1 &
-openscad -o things/right-4x5.stl things/right-4x5.scad >/dev/null 2>&1 &
-openscad -o things/left-4x5.stl things/left-4x5.scad >/dev/null 2>&1 &
-
-patch -p1 < 4x6.patch
-lein run src/dactyl_keyboard/dactyl.clj
-cp things/right.scad things/right-4x6.scad
-cp things/left.scad things/left-4x6.scad
-cp things/right-plate.scad things/right-4x6-plate.scad
-openscad -o things/right-4x6-plate.dxf things/right-4x6-plate.scad >/dev/null 2>&1 &
-openscad -o things/right-4x6.stl things/right-4x6.scad >/dev/null 2>&1 &
-openscad -o things/left-4x6.stl things/left-4x6.scad >/dev/null 2>&1 &
-git checkout src/dactyl_keyboard/dactyl.clj
-
-patch -p1 < 5x6.patch
-lein run src/dactyl_keyboard/dactyl.clj
-cp things/right.scad things/right-5x6.scad
-cp things/left.scad things/left-5x6.scad
-cp things/right-plate.scad things/right-5x6-plate.scad
-openscad -o things/right-5x6-plate.dxf things/right-5x6-plate.scad >/dev/null 2>&1 &
-openscad -o things/right-5x6.stl things/right-5x6.scad >/dev/null 2>&1 &
-openscad -o things/left-5x6.stl things/left-5x6.scad >/dev/null 2>&1 &
-git checkout src/dactyl_keyboard/dactyl.clj
-
-patch -p1 < 6x6.patch
-lein run src/dactyl_keyboard/dactyl.clj
-cp things/right.scad things/right-6x6.scad
-cp things/left.scad things/left-6x6.scad
-cp things/right-plate.scad things/right-6x6-plate.scad
-openscad -o things/right-6x6-plate.dxf things/right-6x6-plate.scad >/dev/null 2>&1 &
-openscad -o things/right-6x6.stl things/right-6x6.scad >/dev/null 2>&1 &
-openscad -o things/left-6x6.stl things/left-6x6.scad >/dev/null 2>&1 &
-git checkout src/dactyl_keyboard/dactyl.clj
-
-
-# git add things/*-4x5.stl
-# git add things/right-4x5-plate.dxf
-# git commit -m "Add CAD files"
-wait \ No newline at end of file
diff --git a/doc/intro.md b/doc/intro.md
deleted file mode 100644
index cfdc90a..0000000
--- a/doc/intro.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Introduction to dactyl-cave
-
-TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)
diff --git a/project.clj b/project.clj
deleted file mode 100644
index 86d5931..0000000
--- a/project.clj
+++ /dev/null
@@ -1,11 +0,0 @@
-(defproject dactyl-keyboard "0.1.0-SNAPSHOT"
- :description "A parametrized, split-hand, concave, columnar, erogonomic keyboard"
- :url "http://example.com/FIXME"
- :main dactyl-keyboard.dactyl
- :license {:name "Eclipse Public License"
- :url "http://www.eclipse.org/legal/epl-v10.html"}
- :dependencies [[org.clojure/clojure "1.7.0"]
- [unicode-math "0.2.0"]
- [scad-clj "0.4.0"]])
-
-
diff --git a/src/dactyl_keyboard/dactyl.clj b/src/dactyl_keyboard/dactyl.clj
deleted file mode 100644
index 573e95c..0000000
--- a/src/dactyl_keyboard/dactyl.clj
+++ /dev/null
@@ -1,762 +0,0 @@
-(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]))
-
-
-(defn deg2rad [degrees]
- (* (/ degrees 180) pi))
-
-;;;;;;;;;;;;;;;;;;;;;;
-;; Shape parameters ;;
-;;;;;;;;;;;;;;;;;;;;;;
-
-(def nrows 4)
-(def ncols 5)
-
-(def α (/ π 12)) ; curvature of the columns
-(def β (/ π 36)) ; curvature of the rows
-(def centerrow (- nrows 3)) ; controls front-back tilt
-(def centercol 3) ; 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)
-
-(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 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-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
-;; 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)])
-(def fixed-x [-41.5 -22.5 0 20.3 41.4 65.5 89.6]) ; relative to the middle finger
-(def fixed-z [12.1 8.3 0 5 10.7 14.5 17.5])
-(def fixed-tenting (deg2rad 0))
-
-;;;;;;;;;;;;;;;;;;;;;;;
-;; General variables ;;
-;;;;;;;;;;;;;;;;;;;;;;;
-
-(def lastrow (dec nrows))
-(def cornerrow (dec lastrow))
-(def lastcol (dec ncols))
-
-;;;;;;;;;;;;;;;;;
-;; Switch Hole ;;
-;;;;;;;;;;;;;;;;;
-
-(def keyswitch-height 14.4) ;; Was 14.1, then 14.25
-(def keyswitch-width 14.4)
-
-(def sa-profile-key-height 12.7)
-
-(def plate-thickness 4)
-(def mount-width (+ keyswitch-width 3))
-(def mount-height (+ keyswitch-height 3))
-
-(def single-plate
- (let [top-wall (->> (cube (+ keyswitch-width 3) 1.5 plate-thickness)
- (translate [0
- (+ (/ 1.5 2) (/ keyswitch-height 2))
- (/ plate-thickness 2)]))
- left-wall (->> (cube 1.5 (+ keyswitch-height 3) plate-thickness)
- (translate [(+ (/ 1.5 2) (/ keyswitch-width 2))
- 0
- (/ plate-thickness 2)]))
- side-nub (->> (binding [*fn* 30] (cylinder 1 2.75))
- (rotate (/ π 2) [1 0 0])
- (translate [(+ (/ keyswitch-width 2)) 0 1])
- (hull (->> (cube 1.5 2.75 plate-thickness)
- (translate [(+ (/ 1.5 2) (/ keyswitch-width 2))
- 0
- (/ plate-thickness 2)]))))
- plate-half (union top-wall left-wall (with-fn 100 side-nub))]
- (union plate-half
- (->> plate-half
- (mirror [1 0 0])
- (mirror [0 1 0])))))
-
-;;;;;;;;;;;;;;;;
-;; SA Keycaps ;;
-;;;;;;;;;;;;;;;;
-
-(def sa-length 18.25)
-(def sa-double-length 37.5)
-(def sa-cap {1 (let [bl2 (/ 18.5 2)
- m (/ 17 2)
- key-cap (hull (->> (polygon [[bl2 bl2] [bl2 (- bl2)] [(- bl2) (- bl2)] [(- bl2) bl2]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 0.05]))
- (->> (polygon [[m m] [m (- m)] [(- m) (- m)] [(- m) m]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 6]))
- (->> (polygon [[6 6] [6 -6] [-6 -6] [-6 6]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 12])))]
- (->> key-cap
- (translate [0 0 (+ 5 plate-thickness)])
- (color [220/255 163/255 163/255 1])))
- 2 (let [bl2 (/ sa-double-length 2)
- bw2 (/ 18.25 2)
- key-cap (hull (->> (polygon [[bw2 bl2] [bw2 (- bl2)] [(- bw2) (- bl2)] [(- bw2) bl2]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 0.05]))
- (->> (polygon [[6 16] [6 -16] [-6 -16] [-6 16]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 12])))]
- (->> key-cap
- (translate [0 0 (+ 5 plate-thickness)])
- (color [127/255 159/255 127/255 1])))
- 1.5 (let [bl2 (/ 18.25 2)
- bw2 (/ 28 2)
- key-cap (hull (->> (polygon [[bw2 bl2] [bw2 (- bl2)] [(- bw2) (- bl2)] [(- bw2) bl2]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 0.05]))
- (->> (polygon [[11 6] [-11 6] [-11 -6] [11 -6]])
- (extrude-linear {:height 0.1 :twist 0 :convexity 0})
- (translate [0 0 12])))]
- (->> key-cap
- (translate [0 0 (+ 5 plate-thickness)])
- (color [240/255 223/255 175/255 1])))})
-
-;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Placement Functions ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(def columns (range 0 ncols))
-(def rows (range 0 nrows))
-
-(def cap-top-height (+ plate-thickness sa-profile-key-height))
-(def row-radius (+ (/ (/ (+ mount-height extra-height) 2)
- (Math/sin (/ α 2)))
- cap-top-height))
-(def column-radius (+ (/ (/ (+ mount-width extra-width) 2)
- (Math/sin (/ β 2)))
- cap-top-height))
-(def column-x-delta (+ -1 (- (* column-radius (Math/sin β)))))
-(def column-base-angle (* β (- centercol 2)))
-
-(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 [0 0 (- row-radius)])
- (rotate-x-fn (* α (- centerrow row)))
- (translate-fn [0 0 row-radius])
- (translate-fn [0 0 (- column-radius)])
- (rotate-y-fn column-angle)
- (translate-fn [0 0 column-radius])
- (translate-fn (column-offset column)))
- column-z-delta (* column-radius (- 1 (Math/cos column-angle)))
- placed-shape-ortho (->> shape
- (translate-fn [0 0 (- row-radius)])
- (rotate-x-fn (* α (- centerrow row)))
- (translate-fn [0 0 row-radius])
- (rotate-y-fn column-angle)
- (translate-fn [(- (* (- column centercol) column-x-delta)) 0 column-z-delta])
- (translate-fn (column-offset column)))
- placed-shape-fixed (->> shape
- (rotate-y-fn (nth fixed-angles column))
- (translate-fn [(nth fixed-x column) 0 (nth fixed-z column)])
- (translate-fn [0 0 (- (+ row-radius (nth fixed-z column)))])
- (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])
- )]
- (->> (case column-style
- :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))
-
-(defn rotate-around-x [angle position]
- (mmul
- [[1 0 0]
- [0 (Math/cos angle) (- (Math/sin angle))]
- [0 (Math/sin angle) (Math/cos angle)]]
- position))
-
-(defn rotate-around-y [angle position]
- (mmul
- [[(Math/cos angle) 0 (Math/sin angle)]
- [0 1 0]
- [(- (Math/sin angle)) 0 (Math/cos angle)]]
- position))
-
-(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
- row rows
- :when (or (.contains [2 3] column)
- (not= row lastrow))]
- (->> single-plate
- (key-place column row)))))
-
-(def caps
- (apply union
- (for [column columns
- row rows
- :when (or (.contains [2 3] column)
- (not= row lastrow))]
- (->> (sa-cap (if (= column 5) 1 1))
- (key-place column row)))))
-
-; (pr (rotate-around-y π [10 0 1]))
-; (pr (key-position 1 cornerrow [(/ mount-width 2) (- (/ mount-height 2)) 0]))
-
-;;;;;;;;;;;;;;;;;;;;
-;; Web Connectors ;;
-;;;;;;;;;;;;;;;;;;;;
-
-(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)
- plate-thickness)])))
-
-(def post-adj (/ post-size 2))
-(def web-post-tr (translate [(- (/ mount-width 2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post))
-(def web-post-tl (translate [(+ (/ mount-width -2) post-adj) (- (/ mount-height 2) post-adj) 0] web-post))
-(def web-post-bl (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))
-
-(defn triangle-hulls [& shapes]
- (apply union
- (map (partial apply hull)
- (partition 3 1 shapes))))
-
-(def connectors
- (apply union
- (concat
- ;; Row connections
- (for [column (range 0 (dec ncols))
- row (range 0 lastrow)]
- (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 [column columns
- row (range 0 cornerrow)]
- (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)))
-
- ;; Diagonal connections
- (for [column (range 0 (dec ncols))
- row (range 0 cornerrow)]
- (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))))))
-
-;;;;;;;;;;;;
-;; Thumbs ;;
-;;;;;;;;;;;;
-
-(def thumborigin
- (map + (key-position 1 cornerrow [(/ mount-width 2) (- (/ mount-height 2)) 0])
- thumb-offsets))
-; (pr thumborigin)
-
-(defn thumb-tr-place [shape]
- (->> shape
- ; (rotate (deg2rad 10) [1 0 0])
- ; (rotate (deg2rad -23) [0 1 0])
- ; (rotate (deg2rad -3) [0 0 1])
- (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 -3) [0 0 1])
- (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 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 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 single-plate)
- (thumb-15x-layout single-plate)
- (thumb-15x-layout larger-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-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))
- ))
-
-;;;;;;;;;;
-;; Case ;;
-;;;;;;;;;;
-
-(defn bottom [height p]
- (->> (project p)
- (extrude-linear {:height height :twist 0 :convexity 0})
- (translate [0 0 (- (/ height 2) 10)])))
-
-(defn bottom-hull [& p]
- (hull p (bottom 0.001 p)))
-
-(def left-wall-x-offset 10)
-(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]) )
-
-(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)))
- ))
-
-(defn key-wall-brace [x1 y1 dx1 dy1 post1 x2 y2 dx2 dy2 post2]
- (wall-brace (partial key-place x1 y1) dx1 dy1 post1
- (partial key-place x2 y2) dx2 dy2 post2))
-
-(def case-walls
- (union
- ; 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))
- (key-wall-brace lastcol 0 0 1 web-post-tr lastcol 0 1 0 web-post-tr)
- ; right wall
- (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 cornerrow 0 -1 web-post-br lastcol cornerrow 1 0 web-post-br)
- ; 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 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 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 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)
- ; thumb corners
- (wall-brace thumb-br-place -1 0 web-post-bl thumb-br-place 0 -1 web-post-bl)
- (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)
- ; 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)))
- (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))
- (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))
- (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))
- (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))
- ))
-
-
-(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-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 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)])))
-(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)])))
-
-(def teensy-width 20)
-(def teensy-height 12)
-(def teensy-length 33)
-(def teensy2-length 53)
-(def teensy-pcb-thickness 2)
-(def teensy-holder-width (+ 7 teensy-pcb-thickness))
-(def teensy-holder-height (+ 6 teensy-width))
-(def teensy-offset-height 5)
-(def teensy-holder-top-length 18)
-(def teensy-top-xy (key-position 0 (- centerrow 1) (wall-locate3 -1 0)))
-(def teensy-bot-xy (key-position 0 (+ centerrow 1) (wall-locate3 -1 0)))
-(def teensy-holder-length (- (second teensy-top-xy) (second teensy-bot-xy)))
-(def teensy-holder-offset (/ teensy-holder-length -2))
-(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)])
- ))
-
-(defn screw-insert-shape [bottom-radius top-radius height]
- (union (cylinder [bottom-radius top-radius] height)
- (translate [0 0 (/ height 2)] (sphere top-radius))))
-
-(defn screw-insert [column row bottom-radius top-radius height]
- (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])))))
- ]
- (->> (screw-insert-shape bottom-radius top-radius height)
- (translate [(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)
- ))
-(def screw-insert-height 3.8)
-(def screw-insert-bottom-radius (/ 5.31 2))
-(def screw-insert-top-radius (/ 5.1 2))
-(def screw-insert-holes (screw-insert-all-shapes screw-insert-bottom-radius screw-insert-top-radius screw-insert-height))
-(def screw-insert-outers (screw-insert-all-shapes (+ screw-insert-bottom-radius 1.6) (+ screw-insert-top-radius 1.6) (+ screw-insert-height 1.5)))
-(def screw-insert-screw-holes (screw-insert-all-shapes 1.7 1.7 350))
-
-(def wire-post-height 7)
-(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])))
-
-(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)))))))
-
-
-(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
- wire-posts
- ; thumbcaps
- ; caps
- )
- (translate [0 0 -20] (cube 350 350 40))
- ))
-
-(spit "things/right.scad"
- (write-scad model-right))
-
-(spit "things/left.scad"
- (write-scad (mirror [-1 0 0] model-right)))
-
-(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
- ; usb-holder-hole
- ; ; teensy-holder-hole
- ; screw-insert-outers
- ; teensy-screw-insert-holes
- ; teensy-screw-insert-outers
- ; 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
- ; rj9-holder
- screw-insert-outers)
- (translate [0 0 -10] screw-insert-screw-holes))
- ))))
-
-(spit "things/test.scad"
- (write-scad
- (difference usb-holder usb-holder-hole)))
-
-
-
-(defn -main [dum] 1) ; dummy to make it easier to batch \ No newline at end of file
diff --git a/src/dactyl_manuform.py b/src/dactyl_manuform.py
new file mode 100644
index 0000000..6f0ec0b
--- /dev/null
+++ b/src/dactyl_manuform.py
@@ -0,0 +1,1017 @@
+import solid as sl
+import numpy as np
+from numpy import pi
+import os.path as path
+
+
+def deg2rad(degrees: float) -> float:
+ return degrees * pi/180
+
+def rad2deg(rad: float) -> float:
+ return rad * 180/pi
+
+# ######################
+# ## Shape parameters ##
+# ######################
+
+
+nrows = 5 # key rows
+ncols = 6 # key columns
+
+alpha = pi/12.0 # curvature of the columns
+beta = pi/36.0 # curvature of the rows
+centerrow = nrows - 3 # controls front_back tilt
+centercol = 3 # controls left_right tilt / tenting (higher number is more tenting)
+tenting_angle = pi/12.0 # or, change this for more precise tenting control
+
+hot_swap = False
+
+if nrows > 5:
+ column_style ='orthographic'
+else:
+ column_style = 'standard' # options include :standard, :orthographic, and :fixed
+
+# column_style='fixed'
+
+def column_offset(column: int) -> list:
+ if column == 2:
+ return [0, 2.82, -4.5]
+ elif column >= 4:
+ return [0, -12, 5.64] # original [0 -5.8 5.64]
+ else:
+ return [0, 0, 0]
+
+thumb_offsets = [6, -3, 7]
+keyboard_z_offset = 9 # controls overall height# original=9 with centercol=3# use 16 for centercol=2
+
+extra_width = 2.5 # extra space between the base of keys# original= 2
+extra_height = 1.0 # original= 0.5
+
+wall_z_offset = -15 # length of the first downward_sloping part of the wall (negative)
+wall_xy_offset = 5 # offset in the x and/or y direction for the first downward_sloping part of the wall (negative)
+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
+## fixed_z overrides the z portion of the column ofsets above.
+## NOTE: THIS DOESN'T WORK QUITE LIKE I'D HOPED.
+fixed_angles = [deg2rad(10), deg2rad(10), 0, 0, 0, deg2rad(-15), deg2rad(-15)]
+fixed_x = [-41.5, -22.5, 0, 20.3, 41.4, 65.5, 89.6] # relative to the middle finger
+fixed_z = [12.1, 8.3, 0, 5, 10.7, 14.5, 17.5]
+fixed_tenting = deg2rad(0)
+
+#######################
+## General variables ##
+#######################
+
+lastrow = nrows-1
+cornerrow = lastrow-1
+lastcol = ncols-1
+
+#################
+## Switch Hole ##
+#################
+
+keyswitch_height = 14.4 ## Was 14.1, then 14.25
+keyswitch_width = 14.4
+
+sa_profile_key_height = 12.7
+
+plate_thickness = 4
+mount_width = keyswitch_width + 3
+mount_height = keyswitch_height + 3
+
+
+def single_plate(cylinder_segments=100):
+ top_wall = sl.cube([keyswitch_width + 3, 1.5, plate_thickness], center=True)
+ top_wall = sl.translate([
+ 0,
+ (1.5/2)+(keyswitch_height/2),
+ plate_thickness/2
+ ])(top_wall)
+
+ left_wall = sl.cube([1.5, keyswitch_height + 3, plate_thickness], center=True)
+ left_wall = sl.translate([
+ (1.5/2)+(keyswitch_width/2),
+ 0,
+ plate_thickness/2
+ ])(left_wall)
+
+ side_nub = sl.cylinder(1, 2.75, segments=cylinder_segments, center=True)
+ side_nub = sl.rotate(rad2deg(pi/2),[1, 0, 0])(side_nub)
+ side_nub = sl.translate([ keyswitch_width/2, 0, 1])(side_nub)
+ nub_cube = sl.cube([1.5, 2.75, plate_thickness], center=True)
+ nub_cube= sl.translate([
+ (1.5/2)+(keyswitch_width/2),
+ 0,
+ plate_thickness/2])(nub_cube)
+
+ side_nub = sl.hull()(side_nub, nub_cube)
+
+ plate_half1 = top_wall + left_wall + side_nub
+ plate_half2 = plate_half1
+ plate_half2 = sl.mirror([0, 1, 0])(plate_half2)
+ plate_half2 = sl.mirror([1, 0, 0])(plate_half2)
+
+ plate = plate_half1 + plate_half2
+
+ if hot_swap:
+ hot_swap_socket = sl.import_(path.join(r'..', 'geometry', r'hot_swap_plate.stl'))
+ hot_swap_socket = sl.translate([0, 0, plate_thickness-5.25])(hot_swap_socket)
+
+ plate = sl.union()(plate, hot_swap_socket)
+
+ return plate
+
+
+
+################
+## SA Keycaps ##
+################
+
+sa_length = 18.25
+sa_double_length = 37.5
+
+
+def sa_cap(Usize = 1):
+ #MODIFIED TO NOT HAVE THE ROTATION. NEEDS ROTATION DURING ASSEMBLY
+ sa_length = 18.25
+
+ bw2 = Usize * sa_length / 2
+ bl2 = sa_length / 2
+ m = 0
+ pw2 = 6 * Usize + 1
+ pl2 = 6
+
+ if Usize==1:
+ m = 17 / 2
+
+
+ k1 = sl.polygon([[bw2, bl2], [bw2, -bl2], [-bw2,-bl2], [-bw2, bl2]])
+ k1 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(k1)
+ k1 = sl.translate([0, 0, 0.05])(k1)
+ k2 = sl.polygon([[pw2, pl2], [pw2, -pl2], [-pw2,-pl2], [-pw2, pl2]])
+ k2 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(k2)
+ k2 = sl.translate([0, 0, 12.0])(k2)
+ if m > 0:
+ m1 = sl.polygon([[m, m], [m, -m], [-m,-m], [-m, m]])
+ m1 = sl.linear_extrude(height=0.1, twist=0, convexity=0, center=True)(m1)
+ m1 = sl.translate([0, 0, 6.0])(m1)
+ key_cap = sl.hull()(k1,k2,m1)
+ else:
+ key_cap = sl.hull()(k1,k2)
+
+
+ key_cap = sl.translate([0, 0, 5 + plate_thickness])(key_cap)
+ key_cap = sl.color([220/255, 163/255, 163/255, 1])(key_cap)
+
+ return key_cap
+
+
+
+
+#########################
+## Placement Functions ##
+#########################
+
+
+def rotate_around_x(position, angle):
+ # print((position, angle))
+ t_matrix = np.array(
+ [[1, 0, 0],
+ [0, np.cos(angle), -np.sin(angle)],
+ [0, np.sin(angle), np.cos(angle)]])
+ return np.matmul(t_matrix, position)
+
+def rotate_around_y(position, angle):
+ # print((position, angle))
+ t_matrix = np.array(
+ [[np.cos(angle), 0, np.sin(angle)],
+ [0, 1, 0],
+ [-np.sin(angle), 0, np.cos(angle)]])
+ return np.matmul(t_matrix, position)
+
+
+cap_top_height = plate_thickness + sa_profile_key_height
+row_radius = ((mount_height+extra_height)/2)/(np.sin(alpha/2))+cap_top_height
+column_radius = (((mount_width+extra_width)/2)/(np.sin(beta/2)))+cap_top_height
+column_x_delta = -1-column_radius*np.sin(beta)
+column_base_angle = beta*(centercol-2)
+
+def apply_key_geometry(shape, translate_fn, rotate_x_fn, rotate_y_fn, column, row, column_style=column_style):
+ column_angle = beta*(centercol-column)
+
+ if column_style=='orthographic':
+ column_z_delta = column_radius*(1-np.cos(column_angle))
+ shape = translate_fn(shape, [0, 0, -row_radius])
+ shape = rotate_x_fn(shape, alpha*(centerrow-row))
+ shape = translate_fn(shape, [0, 0, row_radius])
+ shape = rotate_y_fn(shape, column_angle)
+ shape = translate_fn(shape, [-(column-centercol)*column_x_delta, 0, column_z_delta])
+ shape = translate_fn(shape, column_offset(column))
+
+
+ elif column_style=='fixed':
+ shape = rotate_y_fn(shape, fixed_angles[column])
+ shape = translate_fn(shape, [fixed_x[column], 0, fixed_z[column]])
+ shape = translate_fn(shape, [0, 0, -(row_radius+fixed_z[column])])
+ shape = rotate_x_fn(shape, alpha*(centerrow-row))
+ shape = translate_fn(shape, [0, 0, row_radius+fixed_z[column]])
+ shape = rotate_y_fn(shape, fixed_tenting)
+ shape = translate_fn(shape, [0, column_offset(column)[1], 0])
+
+
+ else:
+ shape = translate_fn(shape, [0, 0, -row_radius])
+ shape = rotate_x_fn(shape, alpha*(centerrow-row))
+ shape = translate_fn(shape, [0, 0, row_radius])
+ shape = translate_fn(shape, [0, 0, -column_radius])
+ shape = rotate_y_fn(shape, column_angle)
+ shape = translate_fn(shape, [0, 0, column_radius])
+ shape = translate_fn(shape, column_offset(column))
+
+ shape = rotate_y_fn(shape, tenting_angle)
+ shape = translate_fn(shape, [0, 0, keyboard_z_offset])
+
+ return shape
+
+def translate(shape, xyz):
+ return sl.translate(xyz)(shape)
+
+def x_rot(shape, angle):
+ return sl.rotate(rad2deg(angle), [1, 0, 0])(shape)
+
+def y_rot(shape, angle):
+ return sl.rotate(rad2deg(angle), [0, 1, 0])(shape)
+
+def key_place(shape, column, row):
+ return apply_key_geometry(shape, translate, x_rot, y_rot, column, row)
+
+def add_translate(shape, xyz):
+ vals=[]
+ for i in range(len(shape)):
+ vals.append(shape[i] + xyz[i])
+ return vals
+
+def key_position(position, column, row):
+ return apply_key_geometry(position, add_translate, rotate_around_x, rotate_around_y, column, row)
+
+
+
+
+def key_holes():
+ hole = single_plate()
+ holes = []
+ for column in range(ncols):
+ for row in range(nrows):
+ if (column in [2, 3]) or (not row==lastrow):
+ holes.append(key_place(hole, column, row))
+
+ return sl.union()(*holes)
+
+def caps():
+ caps = []
+ for column in range(ncols):
+ for row in range(nrows):
+ if (column in [2, 3]) or (not row==lastrow):
+ caps.append(key_place(sa_cap(), column, row))
+
+ return sl.union()(*caps)
+
+
+
+####################
+## Web Connectors ##
+####################
+
+web_thickness = 3.5
+post_size = 0.1
+
+def web_post():
+ post = sl.cube([post_size, post_size, web_thickness], center=True)
+ post = sl.translate([0,0, plate_thickness - (web_thickness/2)])(post)
+ return post
+
+post_adj = post_size / 2
+
+def web_post_tr():
+ return sl.translate([(mount_width/2)-post_adj, (mount_height/2)-post_adj, 0])(web_post())
+def web_post_tl():
+ return sl.translate([-(mount_width/2)+post_adj, (mount_height/2)-post_adj, 0])(web_post())
+def web_post_bl():
+ return sl.translate([-(mount_width/2)+post_adj, -(mount_height/2)+post_adj, 0])(web_post())
+def web_post_br():
+ return sl.translate([(mount_width/2)-post_adj, -(mount_height/2)+post_adj, 0])(web_post())
+
+def triangle_hulls(shapes):
+ hulls = []
+ for i in range(len(shapes)-2):
+ hulls.append(sl.hull()(*shapes[i:(i+3)]))
+
+ return sl.union()(*hulls)
+
+def connectors():
+ hulls=[]
+ for column in range(ncols-1):
+ for row in range(lastrow): # need to consider last_row?
+ # for row in range(nrows): # need to consider last_row?
+ places=[]
+ places.append(key_place(web_post_tl(), column+1, row))
+ places.append(key_place(web_post_tr(), column, row))
+ places.append(key_place(web_post_bl(), column+1, row))
+ places.append(key_place(web_post_br(), column, row))
+ hulls.append(triangle_hulls(places))
+
+ for column in range(ncols):
+ # for row in range(nrows-1):
+ for row in range(cornerrow):
+ places=[]
+ places.append(key_place(web_post_bl(), column, row))
+ places.append(key_place(web_post_br(), column, row))
+ places.append(key_place(web_post_tl(), column, row+1))
+ places.append(key_place(web_post_tr(), column, row+1))
+ hulls.append(triangle_hulls(places))
+
+ for column in range(ncols-1):
+ # for row in range(nrows-1): # need to consider last_row?
+ for row in range(cornerrow): # need to consider last_row?
+ places=[]
+ places.append(key_place(web_post_br(), column, row))
+ places.append(key_place(web_post_tr(), column, row+1))
+ places.append(key_place(web_post_bl(), column+1, row))
+ places.append(key_place(web_post_tl(), column+1, row+1))
+ hulls.append(triangle_hulls(places))
+
+ return sl.union()(*hulls)
+
+
+
+
+############
+## Thumbs ##
+############
+
+def thumborigin():
+ origin = key_position([mount_width/2, -(mount_height/2), 0], 1, cornerrow)
+ for i in range(len(origin)):
+ origin[i] = origin[i] + thumb_offsets[i]
+ return origin
+
+
+def thumb_tr_place(shape):
+ shape = sl.rotate( 10, [1, 0, 0])(shape)
+ shape = sl.rotate(-23, [0, 1, 0])(shape)
+ shape = sl.rotate( 10, [0, 0, 1])(shape)
+ shape = sl.translate(thumborigin())(shape)
+ shape = sl.translate([-12, -16, 3])(shape)
+ return shape
+
+def thumb_tl_place(shape):
+ shape = sl.rotate( 10, [1, 0, 0])(shape)
+ shape = sl.rotate(-23, [0, 1, 0])(shape)
+ shape = sl.rotate( 10, [0, 0, 1])(shape)
+ shape = sl.translate(thumborigin())(shape)
+ shape = sl.translate([-32, -15, -2])(shape)
+ return shape
+
+def thumb_mr_place(shape):
+ shape = sl.rotate( -6, [1, 0, 0])(shape)
+ shape = sl.rotate(-34, [0, 1, 0])(shape)
+ shape = sl.rotate( 48, [0, 0, 1])(shape)
+ shape = sl.translate(thumborigin())(shape)
+ shape = sl.translate([-29, -40, -13])(shape)
+ return shape
+
+def thumb_ml_place(shape):
+ shape = sl.rotate( 6, [1, 0, 0])(shape)
+ shape = sl.rotate(-34, [0, 1, 0])(shape)
+ shape = sl.rotate( 40, [0, 0, 1])(shape)
+ shape = sl.translate(thumborigin())(shape)
+ shape = sl.translate([-51, -25, -12])(shape)
+ return shape
+
+def thumb_br_place(shape):
+ shape = sl.rotate(-16, [1, 0, 0])(shape)
+ shape = sl.rotate(-33, [0, 1, 0])(shape)
+ shape = sl.rotate( 54, [0, 0, 1])(shape)
+ shape = sl.translate(thumborigin())(shape)
+ shape = sl.translate([-37.8, -55.3, -25.3])(shape)
+ return shape
+
+def thumb_bl_place(shape):
+ shape = sl.rotate( -4, [1, 0, 0])(shape)
+ shape = sl.rotate(-35, [0, 1, 0])(shape)
+ shape = sl.rotate( 52, [0, 0, 1])(shape)
+ shape = sl.translate(thumborigin())(shape)
+ shape = sl.translate([-56.3, -43.3, -23.5])(shape)
+ return shape
+
+def thumb_1x_layout(shape):
+ return sl.union()(
+ thumb_mr_place(shape),
+ thumb_ml_place(shape),
+ thumb_br_place(shape),
+ thumb_bl_place(shape),
+ )
+
+
+def thumb_15x_layout(shape):
+ return sl.union()(
+ thumb_tr_place(shape),
+ thumb_tl_place(shape),
+ )
+
+def double_plate():
+ plate_height = (sa_double_length-mount_height) / 3
+ # plate_height = (2*sa_length-mount_height) / 3
+ top_plate = sl.cube([mount_width, plate_height, web_thickness], center = True)
+ top_plate = sl.translate([
+ 0,
+ (plate_height+mount_height) / 2,
+ plate_thickness-(web_thickness / 2)
+ ])(top_plate)
+ return sl.union()(top_plate, sl.mirror([0, 1, 0])(top_plate))
+
+def thumbcaps():
+ t1 = thumb_1x_layout(sa_cap(1))
+ t15 = thumb_15x_layout(sl.rotate(pi/2,[0, 0, 1])(sa_cap(1.5)))
+ return t1 + t15
+
+
+
+def thumb():
+ shape = thumb_1x_layout(single_plate())
+ shape += thumb_15x_layout(single_plate())
+ shape += thumb_15x_layout(double_plate())
+ return shape
+
+
+def thumb_post_tr():
+ return sl.translate([(mount_width/2)-post_adj, (mount_height/1.15)-post_adj, 0])(web_post())
+
+def thumb_post_tl():
+ return sl.translate([-(mount_width/2)+post_adj, (mount_height/1.15)-post_adj, 0])(web_post())
+
+def thumb_post_bl():
+ return sl.translate([-(mount_width/2)+post_adj, -(mount_height/1.15)+post_adj, 0])(web_post())
+
+def thumb_post_br():
+ return sl.translate([(mount_width/2)-post_adj, -(mount_height/1.15)+post_adj, 0])(web_post())
+
+
+def thumb_connectors():
+ hulls = []
+
+ # Top two
+ hulls.append(triangle_hulls([
+ thumb_tl_place(thumb_post_tr()),
+ thumb_tl_place(thumb_post_br()),
+ thumb_tr_place(thumb_post_tl()),
+ thumb_tr_place(thumb_post_bl()),
+ ]))
+
+ # bottom two on the right
+ hulls.append(triangle_hulls([
+ thumb_br_place(web_post_tr()),
+ thumb_br_place(web_post_br()),
+ thumb_mr_place(web_post_tl()),
+ thumb_mr_place(web_post_bl()),
+ ]))
+
+ # bottom two on the left
+ hulls.append(triangle_hulls([
+ thumb_br_place(web_post_tr()),
+ thumb_br_place(web_post_br()),
+ thumb_mr_place(web_post_tl()),
+ thumb_mr_place(web_post_bl()),
+ ]))
+ # centers of the bottom four
+ hulls.append(triangle_hulls([
+ thumb_bl_place(web_post_tr()),
+ thumb_bl_place(web_post_br()),
+ thumb_ml_place(web_post_tl()),
+ thumb_ml_place(web_post_bl()),
+ ]))
+
+ # top two to the middle two, starting on the left
+ hulls.append(triangle_hulls([
+ 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()),
+ ]))
+
+ # top two to the main keyboard, starting on the left
+ hulls.append(triangle_hulls([
+ 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()),
+ ]))
+
+ hulls.append(triangle_hulls([
+ thumb_tl_place(thumb_post_tl()),
+ key_place(web_post_bl(), 0, cornerrow),
+ thumb_tl_place(thumb_post_tr()),
+ key_place(web_post_br(), 0, cornerrow),
+ thumb_tr_place(thumb_post_tl()),
+ key_place(web_post_bl(), 1, cornerrow),
+ thumb_tr_place(thumb_post_tr()),
+ key_place(web_post_br(), 1, cornerrow),
+ key_place(web_post_tl(), 2, lastrow),
+ key_place(web_post_bl(), 2, lastrow),
+ thumb_tr_place(thumb_post_tr()),
+ key_place(web_post_bl(), 2, lastrow),
+ thumb_tr_place(thumb_post_br()),
+ key_place(web_post_br(), 2, lastrow),
+ key_place(web_post_bl(), 3, lastrow),
+ key_place(web_post_tr(), 2, lastrow),
+ key_place(web_post_tl(), 3, lastrow),
+ key_place(web_post_bl(), 3, cornerrow),
+ key_place(web_post_tr(), 3, lastrow),
+ key_place(web_post_br(), 3, cornerrow),
+ key_place(web_post_bl(), 4, cornerrow),
+ ]))
+
+ hulls.append(triangle_hulls([
+ key_place(web_post_br(), 1, cornerrow),
+ key_place(web_post_tl(), 2, lastrow),
+ key_place(web_post_bl(), 2, cornerrow),
+ key_place(web_post_tr(), 2, lastrow),
+ key_place(web_post_br(), 2, cornerrow),
+ key_place(web_post_bl(), 3, cornerrow),
+ ]))
+
+ hulls.append(triangle_hulls([
+ key_place(web_post_tr(), 3, lastrow),
+ key_place(web_post_br(), 3, lastrow),
+ key_place(web_post_tr(), 3, lastrow),
+ key_place(web_post_bl(), 4, cornerrow),
+ ]))
+
+ return sl.union()(*hulls)
+
+
+
+
+
+##########
+## Case ##
+##########
+
+def bottom_hull(p, height=.001):
+ shape = None
+ for item in p:
+ proj = sl.projection()(p)
+ t_shape = sl.linear_extrude(height=height, twist=0, convexity=0, center=True)(proj)
+ t_shape = sl.translate([0, 0, height/2-10])(t_shape)
+ if shape is None:
+ shape = t_shape
+ shape = sl.hull()(p, shape, t_shape)
+ return shape
+
+left_wall_x_offset = 10
+left_wall_z_offset = 3
+
+def left_key_position(row, direction):
+ pos = np.array(key_position([-mount_width*0.5, direction*mount_height*0.5, 0], 0, row))
+ return pos - np.array([left_wall_x_offset, 0, left_wall_z_offset])
+
+
+def left_key_place(shape, row, direction):
+ pos = left_key_position(row, direction)
+ return sl.translate(pos)(shape)
+
+def wall_locate1(dx, dy):
+ return [dx * wall_thickness, dy * wall_thickness, -1]
+
+def wall_locate2(dx, dy):
+ return [dx * wall_xy_offset, dy * wall_xy_offset, wall_z_offset]
+
+def wall_locate3(dx, dy):
+ return [dx * (wall_xy_offset + wall_thickness), dy * (wall_xy_offset + wall_thickness), wall_z_offset]
+
+def wall_brace(place1, dx1, dy1, post1, place2, dx2, dy2, post2):
+ hulls=[]
+
+ hulls.append(place1(post1))
+ hulls.append(place1(sl.translate(wall_locate1(dx1, dy1))(post1)))
+ hulls.append(place1(sl.translate(wall_locate2(dx1, dy1))(post1)))
+ hulls.append(place1(sl.translate(wall_locate3(dx1, dy1))(post1)))
+
+ hulls.append(place2(post2))
+ hulls.append(place2(sl.translate(wall_locate1(dx2, dy2))(post2)))
+ hulls.append(place2(sl.translate(wall_locate2(dx2, dy2))(post2)))
+ hulls.append(place2(sl.translate(wall_locate3(dx2, dy2))(post2)))
+ shape1 = sl.hull()(*hulls)
+
+ hulls=[]
+ hulls.append(place1(sl.translate(wall_locate2(dx1, dy1))(post1)))
+ hulls.append(place1(sl.translate(wall_locate3(dx1, dy1))(post1)))
+ hulls.append(place2(sl.translate(wall_locate2(dx2, dy2))(post2)))
+ hulls.append(place2(sl.translate(wall_locate3(dx2, dy2))(post2)))
+ shape2 = bottom_hull(hulls)
+
+ return shape1 + shape2
+
+def key_wall_brace(x1, y1, dx1, dy1, post1, x2, y2, dx2, dy2, post2):
+ return wall_brace(
+ (lambda shape: key_place(shape, x1, y1)), dx1, dy1, post1,
+ (lambda shape: key_place(shape, x2, y2)), dx2, dy2, post2
+ )
+
+
+def back_wall():
+ x=0
+ shape = key_wall_brace(x, 0, 0, 1, web_post_tl(), x, 0, 0, 1, web_post_tr())
+ for i in range(ncols-1):
+ x=i+1
+ shape += key_wall_brace(x, 0, 0, 1, web_post_tl(), x , 0, 0, 1, web_post_tr())
+ shape += key_wall_brace(x, 0, 0, 1, web_post_tl(), x-1, 0, 0, 1, web_post_tr())
+ shape += key_wall_brace(lastcol, 0, 0, 1, web_post_tr(), lastcol, 0, 1, 0, web_post_tr())
+ return shape
+
+def right_wall():
+ y=0
+ shape = key_wall_brace(lastcol, y, 1, 0, web_post_tr(), lastcol, y , 1, 0, web_post_br())
+ for i in range(lastrow-1):
+ y=i+1
+ shape += key_wall_brace(lastcol, y, 1, 0, web_post_tr(), lastcol, y , 1, 0, web_post_br())
+ shape += key_wall_brace(lastcol, y, 1, 0, web_post_br(), lastcol, y-1, 1, 0, web_post_tr())
+ shape += key_wall_brace(lastcol, cornerrow, 0, -1, web_post_br(), lastcol, cornerrow, 1, 0, web_post_br())
+ return shape
+
+
+
+def left_wall():
+ shape = wall_brace(
+ (lambda sh: key_place(sh, 0, 0)), 0, 1, web_post_tl(),
+ (lambda sh: left_key_place(sh, 0, 1)), 0, 1, web_post()
+ )
+
+ shape += wall_brace(
+ (lambda sh: left_key_place(sh, 0, 1)), 0, 1, web_post(),
+ (lambda sh: left_key_place(sh, 0, 1)), -1, 0, web_post()
+ )
+
+ for i in range(lastrow):
+ y=i
+ temp_shape1 = wall_brace(
+ (lambda sh: left_key_place(sh, y, 1)), -1, 0, web_post(),
+ (lambda sh: left_key_place(sh, y,-1)), -1, 0, web_post()
+ )
+ temp_shape2 = sl.hull()(
+ key_place(web_post_tl(), 0, y),
+ key_place(web_post_bl(), 0, y),
+ left_key_place(web_post(), y, 1),
+ left_key_place(web_post(), y, -1),
+ )
+ shape += temp_shape1 + temp_shape2
+
+
+ for i in range(lastrow-1):
+ y=i+1
+ temp_shape1 = wall_brace(
+ (lambda sh: left_key_place(sh, y-1, -1)), -1, 0, web_post(),
+ (lambda sh: left_key_place(sh, y , 1)), -1, 0, web_post()
+ )
+ temp_shape2 = sl.hull()(
+ key_place(web_post_tl(), 0, y ),
+ key_place(web_post_bl(), 0, y-1),
+ left_key_place(web_post(), y , 1),
+ left_key_place(web_post(), y-1, -1),
+ )
+ shape += temp_shape1 + temp_shape2
+
+ return shape
+
+
+def front_wall():
+ shape = key_wall_brace(
+ lastcol, 0, 0, 1, web_post_tr(),
+ lastcol, 0, 1, 0, web_post_tr()
+ )
+ shape += key_wall_brace(
+ 3, lastrow, 0, -1, web_post_bl(),
+ 3, lastrow, 0.5, -1, web_post_br()
+ )
+ shape += key_wall_brace(
+ 3, lastrow, 0.5, -1, web_post_br(),
+ 4, cornerrow, 1, -1, web_post_bl()
+ )
+ for i in range(ncols-4):
+ x=i+4
+ shape += key_wall_brace(
+ x, cornerrow, 0, -1, web_post_bl(),
+ x, cornerrow, 0, -1, web_post_br()
+ )
+ for i in range(ncols-5):
+ x=i+5
+ shape += key_wall_brace(
+ x , cornerrow, 0, -1, web_post_bl(),
+ x-1, cornerrow, 0, -1, web_post_br()
+ )
+
+ return shape
+
+
+
+
+
+
+def thumb_walls():
+ # thumb, walls
+ shape = wall_brace(thumb_mr_place, 0, -1, web_post_br(), thumb_tr_place, 0, -1, thumb_post_br())
+ shape += wall_brace(thumb_mr_place, 0, -1, web_post_br(), thumb_mr_place, 0, -1, web_post_bl())
+ shape += wall_brace(thumb_br_place, 0, -1, web_post_br(), thumb_br_place, 0, -1, web_post_bl())
+ shape += wall_brace(thumb_ml_place, -0.3, 1, web_post_tr(), thumb_ml_place, 0, 1, web_post_tl())
+ shape += wall_brace(thumb_bl_place, 0, 1, web_post_tr(), thumb_bl_place, 0, 1, web_post_tl())
+ shape += wall_brace(thumb_br_place, -1, 0, web_post_tl(), thumb_br_place, -1, 0, web_post_bl())
+ shape += wall_brace(thumb_bl_place, -1, 0, web_post_tl(), thumb_bl_place, -1, 0, web_post_bl())
+ # thumb, corners
+ shape += wall_brace(thumb_br_place, -1, 0, web_post_bl(), thumb_br_place, 0, -1, web_post_bl())
+ shape += wall_brace(thumb_bl_place, -1, 0, web_post_tl(), thumb_bl_place, 0, 1, web_post_tl())
+ # thumb, tweeners
+ shape += wall_brace(thumb_mr_place, 0,-1, web_post_bl(), thumb_br_place, 0, -1, web_post_br())
+ shape += wall_brace(thumb_ml_place, 0, 1, web_post_tl(), thumb_bl_place, 0, 1, web_post_tr())
+ shape += wall_brace(thumb_bl_place, -1, 0, web_post_bl(), thumb_br_place, -1, 0, web_post_tl())
+ shape += wall_brace(thumb_tr_place, 0,-1, thumb_post_br(), (lambda sh: key_place(sh, 3, lastrow)), 0, -1, web_post_bl())
+
+ return shape
+
+
+def thumb_connection():
+ # clunky bit on the top left thumb connection (normal connectors don't work well)
+ shape = bottom_hull([
+ left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1),
+ left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1),
+ thumb_ml_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())),
+ thumb_ml_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())),
+ ])
+
+ shape += sl.hull()([
+ left_key_place(sl.translate(wall_locate2( -1, 0))(web_post()), cornerrow, -1),
+ left_key_place(sl.translate(wall_locate3( -1, 0))(web_post()), cornerrow, -1),
+ thumb_ml_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())),
+ thumb_ml_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())),
+ thumb_tl_place(thumb_post_tl()),
+ ])
+
+ shape += sl.hull()([
+ left_key_place(web_post(), cornerrow, -1),
+ left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1),
+ left_key_place(sl.translate(wall_locate2(-1, 0))(web_post()), cornerrow, -1),
+ left_key_place(sl.translate(wall_locate3(-1, 0))(web_post()), cornerrow, -1),
+ thumb_tl_place(thumb_post_tl()),
+ ])
+
+ shape += sl.hull()([
+ left_key_place(web_post(), cornerrow, -1),
+ left_key_place(sl.translate(wall_locate1(-1, 0))(web_post()), cornerrow, -1),
+ key_place(web_post_bl(), 0, cornerrow),
+ key_place(sl.translate(wall_locate1(-1, 0))(web_post_bl()), 0, cornerrow),
+ thumb_tl_place(thumb_post_tl()),
+ ])
+
+ shape += sl.hull()([
+ thumb_ml_place(web_post_tr()),
+ thumb_ml_place(sl.translate(wall_locate1(-0.3, 1))(web_post_tr())),
+ thumb_ml_place(sl.translate(wall_locate2(-0.3, 1))(web_post_tr())),
+ thumb_ml_place(sl.translate(wall_locate3(-0.3, 1))(web_post_tr())),
+ thumb_tl_place(thumb_post_tl()),
+ ])
+
+ return shape
+
+
+def case_walls():
+ return back_wall()+left_wall()+right_wall()+front_wall()+thumb_walls()+thumb_connection()
+
+
+
+
+rj9_start = list(np.array([0, -3, 0]) +
+ np.array(key_position(
+ list(np.array(wall_locate3(0, 1))+np.array([0, (mount_height/2), 0])), 0, 0)))
+
+rj9_position = [rj9_start[0], rj9_start[1], 11]
+
+def rj9_cube():
+ return sl.cube([14.78, 13, 22.38], center=True)
+
+def rj9_space():
+ return sl.translate(rj9_position)(rj9_cube())
+
+def rj9_holder():
+ shape = sl.union()(
+ sl.translate([0, 2, 0])(sl.cube([10.78, 9, 18.38], center=True)),
+ sl.translate([0, 0, 5])(sl.cube([10.78, 13, 5], center=True)),
+ )
+ shape = sl.difference()(shape, rj9_cube())
+ shape = sl.translate(rj9_position)(shape)
+ return shape
+
+
+usb_holder_position = key_position(np.array(wall_locate2(0, 1)) + np.array([0, (mount_height/2), 0]), 1, 0)
+usb_holder_size = [6.5, 10.0, 13.6]
+usb_holder_thickness = 4
+
+def usb_holder():
+ shape = sl.cube([usb_holder_size[0]+usb_holder_thickness, usb_holder_size[1], usb_holder_size[2]+usb_holder_thickness], center=True)
+ shape = sl.translate([usb_holder_position[0], usb_holder_position[1], (usb_holder_size[2]+usb_holder_thickness)/2])(shape)
+ return shape
+
+def usb_holder_hole():
+ shape = sl.cube(usb_holder_size, center=True)
+ shape = sl.translate([usb_holder_position[0], usb_holder_position[1], (usb_holder_size[2]+usb_holder_thickness)/2])(shape)
+ return shape
+
+teensy_width = 20
+teensy_height = 12
+teensy_length = 33
+teensy2_length = 53
+teensy_pcb_thickness = 2
+teensy_holder_width = 7 + teensy_pcb_thickness
+teensy_holder_height = 6 + teensy_width
+teensy_offset_height = 5
+teensy_holder_top_length = 18
+teensy_top_xy = key_position(wall_locate3(-1, 0), 0, centerrow-1)
+teensy_bot_xy = key_position(wall_locate3(-1, 0), 0, centerrow+1)
+teensy_holder_length = teensy_top_xy[1]-teensy_bot_xy[1]
+teensy_holder_offset = -teensy_holder_length/2
+teensy_holder_top_offset = (teensy_holder_top_length/2)-teensy_holder_length
+
+def teensy_holder():
+ s1 = sl.cube([3, teensy_holder_length, 6+teensy_width], center=True)
+ s1 = sl.translate([1.5, teensy_holder_offset, 0])(s1)
+
+ s2 = sl.cube([teensy_pcb_thickness, teensy_holder_length, 3], center=True)
+ s2 = sl.translate([(teensy_pcb_thickness/2)+3, teensy_holder_offset, -1.5-(teensy_width/2)])(s2)
+
+ s3 = sl.cube([teensy_pcb_thickness, teensy_holder_top_length, 3], center=True)
+ s3 = sl.translate([(teensy_pcb_thickness/2)+3, teensy_holder_top_offset, 1.5+(teensy_width/2)])(s3)
+
+ s4 = sl.cube([4, teensy_holder_top_length, 4], center=True)
+ s4 = sl.translate([teensy_pcb_thickness+5, teensy_holder_top_offset, 1+(teensy_width/2)])(s4)
+
+ shape = sl.union()(s1, s2, s3, s4)
+
+ shape = sl.translate([-teensy_holder_width, 0, 0])(shape)
+ shape = sl.translate([-1.4, 0, 0])(shape)
+ shape = sl.translate([teensy_top_xy[0], teensy_top_xy[1]-1, (6+teensy_width)/2])(shape)
+
+ return shape
+
+
+def screw_insert_shape(bottom_radius, top_radius, height):
+ shape = sl.union()(
+ sl.cylinder(r1=bottom_radius, r2=top_radius, h=height, center=True),
+ sl.translate([0, 0, (height/2)])(sl.sphere(top_radius)),
+ )
+ return shape
+
+
+
+def screw_insert(column, row, bottom_radius, top_radius, height):
+ shift_right = column==lastcol
+ shift_left = column==0
+ shift_up = (not (shift_right or shift_left)) and (row==0)
+ shift_down = (not (shift_right or shift_left)) and (row>=lastrow)
+
+ if shift_up:
+ position = key_position(np.array(wall_locate2(0, 1))+np.array([0, (mount_height/2), 0]), column, row)
+ elif shift_down:
+ position = key_position(np.array(wall_locate2(0, -1))-np.array([0, (mount_height/2), 0]), column, row)
+ elif shift_left:
+ position = list(np.array(left_key_position(row, 0))+np.array(wall_locate3(-1, 0)))
+ else:
+ position = key_position(np.array(wall_locate2(1, 0))+np.array([(mount_height/2), 0, 0]), column, row)
+
+ shape = screw_insert_shape(bottom_radius, top_radius, height)
+ shape = sl.translate([position[0], position[1], height/2])(shape)
+
+ return shape
+
+def screw_insert_all_shapes(bottom_radius, top_radius, height):
+ shape = sl.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),
+ )
+
+ return shape
+
+screw_insert_height = 3.8
+screw_insert_bottom_radius = 5.31/2
+screw_insert_top_radius = 5.1/2
+screw_insert_holes = screw_insert_all_shapes(screw_insert_bottom_radius, screw_insert_top_radius, screw_insert_height)
+screw_insert_outers = screw_insert_all_shapes(screw_insert_bottom_radius+1.6, screw_insert_top_radius+1.6, screw_insert_height+1.5)
+screw_insert_screw_holes = screw_insert_all_shapes(1.7, 1.7, 350)
+
+wire_post_height = 7
+wire_post_overhang = 3.5
+wire_post_diameter = 2.6
+
+def wire_post(direction, offset):
+ s1 = sl.cube([wire_post_diameter, wire_post_diameter, wire_post_height], center = True)
+ s1 = sl.translate([0, -wire_post_diameter*0.5*direction, 0])(s1)
+
+ s2 = sl.cube([wire_post_diameter, wire_post_overhang, wire_post_diameter], center = True)
+ s2 = sl.translate([0, -wire_post_overhang*0.5*direction, -wire_post_height/2])(s2)
+
+ shape = sl.union()(s1, s2)
+ shape = sl.translate([0, -offset, (-wire_post_height/2)+3])(shape)
+ shape = sl.rotate(-alpha/2, [1, 0, 0])(shape)
+ shape = sl.translate([3, -mount_height/2, 0])(shape)
+
+ return shape
+
+def wire_posts():
+ shape = thumb_ml_place(sl.translate([-5, 0, -2])(wire_post(1, 0)))
+ shape += thumb_ml_place(sl.translate([0, 0, -2.5])(wire_post(-1, 6)))
+ shape += thumb_ml_place(sl.translate([5, 0, -2])(wire_post(1, 0)))
+
+ for column in range(lastcol):
+ for row in range(lastrow-1):
+ shape += sl.union()(
+ key_place(sl.translate([-5, 0, 0])(wire_post( 1, 0)), column, row),
+ key_place(sl.translate([ 0, 0, 0])(wire_post(-1, 6)), column, row),
+ key_place(sl.translate([ 5, 0, 0])(wire_post( 1, 0)), column, row),
+ )
+ return shape
+
+
+
+
+
+def model_right():
+ shape = sl.union()(
+ key_holes(),
+ connectors(),
+ thumb(),
+ thumb_connectors(),
+ )
+
+ s2 = sl.union()(
+ case_walls(),
+ screw_insert_outers(),
+ teensy_holder(),
+ usb_holder(),
+ )
+
+ s2 = sl.difference()(
+ s2,
+ rj9_space(),
+ usb_holder_hole(),
+ screw_insert_holes()
+ )
+
+ shape = sl.union()(
+ shape,
+ s2,
+ rj9_holder(),
+ wire_posts(),
+ )
+
+ shape -= sl.translate([0, 0, -20])(sl.cube([350, 350, 40], center=True))
+ return shape
+
+
+sl.scad_render_to_file(model_right(), path.join(r'..', 'things', r'right_py.scad'))
+
+sl.scad_render_to_file(sl.mirror([-1, 0, 0])(model_right()), path.join(r'..', 'things', r'left_py.scad'))
+
+
+def baseplate():
+ shape = sl.union()(
+ case_walls(),
+ teensy_holder(),
+ # rj9_holder(),
+ screw_insert_outers(),
+ )
+
+ tool = sl.translate([0, 0, -10])(screw_insert_screw_holes())
+
+ shape = shape - tool
+
+ shape = sl.translate([0, 0, -.1])(shape)
+
+ return sl.projection(cut=True)(shape)
+
+sl.scad_render_to_file(baseplate(), path.join(r'..', 'things', r'plate_py.scad'))
+
+
+
+
diff --git a/tags b/tags
deleted file mode 100644
index d01d39b..0000000
--- a/tags
+++ /dev/null
@@ -1,6 +0,0 @@
-!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
-!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
-!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
-!_TAG_PROGRAM_NAME Exuberant Ctags //
-!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
-!_TAG_PROGRAM_VERSION 5.8 //
diff --git a/test/dactyl_cave/core_test.clj b/test/dactyl_cave/core_test.clj
deleted file mode 100644
index 2259ab4..0000000
--- a/test/dactyl_cave/core_test.clj
+++ /dev/null
@@ -1,7 +0,0 @@
-(ns dactyl-cave.core-test
- (:require [clojure.test :refer :all]
- [dactyl-cave.core :refer :all]))
-
-(deftest a-test
- (testing "FIXME, I fail."
- (is (= 0 1))))