imrishabh18/rp2040-motor-controller
An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.
- Version
- 1.0.42
- License
- unset
- Stars
- 3
scripts/snapshot-clock.ts
import { readFileSync, writeFileSync } from 'node:fs'
import sharp from 'sharp'
const svg = readFileSync('dist/schematic/controller.svg', 'utf8')
await sharp(Buffer.from(svg)).flatten({background:'#f5f1ed'}).png().toFile('../controller-auto-layout.png')
const matrix = svg.match(/data-real-to-screen-transform="matrix\(([^)]+)\)"/)![1]!.split(',').map(Number)
const [a,b,c,d,e,f] = matrix as [number,number,number,number,number,number]
const xMin=8.3, xMax=14.5, yMin=2.4, yMax=8.7
const x=a*xMin+e, y=d*yMax+f, width=a*(xMax-xMin), height=-d*(yMax-yMin)
const cropped=svg.replace(/width="1600" height="1100"/,`width="1100" height="${Math.round(1100*height/width)}" viewBox="${x} ${y} ${width} ${height}"`)
writeFileSync('../clock-auto-layout.svg',cropped)
await sharp(Buffer.from(cropped)).flatten({background:'#f5f1ed'}).png().toFile('../clock-auto-layout.png')
console.log('Saved full controller and clock close-up snapshots')
