rushabhcodes/ESP32-E-Reader
Battery-powered ESP32-C3 e-reader board with USB-C LiPo charging/protection, buck-boost 3.3 V supply, Wi‑Fi MCU, e-paper and microSD interfaces, display charge-pump rails, and tactile power/navigation controls.
- Version
- 1.0.87
- License
- unset
- Stars
- 3
design-data.ts
import { schematicGroups, schematicLayout } from "./schematic-layout";
import displayConnection from "./assets/enclosure/display-connection.json";
/** Static electrical, placement, and sourcing data for the Rev. B board. */
export type SectionName =
| "battery_usb"
| "mcu_power"
| "display_power"
| "storage"
| "controls";
export type PcbPlacement = {
pcbX: number;
pcbY: number;
pcbRotation?: number;
layer?: "top" | "bottom";
};
export type PassiveSpec = PcbPlacement & {
name: string;
value: string;
footprint: string;
section: SectionName;
};
export type ChipSpec = PcbPlacement & {
name: string;
value: string;
footprint: string;
pins: readonly string[];
noConnect?: readonly string[];
section: SectionName;
kind?: "chip" | "connector" | "pushbutton";
};
export const lcscGroups: Array<[string, string[]]> = [
["C29936", ["C1", "C13"]],
["C96446", ["C5", "C7", "C10", "C11", "C14", "C24"]],
["C19702", ["C6"]],
["C14663", ["C2", "C4", "C8", "C9", "C12", "C30"]],
["C1779", ["C3", "C15", "C16", "C17", "C22", "C23", "C28", "C29"]],
["C49678", ["C20", "C32"]],
["C3039694", ["C19"]],
["C12891", ["C34", "C35", "C36", "C37", "C38"]],
["C28323", ["C21", "C25", "C27"]],
["C22790", ["R1"]],
["C98220", ["R4", "R10", "R11", "R18", "R19", "R20", "R21", "R23", "R30", "R31"]],
["C25803", ["R12", "R13", "R24", "R25", "R29"]],
["C23179", ["R5", "R14"]],
["C22935", ["R16"]],
["C137549", ["R17"]],
["C125758", ["R27", "R28"]],
["C23189", ["R3"]],
["C4190", ["R6", "R32"]],
["C23186", ["R7", "R8"]],
["C3013546", ["R9"]],
["C13167", ["R15"]],
["C133195", ["L1"]],
["C84256", ["D1"]],
["C82046", ["D2", "D3", "D4"]],
["C173752", ["BT1"]],
["C165948", ["J1"]],
["C324726", ["J2"]],
["C114218", ["J4"]],
["C2830320", ["Q1"]],
["C469327", ["Q2"]],
["C15220", ["U1"]],
["C7519", ["U2"]],
["C2927799", ["U3"]],
["C2926676", ["U4"]],
["C202140", ["U5"]],
["C133190", ["L2"]],
["C388883", ["S1", "S2"]],
["C139797", ["SW2", "SW3", "SW4", "SW6"]],
["C431541", ["SW7"]],
];
export const lcscByRef = new Map(
lcscGroups.flatMap(([partNumber, references]) =>
references.map((reference) => [reference, partNumber] as const),
),
);
export const supplierPartNumbersFor = (reference: string) => {
const partNumber = lcscByRef.get(reference);
return partNumber ? { jlcpcb: [partNumber] } : undefined;
};
export const kicad = (path: string) => `kicad:${path}`;
export const FP = {
c0603: "0603",
c0805: "0805",
c1206: "1206",
r0603: "0603",
r0805: "0805",
} as const;
export const polarizedPinLabels = {
// JEDEC diode packages use pad 1 for K and pad 2 for A.
pin1: "cathode",
pin2: "anode",
} as const;
export const capacitors: PassiveSpec[] = [
{
name: "C1",
value: "1uF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: -11.150000000000006,
pcbY: 37.68,
pcbRotation: 180,
layer: "top",
},
{
name: "C2",
value: "100nF",
footprint: FP.c0603,
section: "battery_usb",
pcbX: 21.5,
pcbY: 20,
pcbRotation: 0,
layer: "top",
},
{
name: "C3",
value: "4.7uF",
footprint: FP.c0805,
section: "battery_usb",
pcbX: 17,
pcbY: 20,
pcbRotation: 0,
layer: "top",
},
{
name: "C4",
value: "100nF",
footprint: FP.c0603,
section: "battery_usb",
pcbX: 20.57499999999999,
pcbY: 40.9675,
pcbRotation: 90,
layer: "top",
},
{
name: "C5",
value: "10uF",
footprint: FP.c0603,
section: "battery_usb",
pcbX: 18.724999999999994,
pcbY: 40.9675,
pcbRotation: 90,
layer: "top",
},
{
name: "C6",
value: "10uF",
footprint: FP.c0603,
section: "battery_usb",
pcbX: -26.525599999999997,
pcbY: 39.012,
pcbRotation: 90,
layer: "top",
},
{
name: "C7",
value: "10uF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: -11.150000000000006,
pcbY: 39.18,
pcbRotation: 180,
layer: "top",
},
{
name: "C8",
value: "100nF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: -11.150000000000006,
pcbY: 40.69,
pcbRotation: 180,
layer: "top",
},
{
name: "C9",
value: "100nF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: 6,
pcbY: 7,
pcbRotation: -90,
layer: "top",
},
{
name: "C10",
value: "10uF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: 6,
pcbY: 10,
pcbRotation: -90,
layer: "top",
},
{
name: "C11",
value: "10uF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: 6,
pcbY: 4,
pcbRotation: -90,
layer: "top",
},
{
name: "C12",
value: "100nF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: -7.530000000000001,
pcbY: 15.64,
pcbRotation: -90,
layer: "top",
},
{
name: "C13",
value: "1uF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: -5.930000000000007,
pcbY: 15.64,
pcbRotation: -90,
layer: "top",
},
{
name: "C14",
value: "10uF",
footprint: FP.c0603,
section: "mcu_power",
pcbX: -4.310000000000002,
pcbY: 15.64,
pcbRotation: -90,
layer: "top",
},
{
name: "C15",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -20.2825,
pcbY: 6.420000000000002,
pcbRotation: 0,
layer: "top",
},
{
name: "C16",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -10.300000000000011,
pcbY: 1.3100000000000023,
pcbRotation: 90,
layer: "top",
},
{
name: "C17",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -15.280000000000001,
pcbY: 4.95,
pcbRotation: 180,
layer: "top",
},
{
name: "C19",
value: "10uF",
footprint: FP.c0805,
section: "display_power",
pcbX: 4.599999999999994,
pcbY: -10.657499999999999,
pcbRotation: 90,
layer: "top",
},
{
name: "C20",
value: "100nF",
footprint: FP.r0805,
section: "display_power",
pcbX: 2.4499999999999886,
pcbY: -10.657499999999999,
pcbRotation: 90,
layer: "top",
},
{
name: "C21",
value: "1uF",
footprint: FP.c0805,
section: "display_power",
pcbX: 0.4000000000000057,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C22",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -3.8000000000000114,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C23",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -8,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C24",
value: "10uF",
footprint: FP.c0603,
section: "storage",
pcbX: 11,
pcbY: -26,
pcbRotation: 0,
layer: "top",
},
{
name: "C25",
value: "1uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -1.6999999999999886,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C27",
value: "1uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -10.099999999999994,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C28",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: -5.900000000000006,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C29",
value: "4.7uF",
footprint: FP.c0805,
section: "display_power",
pcbX: 6.6200000000000045,
pcbY: -10.657499999999999,
pcbRotation: -90,
layer: "top",
},
{
name: "C30",
value: "100nF",
footprint: FP.c0603,
section: "storage",
pcbX: 11,
pcbY: -28,
pcbRotation: 0,
layer: "top",
},
{
name: "C32",
value: "100nF",
footprint: FP.c0805,
section: "display_power",
pcbX: -15.240000000000009,
pcbY: -4.54,
pcbRotation: 0,
layer: "top",
},
{ name: "C34", value: "22uF", footprint: FP.c1206, section: "battery_usb", pcbX: 13, pcbY: 23, pcbRotation: 90, layer: "top" },
{ name: "C35", value: "22uF", footprint: FP.c1206, section: "battery_usb", pcbX: 17, pcbY: 14, pcbRotation: 90, layer: "top" },
{ name: "C36", value: "22uF", footprint: FP.c1206, section: "mcu_power", pcbX: 11, pcbY: 1, pcbRotation: 90, layer: "top" },
{ name: "C37", value: "22uF", footprint: FP.c1206, section: "mcu_power", pcbX: 15, pcbY: 1, pcbRotation: 90, layer: "top" },
{ name: "C38", value: "22uF", footprint: FP.c1206, section: "mcu_power", pcbX: 19, pcbY: 1, pcbRotation: 90, layer: "top" },
];
export const resistors: PassiveSpec[] = [
{
name: "R1",
value: "12k",
footprint: FP.r0603,
section: "controls",
pcbX: 12,
pcbY: -32,
pcbRotation: 90,
layer: "top",
},
{
name: "R3",
value: "5.6k",
footprint: FP.r0603,
section: "controls",
pcbX: 15,
pcbY: -31,
pcbRotation: 90,
layer: "top",
},
{
name: "R4",
value: "10k",
footprint: FP.r0603,
section: "mcu_power",
pcbX: -11.159999999999997,
pcbY: 36.14,
pcbRotation: 180,
layer: "top",
},
{
name: "R5",
value: "470",
footprint: FP.r0603,
section: "battery_usb",
pcbX: -28.919999999999987,
pcbY: 30.39,
pcbRotation: 0,
layer: "top",
},
{
name: "R6",
value: "2.2k",
footprint: FP.r0603,
section: "controls",
pcbX: 28,
pcbY: -22,
pcbRotation: 90,
layer: "top",
},
{
name: "R7",
value: "5.1k",
footprint: FP.r0603,
section: "battery_usb",
pcbX: 19.2825,
pcbY: 29.86,
pcbRotation: 180,
layer: "top",
},
{
name: "R8",
value: "5.1k",
footprint: FP.r0603,
section: "battery_usb",
pcbX: 19.2825,
pcbY: 31.539999999999992,
pcbRotation: 180,
layer: "top",
},
{
name: "R9",
value: "2.5k",
footprint: FP.r0603,
section: "battery_usb",
pcbX: 8,
pcbY: 21,
pcbRotation: 270,
layer: "top",
},
{
name: "R10",
value: "10k",
footprint: FP.r0603,
section: "controls",
pcbX: -25.54249999999999,
pcbY: 17.069999999999993,
pcbRotation: 180,
layer: "top",
},
{
name: "R11",
value: "10k",
footprint: FP.r0603,
section: "controls",
pcbX: 19,
pcbY: -26,
pcbRotation: -90,
layer: "top",
},
{
name: "R12",
value: "100k",
footprint: FP.r0603,
section: "mcu_power",
pcbX: 19.257499999999993,
pcbY: 27.629999999999995,
pcbRotation: 180,
layer: "top",
},
{
name: "R13",
value: "100k",
footprint: FP.r0603,
section: "mcu_power",
pcbX: 19.24000000000001,
pcbY: 26.03,
pcbRotation: 0,
layer: "top",
},
{
name: "R14",
value: "470",
footprint: FP.r0603,
section: "battery_usb",
pcbX: -18.295999999999992,
pcbY: 35.608399999999996,
pcbRotation: 90,
layer: "top",
},
{
name: "R15",
value: "2.7k",
footprint: FP.r0603,
section: "battery_usb",
pcbX: -19.870800000000003,
pcbY: 35.608399999999996,
pcbRotation: 90,
layer: "top",
},
{
name: "R16",
value: "1M",
footprint: FP.r0603,
section: "display_power",
pcbX: -18.507499999999993,
pcbY: -9.409999999999997,
pcbRotation: 0,
layer: "top",
},
{
name: "R17",
value: "2.2",
footprint: FP.r0805,
section: "display_power",
pcbX: -15.680000000000007,
pcbY: -8.019999999999996,
pcbRotation: -90,
layer: "top",
},
{
name: "R18",
value: "10k",
footprint: FP.r0603,
section: "display_power",
pcbX: 3.710000000000008,
pcbY: -1.269999999999996,
pcbRotation: 90,
layer: "top",
},
{
name: "R19",
value: "10k",
footprint: FP.r0603,
section: "display_power",
pcbX: 6.889999999999986,
pcbY: -1.269999999999996,
pcbRotation: 90,
layer: "top",
},
{
name: "R20",
value: "10k",
footprint: FP.r0603,
section: "storage",
pcbX: -11.7,
pcbY: -25.910399999999996,
pcbRotation: 180,
layer: "top",
},
{
name: "R21",
value: "10k",
footprint: FP.r0603,
section: "display_power",
pcbX: 5.27000000000001,
pcbY: -1.269999999999996,
pcbRotation: 90,
layer: "top",
},
{
name: "R23",
value: "10k",
footprint: FP.r0603,
section: "storage",
pcbX: 15,
pcbY: -26,
pcbRotation: 180,
layer: "top",
},
{
name: "R24",
value: "100k",
footprint: FP.r0603,
section: "storage",
pcbX: -11.7,
pcbY: -24.386399999999995,
pcbRotation: 180,
layer: "top",
},
{
name: "R25",
value: "100k",
footprint: FP.r0603,
section: "storage",
pcbX: 15,
pcbY: -28,
pcbRotation: 180,
layer: "top",
},
{
name: "R27",
value: "20",
footprint: FP.r0603,
section: "mcu_power",
pcbX: -11.150000000000006,
pcbY: 31.769999999999996,
pcbRotation: 0,
layer: "top",
},
{
name: "R28",
value: "20",
footprint: FP.r0603,
section: "mcu_power",
pcbX: 9.474999999999994,
pcbY: 25.629999999999995,
pcbRotation: 90,
layer: "top",
},
{
name: "R29",
value: "100k",
footprint: FP.r0603,
section: "mcu_power",
pcbX: 21.5,
pcbY: 14.1,
pcbRotation: 180,
layer: "top",
},
{
name: "R30",
value: "10k",
footprint: FP.r0603,
section: "mcu_power",
pcbX: -11.15,
pcbY: 29.5,
pcbRotation: 90,
layer: "top",
},
{ name: "R31", value: "10k", footprint: FP.r0603, section: "battery_usb", pcbX: 8.5, pcbY: 17, pcbRotation: 90, layer: "top" },
{ name: "R32", value: "2.2k", footprint: FP.r0603, section: "battery_usb", pcbX: 8.5, pcbY: 14, pcbRotation: 90, layer: "top" },
];
export const inductors: PassiveSpec[] = [
{
name: "L1",
value: "10uH",
footprint: kicad("Inductor_SMD/L_Panasonic_PCC-M0540M"),
section: "display_power",
pcbX: -22.377499999999998,
pcbY: 0.20250000000000057,
pcbRotation: -90,
layer: "top",
},
{ name: "L2", value: "1.5uH", footprint: "jlcpcb:C133190", section: "mcu_power", pcbX: 18, pcbY: 7, pcbRotation: 0, layer: "top" },
];
export const diodes: PassiveSpec[] = [
{
name: "D2",
value: "MBR0530",
footprint: kicad("Diode_SMD/D_SOD-123"),
section: "display_power",
pcbX: -15.75,
pcbY: -2.34,
pcbRotation: 180,
layer: "top",
},
{
name: "D3",
value: "MBR0530",
footprint: kicad("Diode_SMD/D_SOD-123"),
section: "display_power",
pcbX: -15.737500000000011,
pcbY: 0.18999999999999773,
pcbRotation: 0,
layer: "top",
},
{
name: "D4",
value: "MBR0530",
footprint: kicad("Diode_SMD/D_SOD-123"),
section: "display_power",
pcbX: -15.900000000000006,
pcbY: 2.72,
pcbRotation: 180,
layer: "top",
},
];
export const chips: ChipSpec[] = [
{
name: "BT1",
value: "LiPo Cell",
kind: "connector",
footprint: kicad("Connector_JST/JST_PH_S2B-PH-K_1x02_P2.00mm_Horizontal"),
pins: ["1", "2"],
section: "battery_usb",
pcbX: 26.975,
pcbY: -6,
pcbRotation: 180,
layer: "top",
},
{
name: "J1",
value: "USB-C",
kind: "connector",
footprint: "jlcpcb:C165948",
pins: Array.from({ length: 16 }, (_, i) => `${i + 1}`),
noConnect: ["5", "11"],
section: "battery_usb",
pcbX: 25.985,
pcbY: 36.26,
pcbRotation: 90,
layer: "top",
},
{
name: "J2",
value: "Waveshare 3.97in (G), SSD2677",
kind: "connector",
footprint: kicad(
"Connector_FFC-FPC/Hirose_FH34SRJ-24S-0.5SH_1x24-1MP_P0.50mm_Horizontal",
),
pins: Array.from({ length: 24 }, (_, i) => `${i + 1}`),
noConnect: ["1", "4", "6", "7", "19"],
section: "display_power",
// Offset tip of the Waveshare L-shaped ribbon, viewed from PCB rear.
pcbX: displayConnection.connector.centerX,
pcbY: displayConnection.connector.centerY,
pcbRotation: 0,
layer: "top",
},
{
name: "J4",
value: "Micro SD",
kind: "connector",
footprint: kicad("Connector_Card/microSD_HC_Hirose_DM3AT-SF-PEJM5"),
pins: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],
noConnect: ["10"],
section: "storage",
pcbX: -22.349999999999994,
pcbY: -18.5,
pcbRotation: -90,
layer: "top",
},
{
name: "Q1",
value: "FS8205A",
footprint: kicad("Package_TO_SOT_SMD/SOT-23-6_Handsoldering"),
pins: ["1", "2", "3", "4", "5", "6"],
section: "battery_usb",
pcbX: -23.274400000000014,
pcbY: 31.646,
pcbRotation: 90,
layer: "top",
},
{
name: "Q2",
value: "Si1308EDL",
footprint: kicad("Package_TO_SOT_SMD/SOT-323_SC-70"),
pins: ["1", "2", "3"],
section: "display_power",
pcbX: -18.810000000000002,
pcbY: -5.560000000000002,
pcbRotation: 270,
layer: "top",
},
{
name: "U1",
value: "BQ24073RGTR",
footprint: "jlcpcb:C15220",
pins: Array.from({ length: 17 }, (_, i) => `${i + 1}`),
noConnect: ["7", "14"],
section: "battery_usb",
pcbX: 13,
pcbY: 17,
pcbRotation: 0,
layer: "top",
},
{
name: "U2",
value: "USBLC6-2SC6",
footprint: kicad("Package_TO_SOT_SMD/SOT-23-6"),
pins: ["1", "2", "3", "4", "5", "6"],
noConnect: ["1", "4"],
section: "battery_usb",
pcbX: 19.919999999999987,
pcbY: 36.4075,
pcbRotation: 90,
layer: "top",
},
{
name: "U3",
value: "DW01A",
footprint: kicad("Package_TO_SOT_SMD/SOT-23-6"),
pins: ["1", "2", "3", "4", "5", "6"],
noConnect: ["4"],
section: "battery_usb",
pcbX: -23.24940000000001,
pcbY: 36.6244,
pcbRotation: 90,
layer: "top",
},
{
name: "U4",
value: "ESP32-C3-WROOM-02U-N4",
footprint: kicad("RF_Module/ESP32-C3-WROOM-02U"),
pins: Array.from({ length: 27 }, (_, i) => `${i + 1}`),
noConnect: ["11"],
section: "mcu_power",
pcbX: 0.25,
pcbY: 34.78,
pcbRotation: 0,
layer: "top",
},
{
name: "U5",
value: "TPS63021DSJR",
footprint: "jlcpcb:C202140",
pins: Array.from({ length: 15 }, (_, i) => `${i + 1}`),
noConnect: ["14"],
section: "mcu_power",
pcbX: 11,
pcbY: 7,
pcbRotation: 0,
layer: "top",
},
{
name: "S1",
value: "EN",
kind: "pushbutton",
footprint: kicad("Button_Switch_SMD/SW_SPST_EVQP7C"),
pins: ["1", "2"],
section: "controls",
pcbX: -29.125,
pcbY: -31,
pcbRotation: -90,
layer: "top",
},
{
name: "S2",
value: "POWER",
kind: "pushbutton",
footprint: kicad("Button_Switch_SMD/SW_SPST_EVQP7C"),
pins: ["1", "2"],
section: "controls",
pcbX: -29.07499999999999,
pcbY: 23.08,
pcbRotation: -90,
layer: "top",
},
{
name: "SW2",
value: "BACK",
kind: "pushbutton",
footprint: "Alps Alpine SKRPACE010",
pins: ["1", "2", "3", "4"],
section: "controls",
pcbX: displayConnection.controls.navigationX[2],
pcbY: displayConnection.controls.navigationY,
pcbRotation: 0,
layer: "bottom",
},
{
name: "SW3",
value: "CONFIRM",
kind: "pushbutton",
footprint: "Alps Alpine SKRPACE010",
pins: ["1", "2", "3", "4"],
section: "controls",
pcbX: displayConnection.controls.navigationX[1],
pcbY: displayConnection.controls.navigationY,
pcbRotation: 0,
layer: "bottom",
},
{
name: "SW4",
value: "LEFT",
kind: "pushbutton",
footprint: "Alps Alpine SKRPACE010",
pins: ["1", "2", "3", "4"],
section: "controls",
pcbX: displayConnection.controls.navigationX[3],
pcbY: displayConnection.controls.navigationY,
pcbRotation: 0,
layer: "bottom",
},
{
name: "SW6",
value: "RIGHT",
kind: "pushbutton",
footprint: "Alps Alpine SKRPACE010",
pins: ["1", "2", "3", "4"],
section: "controls",
pcbX: displayConnection.controls.navigationX[0],
pcbY: displayConnection.controls.navigationY,
pcbRotation: 0,
layer: "bottom",
},
{
name: "SW7",
value: "MAIN POWER",
footprint: "jlcpcb:C431541",
pins: ["1", "2", "3", "4"],
section: "mcu_power",
pcbX: 28.6,
pcbY: 14.105,
pcbRotation: 90,
layer: "top",
},
{
name: "JP1",
value: "BOOT",
// Unpopulated recovery contacts: a passive BOOT-to-GND interface.
kind: "connector",
footprint: kicad("Jumper/SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mm"),
pins: ["1", "2"],
section: "mcu_power",
pcbX: -20.531200000000013,
pcbY: 18.285600000000002,
pcbRotation: 0,
layer: "top",
},
];
export const testpoints = [
{
name: "TP1",
label: "BATT",
section: "battery_usb" as const,
pcbX: -12.5,
pcbY: 43.431599999999996,
pcbRotation: 0,
layer: "top",
},
{
name: "TP2",
label: "3V3",
section: "mcu_power" as const,
pcbX: -3.360800000000012,
pcbY: 18.691999999999993,
pcbRotation: 0,
layer: "top",
},
{
name: "TP3",
label: "VBUS",
section: "battery_usb" as const,
pcbX: 15,
pcbY: 44,
pcbRotation: 0,
layer: "top",
},
{
name: "TP4",
label: "VGL",
section: "display_power" as const,
pcbX: -9.710800000000006,
pcbY: 8.430399999999992,
pcbRotation: 0,
layer: "top",
},
{
name: "TP5",
label: "VGH",
section: "display_power" as const,
pcbX: -12.961999999999989,
pcbY: 8.481200000000001,
pcbRotation: 0,
layer: "top",
},
{
name: "TP6",
label: "BAT_MEASURE",
section: "mcu_power" as const,
pcbX: 19.042,
pcbY: 22.1464,
pcbRotation: 0,
layer: "top",
},
];
export const schematicSpecs = [
...capacitors,
...resistors,
...inductors,
{ name: "D1", section: "battery_usb" as const },
...diodes,
...chips,
...testpoints,
];
export const schematicPlacementFor = (reference: string) => {
const placement = schematicLayout[reference];
const group = schematicGroups.find(({ refs }) =>
(refs as readonly string[]).includes(reference),
);
if (!placement || !group)
throw new Error(`Missing schematic placement or group for ${reference}`);
return {
...placement,
schSectionName: group.name,
schSheetName: group.sheet,
};
};
export const aliasForPin = (pin: string) =>
`P_${pin.replace(/[^A-Za-z0-9_]/g, "_")}`;
export const pinLabelsFor = (pins: readonly string[]) =>
Object.fromEntries(pins.map((pin) => [pin, aliasForPin(pin)]));
export const endpoint = (ref: string, pin: string) => `.${ref} > .pin${pin}`;
/**
* Electrical trace-width policy derived from the Rev. B KiCad layout.
*
* The original uses wide copper for power distribution and the pulsed-current
* loops in the e-paper charge pump. Its widest
* 0.8-1.0 mm pieces are short pad/loop expansions; because tscircuit currently
* assigns width per net, the values below use the original's sustained width
* rather than applying those local maxima to an entire net.
*/
export const traceThicknessByNet: Record<string, string> = {
BATT_N_RAW: "0.5mm",
PROTECT_COMMON_DRAIN: "0.5mm",
BATT_P: "0.5mm",
// Short pad escapes connect directly into the GND fills on three layers.
GND: "0.2mm",
V3V3: "0.5mm",
EPD_PUMP_NEG: "0.6mm",
EPD_PUMP_SWITCH: "0.6mm",
PREVGH: "0.4mm",
PREVGL: "0.4mm",
PROTECT_VCC: "0.3mm",
USB_VBUS: "0.5mm",
};
export const nets: Record<string, string[]> = {
V3V3: [
endpoint("C7", "1"),
endpoint("C8", "1"),
endpoint("C12", "1"),
endpoint("C13", "1"),
endpoint("C14", "1"),
endpoint("C15", "1"),
endpoint("C19", "1"),
endpoint("C20", "1"),
endpoint("C21", "2"),
endpoint("C24", "1"),
endpoint("C30", "1"),
endpoint("C36", "1"),
endpoint("C37", "1"),
endpoint("C38", "1"),
endpoint("J2", "15"),
endpoint("J2", "16"),
endpoint("J4", "4"),
endpoint("L1", "1"),
endpoint("R4", "2"),
endpoint("R10", "1"),
endpoint("R11", "1"),
endpoint("R18", "2"),
endpoint("R19", "2"),
endpoint("R20", "1"),
endpoint("R21", "2"),
endpoint("R23", "1"),
endpoint("R24", "1"),
endpoint("R25", "1"),
endpoint("R30", "1"),
endpoint("U4", "1"),
endpoint("U5", "3"),
endpoint("U5", "4"),
endpoint("U5", "5"),
endpoint("TP2", "1"),
],
GND: [
endpoint("C1", "2"),
endpoint("C2", "2"),
endpoint("C3", "2"),
endpoint("C4", "2"),
endpoint("C5", "2"),
endpoint("C7", "2"),
endpoint("C8", "2"),
endpoint("C9", "2"),
endpoint("C10", "2"),
endpoint("C11", "2"),
endpoint("C12", "2"),
endpoint("C13", "2"),
endpoint("C14", "2"),
endpoint("C15", "2"),
endpoint("C17", "2"),
endpoint("C19", "2"),
endpoint("C20", "2"),
endpoint("C21", "1"),
endpoint("C22", "1"),
endpoint("C23", "1"),
endpoint("C24", "2"),
endpoint("C25", "1"),
endpoint("C27", "1"),
endpoint("C28", "1"),
endpoint("C29", "1"),
endpoint("C30", "2"),
endpoint("C32", "2"),
endpoint("C34", "2"),
endpoint("C35", "2"),
endpoint("C36", "2"),
endpoint("C37", "2"),
endpoint("C38", "2"),
endpoint("D3", "1"),
endpoint("J1", "1"),
endpoint("J1", "2"),
endpoint("J1", "3"),
endpoint("J1", "4"),
endpoint("J1", "13"),
endpoint("J1", "14"),
// Waveshare (G): BS1 low for four-wire SPI; pins 6/7 remain open.
endpoint("J2", "8"),
endpoint("J2", "17"),
endpoint("J4", "6"),
endpoint("J4", "9"),
endpoint("JP1", "1"),
endpoint("Q1", "3"),
endpoint("R1", "2"),
endpoint("R3", "2"),
endpoint("R6", "2"),
endpoint("R7", "2"),
endpoint("R8", "2"),
endpoint("R9", "2"),
endpoint("R31", "2"),
endpoint("R32", "2"),
endpoint("R13", "2"),
endpoint("R15", "1"),
endpoint("R16", "2"),
endpoint("R17", "2"),
endpoint("R29", "2"),
endpoint("S1", "1"),
endpoint("S1", "3"),
endpoint("S2", "1"),
endpoint("S2", "3"),
endpoint("SW6", "1"),
endpoint("SW7", "4"), // All four metal-case solder feet.
endpoint("U1", "4"),
endpoint("U1", "5"),
endpoint("U1", "8"),
endpoint("U1", "15"), // BQ24073 TD low enables charge termination.
endpoint("U1", "17"),
endpoint("U2", "2"),
endpoint("U4", "9"),
endpoint("U4", "19"),
...[20, 21, 22, 23, 24, 25, 26, 27].map((pin) => endpoint("U4", `${pin}`)),
endpoint("U5", "2"),
endpoint("U5", "13"),
endpoint("U5", "15"),
],
BATT_P: [
endpoint("BT1", "1"),
endpoint("C34", "1"),
endpoint("R12", "1"),
endpoint("R14", "2"),
endpoint("U1", "2"),
endpoint("U1", "3"),
endpoint("TP1", "1"),
],
BATT_N_RAW: [
endpoint("BT1", "2"),
endpoint("C6", "2"),
endpoint("Q1", "1"),
endpoint("U3", "6"),
],
ESP32_EN: [
endpoint("C1", "1"),
endpoint("R4", "1"),
endpoint("S1", "2"),
endpoint("S1", "4"),
endpoint("U4", "2"),
],
USB_VBUS: [
endpoint("C2", "1"),
endpoint("C3", "1"),
endpoint("C4", "1"),
endpoint("C5", "1"),
endpoint("D1", "2"),
endpoint("J1", "15"),
endpoint("J1", "16"),
endpoint("U1", "6"),
endpoint("U1", "13"),
endpoint("U2", "5"),
endpoint("TP3", "1"),
],
USB_DP: [
endpoint("J1", "8"),
endpoint("J1", "10"),
endpoint("U2", "6"),
endpoint("U4", "14"),
],
USB_DM: [
endpoint("J1", "7"),
endpoint("J1", "9"),
endpoint("U2", "3"),
endpoint("U4", "13"),
],
USB_CC1: [endpoint("J1", "6"), endpoint("R7", "1")],
USB_CC2: [endpoint("J1", "12"), endpoint("R8", "1")],
CHARGE_LED_K: [endpoint("D1", "1"), endpoint("R5", "1")],
CHARGE_STAT: [endpoint("R5", "2"), endpoint("U1", "9")],
CHARGE_PROG: [endpoint("R9", "1"), endpoint("U1", "16")],
CHARGE_TS: [endpoint("R31", "1"), endpoint("U1", "1")],
CHARGE_ILIM: [endpoint("R32", "1"), endpoint("U1", "12")],
SYS_OUT: [
endpoint("C9", "1"), endpoint("C10", "1"), endpoint("C11", "1"),
endpoint("C35", "1"), endpoint("SW7", "1"),
endpoint("U1", "10"), endpoint("U1", "11"),
endpoint("U5", "1"), endpoint("U5", "10"), endpoint("U5", "11"),
],
BB_L1: [endpoint("L2", "1"), endpoint("U5", "8"), endpoint("U5", "9")],
BB_L2: [endpoint("L2", "2"), endpoint("U5", "6"), endpoint("U5", "7")],
PROTECT_VCC: [endpoint("C6", "1"), endpoint("R14", "1"), endpoint("U3", "5")],
PROTECT_CS: [endpoint("R15", "2"), endpoint("U3", "2")],
// Both FS8205A drains are joined internally; tie their pads on the PCB too.
PROTECT_COMMON_DRAIN: [endpoint("Q1", "2"), endpoint("Q1", "5")],
PROTECT_OD: [endpoint("Q1", "6"), endpoint("U3", "1")],
PROTECT_OC: [endpoint("Q1", "4"), endpoint("U3", "3")],
BOOT_OPTION: [endpoint("JP1", "2"), endpoint("U4", "8")],
EPD_DC: [endpoint("J2", "11"), endpoint("U4", "3")],
EPD_RST: [endpoint("J2", "10"), endpoint("R21", "1"), endpoint("U4", "4")],
EPD_BUSY: [endpoint("J2", "9"), endpoint("R19", "1"), endpoint("U4", "5")],
EPD_CS: [endpoint("J2", "12"), endpoint("R18", "1"), endpoint("U4", "12")],
SPI_MISO: [endpoint("J4", "7"), endpoint("R20", "2"), endpoint("U4", "6")],
SPI_SCLK: [endpoint("J2", "13"), endpoint("J4", "5"), endpoint("R27", "1")],
SPI_MOSI: [endpoint("J2", "14"), endpoint("J4", "3"), endpoint("R28", "1")],
MCU_IO8: [endpoint("R27", "2"), endpoint("R30", "2"), endpoint("U4", "7")],
MCU_IO10: [endpoint("R28", "2"), endpoint("U4", "10")],
SD_CS: [endpoint("J4", "2"), endpoint("R23", "2"), endpoint("U4", "16")],
SD_DAT1: [endpoint("J4", "8"), endpoint("R24", "2")],
SD_DAT2: [endpoint("J4", "1"), endpoint("R25", "2")],
POWER_BUTTON: [
endpoint("R10", "2"),
endpoint("S2", "2"),
endpoint("S2", "4"),
endpoint("U4", "15"),
],
BUTTONS_ADC: [
endpoint("R11", "2"),
endpoint("SW2", "4"),
endpoint("SW3", "4"),
endpoint("SW4", "4"),
endpoint("SW6", "4"),
endpoint("U4", "17"),
],
BACK: [endpoint("R1", "1"), endpoint("SW2", "1")],
CONFIRM: [endpoint("R3", "1"), endpoint("SW3", "1")],
LEFT: [endpoint("R6", "1"), endpoint("SW4", "1")],
BATT_MEASURE: [
endpoint("R12", "2"),
endpoint("R13", "1"),
endpoint("U4", "18"),
endpoint("TP6", "1"),
],
EPD_PUMP_SWITCH: [
endpoint("C16", "2"),
endpoint("D4", "2"),
endpoint("L1", "2"),
endpoint("Q2", "3"),
],
EPD_PUMP_NEG: [
endpoint("C16", "1"),
endpoint("D2", "1"),
endpoint("D3", "2"),
],
PREVGH: [
endpoint("C17", "1"),
endpoint("D4", "1"),
endpoint("J2", "21"),
endpoint("TP5", "1"),
],
PREVGL: [
endpoint("C23", "2"),
endpoint("C32", "1"),
endpoint("D2", "2"),
endpoint("J2", "23"),
endpoint("TP4", "1"),
],
GDR: [endpoint("J2", "2"), endpoint("Q2", "1"), endpoint("R16", "1")],
RESE: [endpoint("J2", "3"), endpoint("Q2", "2"), endpoint("R17", "1")],
EPD_VDD: [endpoint("C25", "2"), endpoint("J2", "18")],
EPD_VSH1: [endpoint("C22", "2"), endpoint("J2", "20")],
EPD_VSH2: [endpoint("C29", "2"), endpoint("J2", "5")],
EPD_VSL: [endpoint("C28", "2"), endpoint("J2", "22")],
VCOM: [endpoint("C27", "2"), endpoint("J2", "24")],
POWER_ENABLE: [endpoint("SW7", "2"), endpoint("U5", "12")],
POWER_OFF_PULLDOWN: [endpoint("R29", "1"), endpoint("SW7", "3")],
};
export const noConnectAliases = (spec: ChipSpec) =>
spec.noConnect?.map(aliasForPin);