imrishabh18/nema-23-stepper-controller

A four-layer NEMA23 stepper motor controller PCB featuring an RP2040 MCU, DRV8452 dual-phase driver, USB‑C PD power input/protection, current and temperature sensing, status LED/buzzer, and optional magnetic encoder.

Version
1.3.2
License
unset
Stars
1

imports/selected-parts-engine.ts

import type { PartsEngine } from '@tscircuit/props'
import type { CircuitJson } from 'circuit-json'
import ch224a from './footprint-data/C42459160.json'
import tps26630rget from './footprint-data/C2864391.json'
import bulkCapacitor from './footprint-data/C178712.json'
import retainedSelections from './retained-supplier-selections.json'

// Supplier CAD snapshots let core verify pin-1 orientation even offline.
// These are generated from the exact EasyEDA records, not inferred from our board.
const footprints: Record<string, CircuitJson> = {
  C42459160: ch224a as CircuitJson,
  C2864391: tps26630rget as CircuitJson,
  C178712: bulkCapacitor as CircuitJson,
}
export const selectedPartsEngine: PartsEngine = {
  findPart: ({ sourceComponent }) => {
    if ('supplier_part_numbers' in sourceComponent && sourceComponent.supplier_part_numbers) return sourceComponent.supplier_part_numbers
    const part = sourceComponent as unknown as Record<string, unknown>
    const retained = (retainedSelections as Record<string, {electrical: Record<string, unknown>; supplierPartNumbers: Record<string,string[]>}>)[String(part.name)]
    if (!retained) return {}
    for (const [key,value] of Object.entries(retained.electrical)) if (part[key] !== value) throw Error(`Re-source changed component ${part.name}: ${key}`)
    return retained.supplierPartNumbers
  },
  fetchPartCircuitJson: ({ supplierPartNumber }) => footprints[supplierPartNumber ?? ''],
}