mohan-bee/disco

This code models a physical circuit board with two IC chips (a 74HC4017 decade counter and a 74HC161 shift register) connected to ten LEDs and resistors arranged in a circular layout with traces routing outputs and power connections.

Version
0.0.1
License
unset
Stars
0

dist/index.js

import { jsxs, jsx } from 'react/jsx-runtime';

var index = () => {
    // The CD4017 is famous for having its output pins scattered randomly.
    // We map them here in order (Q0 to Q9) so our loop can easily assign them.
    const cd4017Outputs = [
        "pin3", "pin2", "pin4", "pin7", "pin10",
        "pin1", "pin5", "pin6", "pin9", "pin11"
    ];
    return (jsxs("board", { width: "50mm", height: "60mm", children: [jsx("net", { name: "VCC_5V", isPowerNet: true }), jsx("net", { name: "GND", isGroundNet: true }), jsx("chip", { name: "U1", footprint: "soic8", pcbX: -10, pcbY: -10, pinLabels: {
                    pin1: "GND", pin2: "TRIG", pin3: "OUT", pin4: "RESET",
                    pin5: "CTRL", pin6: "THR", pin7: "DIS", pin8: "VCC"
                } }), jsx("chip", { name: "U2", footprint: "soic16", pcbX: 10, pcbY: -10, pinLabels: {
                    pin8: "GND", pin13: "EN", pin14: "CLK", pin15: "RST", pin16: "VCC"
                } }), jsx("trace", { from: ".U1 > .VCC", to: "net.VCC_5V" }), jsx("trace", { from: ".U1 > .GND", to: "net.GND" }), jsx("trace", { from: ".U2 > .VCC", to: "net.VCC_5V" }), jsx("trace", { from: ".U2 > .GND", to: "net.GND" }), jsx("trace", { from: ".U1 > .OUT", to: ".U2 > .CLK" }), jsx("trace", { from: ".U2 > .EN", to: "net.GND" }), jsx("trace", { from: ".U2 > .RST", to: "net.GND" }), Array.from({ length: 10 }).map((_, i) => {
                const angleRadians = Math.PI - (i * (Math.PI / 9));
                const radius = 18; // mm
                // Calculate X and Y positions based on the angle
                const x = Math.cos(angleRadians) * radius;
                const y = Math.sin(angleRadians) * radius + 5;
                // Rotate the LEDs so they point outward from the center
                const rotationDegrees = (angleRadians * 180) / Math.PI - 90;
                return (jsxs("group", { children: [jsx("led", { name: `D${i}`, footprint: "0805", pcbX: x, pcbY: y, pcbRotation: rotationDegrees }), jsx("resistor", { name: `R${i}`, resistance: "330", footprint: "0603", pcbX: x, pcbY: y - 3.5, pcbRotation: rotationDegrees }), jsx("trace", { from: `.U2 > .${cd4017Outputs[i]}`, to: `.R${i} > .pin1` }), jsx("trace", { from: `.R${i} > .pin2`, to: `.D${i} > .pos` }), jsx("trace", { from: `.D${i} > .neg`, to: "net.GND" })] }, `led-channel-${i}`));
            })] }));
};

export { index as default };