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-controller

In 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/assembly-geometry.ts

import { createHash } from "node:crypto"

// Source-filesystem metadata differs between a local checkout and the registry.
// The portable assembly is tied to the actual PCB/CAD geometry instead.
export function hashPcbGeometry(rows: Record<string, any>[]): string {
  const canonical = (value: any): any => {
    if (Array.isArray(value)) return value.map(canonical)
    if (value && typeof value === "object") return Object.fromEntries(
      Object.keys(value).sort().filter(k => value[k] != null)
        .map(k => [k, canonical(value[k])]),
    )
    if (typeof value === "string") return value.replace(/&cachebust_origin=[^&]*/g, "")
    return value
  }
  const geometry = rows.filter(r => r.type.startsWith("pcb_") ||
    (r.type === "cad_component" && r.pcb_component_id))
  return createHash("sha256").update(JSON.stringify(canonical(geometry))).digest("hex")
}