Skip to content

Commit

Permalink
Rest of the owl
Browse files Browse the repository at this point in the history
  • Loading branch information
rianadon committed Nov 27, 2023
1 parent 479d5da commit 180eed0
Show file tree
Hide file tree
Showing 216 changed files with 88,357 additions and 6,215 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
target
pro
.npmrc
updateSite
13 changes: 0 additions & 13 deletions .prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dprint.dprint"]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true
}
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY : all build test keycaps keycaps-simple keyholes switches
build: target/proto/manuform.ts target/proto/lightcycle.ts target/proto/cuttleform.ts target/editorDeclarations.d.ts

NODE = node --experimental-specifier-resolution=node --loader ts-node/esm/transpile-only

test:
$(MAKE) -C test

all: build test

target/proto/manuform.ts: src/proto/manuform.proto
npx protoc --ts_out target --proto_path src $<

target/proto/cuttleform.ts: src/proto/cuttleform.proto
npx protoc --ts_out target --proto_path src $<

target/proto/lightcycle.ts: src/proto/lightcycle.proto
npx protoc --ts_out target --proto_path src $<

target/editorDeclarations.d.ts: src/lib/worker/config.ts src/lib/worker/modeling/transformation-ext.ts
$(NODE) src/model_gen/genEditorTypes.ts

target/KeyV2:
git clone -b choc https://github.com/rianadon/KeyV2 target/KeyV2

keycaps: target/KeyV2
$(NODE) src/model_gen/keycaps.ts
keycaps-simple: target/KeyV2
$(NODE) src/model_gen/keycaps-simple.ts
keyholes:
$(NODE) src/model_gen/keyholes.ts
parts:
$(NODE) src/model_gen/parts.ts
68 changes: 63 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
# Cosmos Keyboards

This is not complete! I'm only releasing the hand measuring stuff as open source for now.
That code is at [`src/routes/scan`](https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/routes/scan). Most of the processing happens in [`lib/hand.ts`](https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/routes/scan/lib/hand.ts).
The most adaptable generator for ergonomic mechanical keyboards there is.

I'm hoping to have the rest of the source released + general release around the end of the year. In the meantime, you can find information on how to beta test the generator on the [project website](https://ryanis.cool/cosmos/).
<p align="center">
<a href="https://ryanis.cool/cosmos"><img alt="Cosmos Logo" height="400px" src="static/keyboard2.png" /></a>
</p>

