astra-abse/t113-s3

Allwinner T113-S3 / JLCPCB C5197687: native saved fanout, LCD top, storage right, 127 perimeter exits, 30 decoupling capacitors, connected GND planes; clean DRC and shorts, all 29 vias connected.

Version
1.2.0
License
MIT
Stars
0

src/decoupling.tsx

import { Fragment } from "react";
import layout from "./decoupling-layout.json";

export const DECOUPLING = layout;
export const capacitorName = (c: (typeof layout)[number]) =>
	`C${c.name.startsWith("C_B") ? 200 + c.pin : c.pin}`;
export function Decoupling({
	connectionsOnly = false,
}: { connectionsOnly?: boolean }) {
	return (
		<>
			{layout.map((c, i) => {
				const bulk = c.name.startsWith("C_B");
				const base = layout.find((d) => d.name === `C_D${c.pin}`)!;
				const from = bulk ? `${capacitorName(base)}.pin1` : `U1.pin${c.pin}`;
				const sx = -1 + (i % 6) * 4,
					sy = 8 - Math.floor(i / 6) * 4;
				return (
					<Fragment key={c.name}>
						{!connectionsOnly && (
							<capacitor
								schSectionName={`section_${c.name}`}
								name={capacitorName(c)}
								capacitance={c.value}
								maxVoltageRating={6.3}
								maxDecouplingTraceLength={25}
								footprint="0402"
								layer="bottom"
								pcbX={c.x}
								pcbY={c.y}
								pcbRotation={c.rotation}
								schX={sx}
								schY={sy}
								schRotation={270}
							>
								<symbol>
									<schematicline
										x1={0}
										y1={0.3}
										x2={0}
										y2={0.1}
										strokeWidth={0.025}
									/>
									<schematicline
										x1={0}
										y1={-0.1}
										x2={0}
										y2={-0.3}
										strokeWidth={0.025}
									/>
									<schematicline
										x1={-0.3}
										y1={0.1}
										x2={0.3}
										y2={0.1}
										strokeWidth={0.025}
									/>
									<schematicline
										x1={-0.3}
										y1={-0.1}
										x2={0.3}
										y2={-0.1}
										strokeWidth={0.025}
									/>
									<schematictext
										text={capacitorName(c)}
										schX={0.4}
										schY={0.2}
										anchor="left"
										fontSize={0.18}
									/>
									<schematictext
										text={c.value}
										schX={0.4}
										schY={-0.2}
										anchor="left"
										fontSize={0.18}
									/>
								</symbol>
							</capacitor>
						)}
						{connectionsOnly && (
							<>
								<trace
									name={`PWR_${c.name}`}
									schDisplayLabel={c.net}
									from={from}
									to={`${capacitorName(c)}.pin1`}
									thickness={0.12}
								/>
								<trace
									name={`GND_${c.name}`}
									schDisplayLabel="GND"
									from={`${capacitorName(c)}.pin2`}
									to="net.GND"
								/>
							</>
						)}
					</Fragment>
				);
			})}
			{!connectionsOnly && (
				<>
					<schematictext
						text="DECOUPLING / LOCAL BYPASS"
						schX={9}
						schY={12}
						fontSize={0.5}
					/>
					<schematictext
						text="30 capacitors • bottom-side assembly • 6.3 V minimum"
						schX={9}
						schY={11}
						fontSize={0.25}
					/>
				</>
			)}
		</>
	);
}