mohan-bee/modern-controller

A two-board 2.4 GHz wireless control system using CH32X035 MCUs, SX1280 radios, USB‑C transmitter with RFX2401C PA/filter, and a battery-powered receiver with U.FL antennas, RGB status LEDs, regulators, and PWM output headers.

Version
0.0.6
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone mohan-bee/modern-controller  # download the package files into ./modern-controller
tsci add mohan-bee/modern-controller    # add it to your project as @tsci/mohan-bee.modern-controller

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

design/render-connector-guide.py

"""Render the top-view wiring guide from the released tscircuit placement."""
import json
from pathlib import Path
from xml.etree.ElementTree import Element, SubElement, ElementTree

root = Path(__file__).resolve().parents[1]
data = json.loads((root / "pair.json").read_text())
svg = Element("svg", xmlns="http://www.w3.org/2000/svg", viewBox="0 0 1060 650",
              width="1060", height="650", role="img")
SubElement(svg, "title").text = "Modern controller panel connector guide"

def add(tag, **attrs):
    return SubElement(svg, tag, {k.replace("_", "-"): str(v) for k, v in attrs.items()})

def text(x, y, value, size=16, color="#18342e", weight="normal"):
    add("text", x=x, y=y, fill=color, font_family="Arial, sans-serif",
        font_size=size, font_weight=weight).text = value

def pos(x, y):
    return 312 + 6*x, 520 - 6*y

add("rect", width=1060, height=650, fill="#fafaf6")
text(35,45,"Panel connector guide",30,weight="bold")
text(35,74,"Component side   /   70 × 70 mm   /   Receiver above transmitter")
add("rect", x=312,y=100,width=420,height=420,fill="#21594d",rx=2)
sources = {e["source_component_id"]: e["name"] for e in data if e["type"]=="source_component"}
centres = {}
for e in data:
    if e["type"]=="pcb_cutout":
        points=" ".join("%g,%g"%pos(p["x"],p["y"]) for p in e["points"])
        add("polygon",points=points,fill="#fafaf6")
    elif e["type"]=="pcb_component":
        x,y=pos(**e["center"])
        w,h=6*e["width"],6*e["height"]
        name=sources[e["source_component_id"]]
        centres[name]=(x,y)
        add("rect",x=x-w/2,y=y-h/2,width=w,height=h,
            fill="#ece3ba" if name.startswith("D") else "#142e28",stroke="#aec4a9",stroke_width=.65)
    elif e["type"]=="pcb_hole":
        x,y=pos(e["x"],e["y"])
        add("circle",cx=x,cy=y,r=3*e["hole_diameter"],fill="#fafaf6")
    elif e.get("pcb_smtpad_id","").startswith("pcb_smtpad_mark"):
        x,y=pos(e["x"],e["y"])
        add("circle",cx=x,cy=y,r=3,fill="#d9b871")

def callout(ref,title,detail,side,baseline):
    x,y=centres[ref]
    left=side=="left"
    stop=298 if left else 751
    elbow=x-25 if left else x+25
    text_x=35 if left else 766
    add("polyline",points=f"{x},{y} {elbow},{baseline-5} {stop},{baseline-5}",
        fill="none",stroke="#607f74",stroke_width=1.7)
    add("circle",cx=x,cy=y,r=3.5,fill="#ffcf67",stroke="#402d10")
    text(text_x,baseline,f"{ref}   {title}",17,weight="bold")
    text(text_x,baseline+22,detail,14)

callout("J203","RX programming","WCH-LinkE debug header","left",150)
callout("J202","RX antenna","2.4 GHz U.FL connector","left",211)
callout("J204","RX battery","1 B+   ·   2 B− (ground)","left",278)
callout("D201","RX status","Green when valid packets arrive","right",160)
callout("J205","Channel outputs","1 O1   ·   2 O2   ·   3 G   ·   4 VIN","right",240)
callout("J102","TX antenna","2.4 GHz U.FL connector","left",368)
callout("J101","USB-C","Data and 5 V from the host","left",465)
callout("J103","TX programming","WCH-LinkE debug header","right",385)
callout("D101","TX status","Green after local transmission","right",460)
text(35,563,"Connecting the receiver",20,weight="bold")
text(35,593,"Power J204 from a protected single cell (4.2 V maximum). Alternatively supply regulated 5 V on J205 pins 4 and 3. Use one source only.")
text(35,619,"Connect external controller ground to J205 pin 3.")
target=root/"dist/pair/connector-guide.svg"
target.parent.mkdir(parents=True,exist_ok=True)
ElementTree(svg).write(target,encoding="utf-8",xml_declaration=True)