astra/f1c100s

This code defines and renders a four-layer, top-mounted F1C100S module with detailed pin assignments, schematic annotations, and layout profiles, facilitating design, validation, and routing of the hardware including support for decoupling capacitors, crystal oscillators, and external connectors.

Version
0.11.0
License
unset
Stars
0

scripts/check-preview-pours.ts

import type { CircuitJson } from "circuit-json";
import { MODULE_SIZE } from "../src/profiles";

/** Verify that the preview emitted grounded, inset copper on every layer. */
export function checkPreviewPours(json: CircuitJson): string[] {
	const data = json as any[],
		errors: string[] = [];
	const pours = data.filter((e) => e.type === "pcb_copper_pour");
	const ground = data.find(
		(e) => e.type === "source_trace" && e.name === "SOC_GND_external",
	);
	const netId = ground?.connected_source_net_ids?.[0];
	if (!netId) errors.push("Preview ground is not connected to the module");
	for (const layer of ["top", "inner1", "inner2", "bottom"])
		if (!pours.some((p) => p.layer === layer))
			errors.push(`Missing ${layer} ground pour`);
	for (const p of pours) {
		if (p.source_net_id !== netId)
			errors.push("Preview pour uses the wrong ground net");
		const vertices = p.brep_shape?.outer_ring?.vertices ?? [];
		if (vertices.length < 3) errors.push("Empty preview pour geometry");
		if (!p.covered_with_solder_mask)
			errors.push("Preview pour must be solder-mask covered");
		if (
			vertices.some(
				(v: any) =>
					Math.max(Math.abs(v.x), Math.abs(v.y)) > MODULE_SIZE / 2 - 0.3 + 1e-5,
			)
		)
			errors.push("Preview pour exceeds its board-edge margin");
	}
	return errors;
}