0
mirror of https://github.com/incutec-hw/OpenFC-Lite-Mini.git synced 2026-08-19 07:03:48 +00:00
Files
incutec-OpenFC-Lite-Mini/hardware/tools/add_emc_note.py
JustStan bc7db8f3f7 Fix contradictions and duplicated information
Contradictions, all resolved against the design files (U10 pad nets and
component values parsed from hardware/OpenFC.kicad_pcb):

- LED series resistors in DESIGN.md re-derived from the board: D2 is
  R52+R53 = 150R from GPIO26 (not 510R), D7 is R36 = 510R from +3.3V
  (not 680R), and the missing D8 row is added. Currents recomputed.
- OSD op-amp supply corrected from +5 V to +3.3 V (U1 pin 5 is on the
  +3.3V net); the headroom question is raised as an open item.
- EMC checklist rewritten for the RP2354A: SPI0/SPI1 swapped to match
  the netlist (IMU on SPI1, SD on SPI0), USB series R corrected to 30R
  at pads 51/52, core inductor L1 to L4, RSSI/external-ADC and ECO/ELRS
  sections dropped, D1 noted as unpopulated.
- audit_design.py docstring corrected to KiCad 10, plus a note that its
  hardcoded refdes and GPIO map are Rev 1 and need re-deriving.

Deleted, all superseded by the Rev 2 RP2354A design or one-time artifacts:

- hardware/tools/design_audit.md, hardware/research/rp2354a-routing-validation.md,
  hardware/tools/rp2350_layout_notes.md (Rev 1 QFN-80 refdes and pin numbers)
- hardware/_U2BEFORE.kicad_pro, hardware/_U2BEFORE-top.png, hardware/OpenFC-top.png
  (one-time U2 3D model verification, unreferenced)
- hardware/emc.json, hardware/thermal.json (generated dumps, now gitignored)
- hardware/tools/eco_strip_sheets.py, hardware/tools/rebuild_blackbox.py
  (one-time scripts that would delete or regress live sheets)
- images/.gitkeep (directory is no longer empty)

Technical content from the deleted notes was moved, not dropped: the PIO
instruction-budget analysis and the SBUS hardware-UART constraint into
open-items.md and DESIGN.md, and the RP2350 core-buck layout rule into the
DESIGN.md power tree.

Duplications collapsed to one copy plus a link: sibling-board description,
production-export sentence, SBUS and microSD rationale, SPI pin assignments,
buck part change, FB_OSD upstream status, IMU footprint compatibility, and
the EMC checklist body that add_emc_note.py now reads from the markdown file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 10:55:45 +02:00

60 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Add the EMC checklist as a textbox on the root schematic. Non-destructive.
The checklist text is read from EMC_CHECKLIST.md next to this script, so there is
only one copy of it in the repo.
"""
import kicad_sch_api as ksa
import os
import sys
TOOLS = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.join(os.path.dirname(TOOLS), "OpenFC.kicad_sch")
CHECKLIST_MD = os.path.join(TOOLS, "EMC_CHECKLIST.md")
def load_checklist():
"""Return the checklist as plain text for the schematic textbox."""
with open(CHECKLIST_MD) as f:
lines = f.read().splitlines()
out = []
for line in lines:
# Strip markdown heading markers and bold/code markers; keep the words.
line = line.lstrip("#").strip() if line.startswith("#") else line
line = line.replace("**", "").replace("`", "")
out.append(line)
return "\n".join(out).strip()
def main():
if not os.path.exists(CHECKLIST_MD):
print(f"ERROR: {CHECKLIST_MD} not found", file=sys.stderr)
return 1
print(f"Loading {ROOT}")
sch = ksa.load_schematic(ROOT)
# Place bottom-left, below all existing sheets
# Existing sheet bounds: y max ~162.56, x: 31 to 218
# A3 page ~420x297 or A4 297x210
text_uuid = sch.add_text_box(
text=load_checklist(),
position=(12.7, 170.18),
size=(250.0, 100.0),
font_size=1.0,
margins=(1.5, 1.5, 1.5, 1.5),
stroke_width=0.15,
stroke_type="default",
justify_horizontal="left",
justify_vertical="top",
)
print(f"Added text box uuid={text_uuid}")
sch.save(ROOT)
print(f"Saved {ROOT}")
return 0
if __name__ == "__main__":
raise SystemExit(main())