imrishabh18/nema-23-stepper-controller
A 57 mm four-layer RP2040 NEMA23 stepper-controller PCB with USB‑C/USB‑PD power input, protected motor rail, DRV8452 dual-winding driver, bidirectional current sensing, temperature/enable interlock, optional magnetic encoder, RGB LED and buzzer status indicators, and motor/test connectors.
- Version
- 1.2.3
- License
- unset
- Stars
- 0
usb-c-compat.ts
import { Connector } from "tscircuit"
// Core 0.0.2050's native USB-C arrangement includes only VBUS1/2 and GND1/2.
// The retained 20-contact power receptacle exposes four of each. Include those
// additional physical contacts in the native power/ground rows; the connector
// engine still determines every pin position, spacing and USB illustration.
const prototype = Connector.prototype as any
const marker = Symbol.for("nema23.usbc-extra-supply-contacts")
if (!prototype[marker]) {
const arrange = prototype._getSchematicPortArrangement
prototype._getSchematicPortArrangement = function () {
const arrangement = arrange.call(this)
if (this._parsedProps.standard !== "usb_c" || !arrangement?.rightSide?.pins) return arrangement
const right = [...arrangement.rightSide.pins]
const used = new Set([...right, ...(arrangement.bottomSide?.pins ?? [])])
const rails = this.selectAll("port").flatMap((port: any) => {
const label = port.getNameAndAliases().find((alias: string) => /^(VBUS|GND)\d+$/i.test(alias))
return label ? [{ pin: port.props.pinNumber, label: label.toUpperCase() }] : []
})
for (const prefix of ["VBUS", "GND"]) {
const family = rails.filter((port: any) => port.label.startsWith(prefix))
.sort((a: any, b: any) => Number(a.label.slice(prefix.length)) - Number(b.label.slice(prefix.length)))
let after = Math.max(...family.map((port: any) => right.indexOf(port.pin)))
for (const port of family) if (!used.has(port.pin)) {
right.splice(++after, 0, port.pin)
used.add(port.pin)
}
}
return { ...arrangement, rightSide: { ...arrangement.rightSide, pins: right } }
}
prototype[marker] = true
}