mohan-bee/pocket-mic-tx-assembly
Pocket-sized ESP32-S3 wireless microphone transmitter with digital MEMS mic, 2.4‑GHz antenna/RF matching, USB/QSPI flash, Li‑ion charging and buck-boost power management, status LED, control key, and protective clip-on enclosure.
- Version
- 0.0.3
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone mohan-bee/pocket-mic-tx-assembly # download the package files into ./pocket-mic-tx-assembly
tsci add mohan-bee/pocket-mic-tx-assembly # add it to your project as @tsci/mohan-bee.pocket-mic-tx-assemblyIn 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.
source/compose-assembly.mts
import assert from "node:assert/strict"
import { readFileSync, writeFileSync } from "node:fs"
import { resolve } from "node:path"
type Entry = { type: string; [key: string]: unknown }
const [pcbPath, mechanicsPath, outputPath, assetDirectory, diagramPath] = process.argv.slice(2)
assert(pcbPath && mechanicsPath && outputPath && diagramPath, "Expected PCB, mechanical and diagram Circuit JSON, and an output path")
const read = (path: string): Entry[] => JSON.parse(readFileSync(path, "utf8"))
const pcb = read(pcbPath)
const mechanics = read(mechanicsPath)
const diagram = read(diagramPath).filter((entry) => entry.type.startsWith("system_block_"))
assert.equal(pcb.filter((entry) => entry.type === "pcb_board").length, 1, "Expected one C5 PCB")
assert(!mechanics.some((entry) => entry.type === "pcb_board"), "Build the native assembly without a PCB before merging")
assert(diagram.some((entry) => entry.type === "system_block_page"), "Expected a compiled system diagram")
const assemblyIds = new Map<string, string>()
for (const entry of mechanics) {
const id = entry[`${entry.type}_id`]
if (typeof id === "string") assemblyIds.set(id, `enclosure_${id}`)
const model = entry.model_glb_url
const localModel = typeof model === "string" ? /^\.\/(?:source\/)?(models\/[\w-]+\.glb)$/.exec(model)?.[1] : undefined
if (localModel) {
assert(assetDirectory, `Missing asset directory for ${model}`)
const bytes = readFileSync(resolve(assetDirectory, localModel))
assert.equal(bytes.toString("ascii", 0, 4), "glTF", `${model} is not a GLB model`)
entry.model_glb_url = `data:model/gltf-binary;base64,${bytes.toString("base64")}`
}
}
// The JSON board inflater reconstructs the netlist and omits some existing PCB
// geometry. Compose the two compiled documents instead, preserving C5 verbatim.
const distinctMechanics: Entry[] = JSON.parse(JSON.stringify(mechanics, (_key, value) =>
typeof value === "string" ? assemblyIds.get(value) ?? value : value))
writeFileSync(outputPath, `${JSON.stringify([...pcb, ...distinctMechanics, ...diagram])}\n`)