gokul/usb3-sd-hub

Engineering draft: four-layer, computer-powered USB 3 hub with one USB-C host socket, two USB-C and two USB-A accessory sockets, and a full-size SD slot. Board and three schematic previews are available. Routing and production checks are incomplete; not fabrication ready.

Version
0.1.4
License
unset
Stars
0

design/schematic-note-layout.ts

import { SchematicText } from "tscircuit";

Reflect.set(
	SchematicText.prototype,
	"doInitialSchematicLayout",
	function (this: SchematicText) {
		if (
			this._getBoard()?.name !== "USB_HUB_BOARD" ||
			this._parsedProps.fontSize !== 0.22 ||
			!this.schematic_text_id
		)
			return;
		const note = this.root?.db.schematic_text.get(this.schematic_text_id);
		if (!note) return;
		const projectedChipName = /^([A-Z][A-Z0-9_]+): /.exec(note.text)?.[1];
		const projectedChip = projectedChipName
			? this.getSubcircuit().selectOne(`.${projectedChipName}`)
			: null;
		const schematicComponentId =
			this.parent?.schematic_component_id ??
			projectedChip?.schematic_component_id;
		if (!schematicComponentId) return;
		const chip = this.root?.db.schematic_component.get(schematicComponentId);
		if (!chip) return;
		this.root?.db.schematic_text.update(this.schematic_text_id, {
			schematic_component_id: schematicComponentId,
			position: {
				x: chip.center.x,
				y: chip.center.y - chip.size.height / 2 - 0.8,
			},
		});
	},
);