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.
enclosure/labels.tsx
import modeling from "@jscad/modeling"
import { jscad } from "jscad-fiber/headless"
import { body, design, motorPorts } from "./dimensions"
export const labelStroke = .4
export const labelSpacing = 1.42
export type PanelLabel = {text:string;x:number;y:number;height:number;center?:boolean}
export const lidLabels: PanelLabel[] = [
{text:"SPEED",x:-57,y:62,height:2.1},
{text:"OFF",x:-63,y:40.8,height:1.8},
{text:"POWER",x:-63,y:35.5,height:1.6},
{text:"ON",x:-63,y:30.5,height:1.8},
...[{text:"ARM",x:-55.3},{text:"UP",x:-43.1},{text:"DOWN",x:-34.2},{text:"OK",x:-21.1},{text:"BACK",x:-12.2}].map(v=>({...v,y:32.8,height:1.9})),
// Pinholes: smaller lettering, close above each hole.
...[{text:"RESET",x:-.9},{text:"BOOT",x:10.8}].map(v=>({...v,y:30.6,height:1.5})),
{text:"ENCODER",x:24,y:22,height:1.4},
{text:"BLDC",x:body.x,y:-5,height:10,center:true},
{text:"RP2040",x:body.x,y:-12,height:2.2,center:true},
...motorPorts.map((q,i)=>({text:["U","V","W"][i],x:q.x-.7,y:67,height:1.6})),
{text:"USB-PD",x:-60,y:-3,height:1.6},
{text:"USB DATA",x:-60,y:-16,height:1.6},
]
export function labelLines({text,x,y,height,center=false}: PanelLabel) {
const lines=modeling.text.vectorText({input:text,height:height/1.5,xOffset:x,yOffset:y,letterSpacing:labelSpacing}) as number[][][]
if(!center)return lines
const xs=lines.flat().map(p=>p[0])
const offset=x-(Math.min(...xs)+Math.max(...xs))/2
return lines.map(line=>line.map(([px,py])=>[px+offset,py]))
}
// Real engraved geometry from JSCAD's vector font, shared by TSX and STL export.
export function EngravedText({text,x,y,height=2,z=design.top-.4}: {text:string;x:number;y:number;height?:number;z?:number}) {
const lines=labelLines({text,x,y,height})
const radius=labelStroke/2
return <>{lines.flatMap((line,i)=>line.slice(1).map((p,j)=>{
const a=line[j], dx=p[0]-a[0], dy=p[1]-a[1]
const length=Math.hypot(dx,dy)
if(length<.0001)return null
return <jscad.translate key={`${i}:${j}`} offset={[(p[0]+a[0])/2,(p[1]+a[1])/2,z+.5]}>
<jscad.rotate angles={[0,0,Math.atan2(dy,dx)]}>
<jscad.cuboid size={[length+radius,2*radius,1]} />
</jscad.rotate>
</jscad.translate>
}))}</>
}