AnasSarkiz/magnetic-shutter-remote-r8
A USB‑C rechargeable battery-powered ESP32‑C3 wireless controller with Li‑ion charging, protected 3.3‑V buck‑boost regulation, thermal/safety monitoring, status LEDs, buttons, programming UART, crystal clock, and 2.4‑GHz antenna matching network.
- Version
- 0.4.0-prototype
- License
- unset
- Stars
- 0
src/r9-usb-trace-paths.ts
import { applyToPoint, translate } from "transformation-matrix";
import { z } from "zod";
import { r9UsbSinkGroundPaths } from "./r9-ground-returns";
import type { FanoutTracePath } from "@tscircuit/core";
// Board-world XY mm,+Z top. Native HRO CC contacts terminate at their
// separate5.1k sink resistors; neither is joined to the other CC contact.
export const r9UsbTracePaths: FanoutTracePath[] = [
{
connection: "J1.pin13",
route: [
{
route_type: "wire",
x: 3.1999555,
y: 21.8111568,
width: 0.3,
layer: "top",
},
{ route_type: "wire", x: 3.202, y: 20.5, width: 0.3, layer: "top" },
{
route_type: "via",
x: 3.202,
y: 20.5,
from_layer: "top",
to_layer: "bottom",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
],
},
{
connection: "J1.pin14",
route: [
{
route_type: "wire",
x: -3.2000063,
y: 21.8110552,
width: 0.3,
layer: "top",
},
{ route_type: "wire", x: -6, y: 21.8110552, width: 0.3, layer: "top" },
{
route_type: "via",
x: -6,
y: 21.8110552,
from_layer: "top",
to_layer: "bottom",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
],
},
{
connection: "J1.pin15",
route: [
{
route_type: "wire",
x: -2.4001603,
y: 21.8110552,
width: 0.508,
layer: "top",
},
{
route_type: "wire",
x: -2.4001603,
y: 19.7,
width: 0.508,
layer: "top",
},
{ route_type: "wire", x: -1.8, y: 19.7, width: 0.508, layer: "top" },
{
route_type: "via",
x: -1.8,
y: 19.7,
from_layer: "top",
to_layer: "bottom",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
{ route_type: "wire", x: -1.8, y: 19.7, width: 0.508, layer: "bottom" },
{ route_type: "wire", x: -1.8, y: 18.7, width: 0.508, layer: "bottom" },
{ route_type: "wire", x: 0.9, y: 18.7, width: 0.508, layer: "bottom" },
{ route_type: "wire", x: 1.4, y: 18, width: 0.508, layer: "bottom" },
{ route_type: "wire", x: 3.5, y: 18, width: 0.508, layer: "bottom" },
...usbInputReservoirTail(),
],
},
{
connection: "J1.pin16",
route: [
{
route_type: "wire",
x: 2.3999571,
y: 21.8112203,
width: 0.508,
layer: "top",
},
{ route_type: "wire", x: 2.3999571, y: 20.5, width: 0.508, layer: "top" },
{
route_type: "via",
x: 2.3999571,
y: 20.5,
from_layer: "top",
to_layer: "bottom",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
{
route_type: "wire",
x: 2.3999571,
y: 20.5,
width: 0.508,
layer: "bottom",
},
{
route_type: "wire",
x: 2.3999571,
y: 20,
width: 0.508,
layer: "bottom",
},
{ route_type: "wire", x: 3.5, y: 18, width: 0.508, layer: "bottom" },
...usbInputReservoirTail(),
],
},
...[
{ connection: "J1.pin1", x: -4.325112, y: 22.5795068, endX: -6 },
{ connection: "J1.pin2", x: -4.325112, y: 26.7593308, endX: -6 },
{ connection: "J1.pin3", x: 4.325112, y: 26.7593308, endX: 6 },
{ connection: "J1.pin4", x: 4.325112, y: 22.5795068, endX: 6 },
].map(
({ connection, x, y, endX }): FanoutTracePath => ({
connection,
route: [
{ route_type: "wire", x, y, width: 0.3, layer: "bottom" },
{ route_type: "wire", x: endX, y, width: 0.3, layer: "bottom" },
],
}),
),
{
connection: "J1.pin6",
route: [
{
route_type: "wire",
x: 1.249934,
y: 21.8111568,
width: 0.15,
layer: "top",
},
{ route_type: "wire", x: 1.249934, y: 20.2, width: 0.15, layer: "top" },
{
route_type: "via",
x: 1.249934,
y: 20.2,
from_layer: "top",
to_layer: "bottom",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
{
route_type: "wire",
x: 1.249934,
y: 20.2,
width: 0.15,
layer: "bottom",
},
{
route_type: "wire",
x: -4.753364,
y: 20.2,
width: 0.15,
layer: "bottom",
},
{
route_type: "via",
x: -4.753364,
y: 20.2,
from_layer: "bottom",
to_layer: "top",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
{ route_type: "wire", x: -4.753364, y: 20.2, width: 0.15, layer: "top" },
{ route_type: "wire", x: -4.753364, y: 19, width: 0.15, layer: "top" },
],
},
{
connection: "J1.pin12",
route: [
{
route_type: "wire",
x: -1.75006,
y: 21.8111568,
width: 0.15,
layer: "top",
},
{ route_type: "wire", x: -1.75006, y: 20.65, width: 0.15, layer: "top" },
{
route_type: "wire",
x: -0.753364,
y: 19.653304,
width: 0.15,
layer: "top",
},
{ route_type: "wire", x: -0.753364, y: 19, width: 0.15, layer: "top" },
],
},
{
connection: "R2.pin2",
route: [
{ route_type: "wire", x: 0.753364, y: 19, width: 0.3, layer: "top" },
{ route_type: "wire", x: 2, y: 19, width: 0.3, layer: "top" },
{
route_type: "via",
x: 2,
y: 19,
from_layer: "top",
to_layer: "bottom",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
],
},
];
function usbInputReservoirTail(): FanoutTracePath["route"] {
return [
{ route_type: "wire", x: 5.999976, y: 18.3, width: 0.508, layer: "bottom" },
{
route_type: "via",
x: 5.999976,
y: 18.3,
from_layer: "bottom",
to_layer: "top",
via_diameter: 0.45,
via_hole_diameter: 0.3,
},
{ route_type: "wire", x: 5.999976, y: 18.3, width: 0.508, layer: "top" },
{ route_type: "wire", x: 5.999976, y: 19.5, width: 0.508, layer: "top" },
];
}
// Explicit physical footprint region, independent of the long completed feeds.
export const r9UsbFrameAnchor = { x: -0.11574545, y: 23.1136629 };
export const r9UsbFanoutPaths = [
...r9UsbTracePaths,
...r9UsbSinkGroundPaths,
].map((path) => ({
...path,
route: path.route.map((point) => {
const moved = applyToPoint(
translate(-r9UsbFrameAnchor.x, -r9UsbFrameAnchor.y),
{ x: z.number().parse(point.x), y: z.number().parse(point.y) },
);
return { ...point, x: moved.x, y: moved.y };
}),
}));