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/source-render-cache.ts
/** Phase-local memoization for core 0.0.2320's repeated capacitor net lookups.
* Connectivity is already constructed before SourceRender. Cache only returned
* live Port/Trace references during that synchronous phase; clear immediately
* afterward. No net, route, capacitor limit or DRC record is changed.
*/
import {Board,Port,Trace} from '@tscircuit/core'
export const sourceCacheStats={hit:0,miss:0,inactive:0}
const reverse=new WeakMap<object,Map<object,Map<object,unknown[]>>>()
const active=new WeakMap<object,Map<object,Map<string,unknown>>>()
const bp=Board.prototype as any, original=bp.runRenderPhaseForChildren
bp.runRenderPhaseForChildren=function(phase:string){
if(phase!=='SourceRender'||process.env.BLDC_DISABLE_SOURCE_CACHE==='1')return original.call(this,phase)
active.set(this.root,new Map());reverse.set(this.root,new Map())
try{return original.call(this,phase)}finally{active.delete(this.root);reverse.delete(this.root)}
}
for(const [proto,names] of [[Port.prototype,['_getDirectlyConnectedTraces','_getPortsInternallyConnectedToThisPort']],[Trace.prototype,['_findConnectedPorts','_findConnectedNets']]] as const){
for(const name of names){
const prior=(proto as any)[name]
;(proto as any)[name]=function(...args:unknown[]){
const scope=active.get(this.root)
if(!scope||args.length){sourceCacheStats.inactive++;return prior.apply(this,args)}
if(name==='_getDirectlyConnectedTraces'){
const sub=this.getSubcircuit(),bySub=reverse.get(this.root)!
let index=bySub.get(sub)
if(!index){
index=new Map();bySub.set(sub,index)
for(const trace of sub.selectAll('trace')){
if(trace._couldNotFindPort)continue
try{
const result=trace._findConnectedPorts()
if(!result.allPortsFound)continue
for(const port of new Set<object>(result.portsWithSelectors.map((p:any)=>p.port))){
let list=index.get(port);if(!list){list=[];index.set(port,list)};list.push(trace)
}
}catch(e){if((e as Error).constructor.name!=='TraceConnectionError')throw e}
}
}
return index.get(this)??[]
}
let cache=scope.get(this);if(!cache){cache=new Map();scope.set(this,cache)}
if(!cache.has(name)){sourceCacheStats.miss++;cache.set(name,prior.call(this))}else sourceCacheStats.hit++
return cache.get(name)
}
}
}