[Cosmos](https://ryanis.cool/cosmos) is released under an open-core model. 95% of the generator is free and open-source. Pro features (rounded edges, the stilts model, and wrist rests) are not.

## Generator

Most generator code lives at [`src/lib`] and[`src/routes/beta`]. Some files used for pre-generating STEP & GLB files used in the generator are located at [`src/model_gen`].

[`src/lib`]: https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/lib
[`src/routes/beta`]: https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/routes/beta
[`src/model_gen`]: https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/model_gen

To run the generator locally:

```bash
git clone https://github.com/rianadon/Cosmos-Keyboards
cd Cosmos-Keyboards
npm install
mkdir target
make keycaps-simple # Generates keycaps used for collision detection.
make keycaps # Generates geometry for all the keycaps. Take a while.
make parts # Generates the mx switch geometry
make # Compiles protobuf files
npm run dev

# Optional
make keyholes # (requires Java and Leiningen): Generates keyholes used in the Dactyl generator
```

Then visit [`http://localhost:5173/beta`](http://localhost:5173/beta).

If you're using Windows and don't have access to the `make` command, you can piece together the commands that are run by referencing the `Makefile` and running them yourself. Or just [install make](https://stackoverflow.com/a/73862277) :)

### Contributing Parts

In the codebase, the part integrated into the keyboard that holds a switch, trackball, screen, etc. is called a **socket**. Whatever is placed within the socket is called a **part**. Both the socket and part share the same name, which is used in Expert mode as the `type` property for a key. This short guide covers adding a new socket & part to the codebase.

1. Give the socket a name. The standard I've been loosely following is `thing-dimensions-vendor`. The vendor & dimensions can be omitted if they are obvious. For example, `trackpad-23mm-cirque` (I don't follow my convention) and `oled-128x32-0.91in-adafruit`.
2. Design a STEP file for the socket. Place it at `src/assets/key-(name).step`. If you're using someone else's STEP file, make sure it is licensed for reuse.
3. The boundary of the socket must be a rectangle. Take note of the dimensions. (You can also make it a cylinder—reference the trackpad).
4. Edit `src/lib/geometry/socketsParts.ts`. Add your part to `PART_NAMES` so it can be correctly shown in the BOM. Also edit `socketSize` to return the size of the rectangle from step 3.
5. The `partBottom` function returns a box describing the boundary of the part that rests in the socket, referenced from the top of the socket. This is used to raise the model high enough so that your part doesn't collide with the ground! Measure the part and modify this function.
6. Edit `src/lib/worker/socketsLoader.ts`. Import your STEP file and add it to `KEY_URLS` so the generator can make use of it.
7. Edit `src/lib/worker/config.ts` and add the name of your socket to the config. You'll probably be adding it under `CuttleBaseKey`.
8. Run `make` again to regenerate the Typescript type declarations for Expert mode.

You'll likely have an STL file of the part that goes into the socket. Follow these steps add it:

9. Again make sure the STL file is licensed for reuse or that it's your own. Place it under `src/assets/key-(name).stl`.
10. Edit `src/model_gen/parts.ts` so that your STL file can be converted to a GLB.
11. Edit `src/lib/loaders/parts.ts`and add your part.

> The working name of Cosmos was Cuttleform, named after the Cuttlefish. Cuttlefish are pretty adaptable!
## Hand Scanning

The code is at [`src/routes/scan`](https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/routes/scan). Most of the processing happens in [`lib/hand.ts`](https://github.com/rianadon/Cosmos-Keyboards/tree/main/src/routes/scan/lib/hand.ts).

Please feel free to use either GitHub or Discord for submitting issues.

### Hand Scanning
I'm planning on building out an API to make it easy for users to share their scanned hand data with other keyboard-related websites. If you maintain a keyboard-related site and are interested in adding a way for visitors to quickly see how your keyboard fits their hand, send me an email at ryan `@` ryanis.cool. You can of course use this code to build out your own hand scanning solution, provided you abide by the terms of the [AGPL-3.0 license](https://github.com/rianadon/Cosmos-Keyboards/blob/main/LICENSE).
### Building your own keyboard app?

I'm planning on building out an API to make it easy for users to share their scanned hand data with other keyboard-related websites. If you maintain a keyboard-related site and are interested in adding a way for visitors to quickly see how your keyboard fits their hand, send me an email at.cool. You can of course use this code to build out your own hand scanning solution, provided you abide by the terms of the [AGPL-3.0 license](https://github.com/rianadon/Cosmos-Keyboards/blob/main/LICENSE).
4 changes: 2 additions & 2 deletions docs/screws.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Screws are used to hold the keyboard base plate onto the rest of the keyboard ca
> **Abbreviations** OD: Outer Hole Diameter, H: Height, T: Angle Tapered In from Outer Diameter
| Screw size /<br>Attachment Method | ![Img][SI] Screw Insert | ![Img][TSI] Tapered Screw Insert | ![Img][ESI] Screw-to-Expand<br>Screw Insert | ![Img][Tap] Tapped Hole |
|-----------------------------------|-------------------------|----------------------------------|---------------------------------------------|-------------------------|
| --------------------------------- | ----------------------- | -------------------------------- | ------------------------------------------- | ----------------------- |
| **Equipment Needed** | Soldering Iron | Soldering Iron | Possibly a Mallet | Tap |
| M3 | OD: 4mm<br>H: 5.1mm | OD: 5mm<br>H: 4.6mm<br>T: 8° | OD: 4mm<br>H: 4.8mm | OD: 2.5mm<br>H: 4.8mm |
| M4 | OD: 5.6mm<br>H: 5.5mm | OD: 5.6mm<br>H: 5.5mm<br>T: 8° | OD: 5.6mm<br>H: 6.4mm | OD: 3.3mm<br>H: 6.4mm |
Expand All @@ -22,7 +22,7 @@ The sizes are taken from the recommended parameters in [McMaster-Carr's](https:/
These sizes below are taken from the ANSI standards:

| Screw size | OD, Hole in Bottom Plate | OD, Countersunk Hole in Bottom Plate |
|------------|--------------------------|--------------------------------------|
| ---------- | ------------------------ | ------------------------------------ |
| M3 | 3.4mm (medium fit) | 6.3mm, 45° taper |
| M4 | 4.5mm (medium fit) | 9.4mm, 45° taper |
| #4-40 | 0.1285" (free fit) | 0.28125", 41° taper |
Expand Down
36 changes: 36 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"lineWidth": 200,
"typescript": {
"quoteStyle": "preferSingle",
"semiColons": "asi"
},
"prettier": {
"associations": [
"**/*.{svelte}"
],
"singleQuote": true,
"semi": false,
"printWidth": 100
},
"json": {
},
"markdown": {
},
"includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,svelte}"],
"excludes": [
"**/node_modules",
"**/*-lock.json",
"build",
".svelte-kit",
"package",
"target",
"**/*.wasm.js",
"**/replicad_single*"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.88.4.wasm",
"https://plugins.dprint.dev/json-0.19.0.wasm",
"https://plugins.dprint.dev/markdown-0.16.2.wasm",
"https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe"
]
}
Loading

0 comments on commit 180eed0

Please sign in to comment.