MustafaMulla29/rp2040-bldc-motor-controller
Hardware assembly metadata and PCB geometry for a controller board with a snap-off rotary-encoder section, plus four parallel 150 µF/50 V bulk electrolytic capacitors filtering the motor supply.
- Version
- 2.0.40
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone MustafaMulla29/rp2040-bldc-motor-controller # download the package files into ./rp2040-bldc-motor-controller
tsci add MustafaMulla29/rp2040-bldc-motor-controller # add it to your project as @tsci/MustafaMulla29.rp2040-bldc-motor-controllerIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
scripts/large-files.mjs
/**
* Large inputs and the registry's per-file upload limit.
*
* While the registry rejects this package's archive upload (HTTP 413), the CLI uploads
* file by file, and any single file above roughly 4 MB is rejected too. `pack` writes a
* gzip copy beside each large input; the raw paths are listed in tscircuit.config.json
* `ignoredFiles`, so `tsci push` uploads only the .gz. `restore` recreates the raw files,
* byte-identical and sha256-checked, and runs at the start of the registry build
* (scripts/build-registry.mjs). Nothing is re-encoded, so every existing hash guard
* (PCB baseline, route plan) still holds.
*
* Inputs that the build reads belong here, plus the joined fabrication board: at 6.6 MB it
* cannot be uploaded as plain JSON, and the package page's "Builds" picker opens a .gz
* circuit file directly (as it already does for dist/pcb/circuit.json.gz).
* `assets/connected-system.glb` must stay a plain file: the tscircuit.com 3D viewer
* downloads it from the package by that exact path.
*
* bun scripts/large-files.mjs pack before publishing
* bun scripts/large-files.mjs restore after cloning the published package
*/
import { createHash } from "node:crypto"
import { existsSync, readFileSync, writeFileSync } from "node:fs"
import { resolve } from "node:path"
import { fileURLToPath } from "node:url"
import { gunzipSync, gzipSync } from "node:zlib"
const root = resolve(import.meta.dirname, "..")
const manifestPath = resolve(root, "scripts/large-files.json")
export const largeFiles = [
"circuit/route-plan.json",
"dist/pcb/circuit.json",
// Controller with the snap-off encoder (scripts/build-fabrication-with-encoder.mjs).
"dist/fabrication-with-encoder/circuit.json",
]
const sha = bytes => createHash("sha256").update(bytes).digest("hex")
/** Write `<file>.gz` for every large file and record its size and hash. */
export function pack() {
const manifest = {}
for (const file of largeFiles) {
const raw = readFileSync(resolve(root, file))
const packed = resolve(root, `${file}.gz`)
// Keep an existing archive when it already holds these exact bytes.
if (!existsSync(packed) || sha(gunzipSync(readFileSync(packed))) !== sha(raw)) {
writeFileSync(packed, gzipSync(raw, { level: 9 }))
}
manifest[file] = { bytes: raw.length, sha256: sha(raw), packedBytes: readFileSync(packed).length }
console.log(`packed ${file} (${raw.length} -> ${manifest[file].packedBytes} bytes)`)
}
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n")
}
/** Recreate any missing or stale raw file from its .gz and verify the recorded hash. */
export function restore() {
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"))
for (const [file, expected] of Object.entries(manifest)) {
const target = resolve(root, file)
if (existsSync(target) && sha(readFileSync(target)) === expected.sha256) continue
const packed = resolve(root, `${file}.gz`)
if (!existsSync(packed)) {
// The hosted build sandbox is not given dist/**, so a baseline stored there is absent
// in the cloud. It is a record for local checks, not an input to the build.
if (file.startsWith("dist/")) {
console.log(`skipped ${file} (dist/ is not part of this checkout)`)
continue
}
throw new Error(`Missing ${file} and ${file}.gz`)
}
const raw = gunzipSync(readFileSync(packed))
if (sha(raw) !== expected.sha256) throw new Error(`${file}.gz does not match the recorded sha256`)
writeFileSync(target, raw)
console.log(`restored ${file} (${raw.length} bytes)`)
}
}
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
const command = process.argv[2]
if (command === "pack") pack()
else if (command === "restore") restore()
else {
console.error("Usage: bun scripts/large-files.mjs <pack|restore>")
process.exit(1)
}
}