rushabhcodes/simple-usb-c-pd-peltier-driver
Reference-based four-layer USB-C PD Peltier driver with RP2040 control, adjustable voltage/current limits, fan power and temperature probes.
- Version
- 0.3.1
- License
- MIT
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone rushabhcodes/simple-usb-c-pd-peltier-driver # download the package files into ./simple-usb-c-pd-peltier-driver
tsci add rushabhcodes/simple-usb-c-pd-peltier-driver # add it to your project as @tsci/rushabhcodes.simple-usb-c-pd-peltier-driverIn 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.
tests/preview-archive.test.ts
import { expect, test } from "bun:test"
import { chunkPreview, joinPreview, validatePreviewManifest } from "../scripts/preview-archive"
test("bounded preview chunks reconstruct the exact archive", () => {
const input = Buffer.from("the-four-boards-and-local-viewer".repeat(10))
const { manifest, chunks } = chunkPreview(input, 17)
expect(chunks.every(c => c.length <= 17)).toBe(true)
expect(joinPreview(manifest, chunks)).toEqual(input)
})
test("missing, reordered and corrupted preview chunks are rejected", () => {
const { manifest, chunks } = chunkPreview(Buffer.from("abcdefghijklmno"), 5)
expect(() => joinPreview(manifest, chunks.slice(1))).toThrow()
expect(() => joinPreview(manifest, [...chunks].reverse())).toThrow()
const corrupt = chunks.map(c => Buffer.from(c)); corrupt[0]![0] ^= 1
expect(() => joinPreview(manifest, corrupt)).toThrow("checksum")
})
test("preview manifests reject invalid part paths and sizes", () => {
const { manifest } = chunkPreview(Buffer.from("valid preview"))
const bad = structuredClone(manifest); bad.parts[0]!.file = "../../private-config"
expect(() => validatePreviewManifest(bad)).toThrow()
const wrong = structuredClone(manifest); wrong.bytes++
expect(() => validatePreviewManifest(wrong)).toThrow()
expect(() => chunkPreview(Buffer.alloc(0))).toThrow()
})