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
symbol-text-compat.ts
import { SchematicText, Port } from "tscircuit"
// core 0.0.2050 attaches custom-symbol text to schematic_symbol_id but omits
// schematic_component_id. Native autolayout and SVG bounds use the latter.
// Associate the text with its owner before layout; all positions still come
// from the imported local artwork and tscircuit's layout engine.
const prototype = SchematicText.prototype as any
const marker = Symbol.for("nema23.symbol-text-owner")
if (!prototype[marker]) {
const render = prototype.doInitialSchematicPrimitiveRender
prototype.doInitialSchematicPrimitiveRender = function () {
render.call(this)
const owner = this.getParentNormalComponent()
if (this.schematic_text_id && owner?.schematic_component_id) {
const text = this.root.db.schematic_text.get(this.schematic_text_id)
if (text && !text.schematic_component_id) {
this.root.db.schematic_text.update(this.schematic_text_id, {
schematic_component_id: owner.schematic_component_id,
})
}
}
}
prototype[marker] = true
}
// A custom two-pin resistor drawing is already self-identifying. Core normally
// suppresses primitive resistor pin names, but its JSON symbol path prints the
// inherited "anode/cathode" aliases over this small supplier symbol.
const portPrototype = Port.prototype as any
if (!portPrototype[marker]) {
const label = portPrototype._getBestDisplayPinLabel
portPrototype._getBestDisplayPinLabel = function () {
const owner = this.getParentNormalComponent()
if (owner?.componentName === "Resistor" && owner.props.symbol) return undefined
return label.call(this)
}
portPrototype[marker] = true
}