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/pcb-position-compatibility.ts
import { Group, NormalComponent } from "tscircuit";
// Scoped compatibility fix for core #2841. core writes resolved millimetre
// numbers to display_offset_x/y, whose Circuit JSON contract requires strings.
// This repairs the renderer's metadata after native placement. Copper, connectivity,
// clearances and physical component positions are not changed.
const componentLayout = NormalComponent.prototype.doInitialPcbLayout;
NormalComponent.prototype.doInitialPcbLayout = function () {
componentLayout.call(this);
if (this._getBoard()?.name !== "USB_HUB_BOARD" || !this.pcb_component_id)
return;
const pcbComponent = this.root?.db.pcb_component.get(this.pcb_component_id);
if (!pcbComponent) return;
this.root?.db.pcb_component.update(this.pcb_component_id, {
...(typeof pcbComponent.display_offset_x === "number"
? { display_offset_x: `${pcbComponent.display_offset_x}mm` }
: {}),
...(typeof pcbComponent.display_offset_y === "number"
? { display_offset_y: `${pcbComponent.display_offset_y}mm` }
: {}),
});
};
const groupLayout = Group.prototype.doInitialPcbLayout;
Group.prototype.doInitialPcbLayout = function () {
groupLayout.call(this);
if (this._getBoard()?.name !== "USB_HUB_BOARD" || !this.pcb_group_id) return;
const pcbGroup = this.root?.db.pcb_group.get(this.pcb_group_id);
if (!pcbGroup) return;
this.root?.db.pcb_group.update(this.pcb_group_id, {
...(typeof pcbGroup.display_offset_x === "number"
? { display_offset_x: `${pcbGroup.display_offset_x}mm` }
: {}),
...(typeof pcbGroup.display_offset_y === "number"
? { display_offset_y: `${pcbGroup.display_offset_y}mm` }
: {}),
});
};