imrishabh18/desk-led-matrix

This code models a hardware setup comprising a WLED-compatible LED cascade array connected to a XIAO ESP32-C3 microcontroller, including power regulation components and detailed PCB layout with traces, pads, and silkscreen markings.

Version
1.0.4
License
unset
Stars
0

dist/index.cjs

'use strict';

var jsxRuntime = require('react/jsx-runtime');
var react = require('react');

const pinLabels = {
    pin1: ["VDD"],
    pin2: ["DO"],
    pin3: ["GND"],
    pin4: ["DI"]
};
const WLED = (props) => {
    return (jsxRuntime.jsx("chip", { pinLabels: pinLabels, supplierPartNumbers: {
            "jlcpcb": [
                "C22461793"
            ]
        }, manufacturerPartNumber: "XL_5050RGBC_2812B_S", footprint: jsxRuntime.jsxs("footprint", { children: [jsxRuntime.jsx("smtpad", { portHints: ["pin3"], pcbX: "2.499995mm", pcbY: "-1.599946mm", width: "1.7999964mm", height: "0.999998mm", shape: "rect" }), jsxRuntime.jsx("smtpad", { portHints: ["pin4"], pcbX: "2.499995mm", pcbY: "1.599946mm", width: "1.7999964mm", height: "0.999998mm", shape: "rect" }), jsxRuntime.jsx("smtpad", { portHints: ["pin1"], pcbX: "-2.499995mm", pcbY: "1.599946mm", width: "1.7999964mm", height: "0.999998mm", shape: "rect" }), jsxRuntime.jsx("smtpad", { portHints: ["pin2"], pcbX: "-2.499995mm", pcbY: "-1.599946mm", width: "1.7999964mm", height: "0.999998mm", shape: "rect" }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": 2.499944200000016, "y": -2.2724110000000053 }, { "x": 2.499944200000016, "y": -2.4999442000000016 }, { "x": -2.500045799999995, "y": -2.4999442000000016 }, { "x": -2.500045799999995, "y": -2.313686000000004 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": 2.499944200000016, "y": 2.500045799999995 }, { "x": 2.5067260000000147, "y": 2.274214399999991 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": -2.4888189999999923, "y": 2.2784307999999953 }, { "x": -2.500045799999995, "y": 2.500045799999995 }, { "x": 2.499944200000016, "y": 2.500045799999995 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": 2.499944200000016, "y": 0.7696707999999859 }, { "x": 2.499944200000016, "y": -0.7695692000000065 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": -2.500045799999995, "y": -0.7695692000000065 }, { "x": -2.500045799999995, "y": 0.7696707999999859 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": 1.4999462000000108, "y": -1.7999456000000151 }, { "x": 1.4999462000000108, "y": -2.4999442000000016 }, { "x": 0.7999476000000101, "y": -2.4999442000000016 }, { "x": 1.499895400000014, "y": -1.7998440000000073 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": 1.5007590000000022, "y": 0 }, { "x": 1.4496435142360582, "y": -0.3882606612153694 }, { "x": 1.2997804928267271, "y": -0.7500619999999998 }, { "x": 1.0613828530206888, "y": -1.0607478530207004 }, { "x": 0.7506970000000024, "y": -1.2991454928267387 }, { "x": 0.388895661215372, "y": -1.4490085142360698 }, { "x": 0.0006350000000026057, "y": -1.5001240000000138 }, { "x": -0.3876256612153668, "y": -1.4490085142360698 }, { "x": -0.749426999999983, "y": -1.2991454928267387 }, { "x": -1.0601128530206978, "y": -1.0607478530207004 }, { "x": -1.2985104928267361, "y": -0.7500619999999998 }, { "x": -1.4483735142360672, "y": -0.3882606612153694 }, { "x": -1.4994889999999828, "y": 0 }, { "x": -1.4483735142360672, "y": 0.3882606612153694 }, { "x": -1.2985104928267361, "y": 0.7500619999999856 }, { "x": -1.0601128530206978, "y": 1.0607478530206862 }, { "x": -0.749426999999983, "y": 1.2991454928267245 }, { "x": -0.3876256612153668, "y": 1.4490085142360556 }, { "x": 0.0006350000000026057, "y": 1.5001239999999996 }, { "x": 0.388895661215372, "y": 1.4490085142360556 }, { "x": 0.7506970000000024, "y": 1.2991454928267245 }, { "x": 1.0613828530206888, "y": 1.0607478530206862 }, { "x": 1.2997804928267271, "y": 0.7500619999999856 }, { "x": 1.4496435142360582, "y": 0.3882606612153694 }, { "x": 1.5007590000000022, "y": 0 }] }), jsxRuntime.jsx("silkscreenpath", { route: [{ "x": -2.79996899999999, "y": 2.4000460000000032 }, { "x": -2.8033790070082887, "y": 2.3741444252423207 }, { "x": -2.8133766416908657, "y": 2.3500079999999883 }, { "x": -2.8292805817659854, "y": 2.329281581765983 }, { "x": -2.850007000000005, "y": 2.313377641690863 }, { "x": -2.8741434252423232, "y": 2.3033800070083004 }, { "x": -2.9000450000000058, "y": 2.299970000000002 }, { "x": -2.9259465747576883, "y": 2.3033800070083004 }, { "x": -2.9500830000000065, "y": 2.313377641690863 }, { "x": -2.970809418234012, "y": 2.329281581765983 }, { "x": -2.9867133583091316, "y": 2.3500079999999883 }, { "x": -2.9967109929917086, "y": 2.3741444252423207 }, { "x": -3.000121000000007, "y": 2.4000460000000032 }, { "x": -2.9967109929917086, "y": 2.4259475747576857 }, { "x": -2.9867133583091316, "y": 2.450084000000004 }, { "x": -2.970809418234012, "y": 2.4708104182340094 }, { "x": -2.9500830000000065, "y": 2.486714358309129 }, { "x": -2.9259465747576883, "y": 2.496711992991692 }, { "x": -2.9000450000000058, "y": 2.5001220000000046 }, { "x": -2.8741434252423232, "y": 2.496711992991692 }, { "x": -2.850007000000005, "y": 2.486714358309129 }, { "x": -2.8292805817659854, "y": 2.4708104182340094 }, { "x": -2.8133766416908657, "y": 2.450084000000004 }, { "x": -2.8033790070082887, "y": 2.4259475747576857 }, { "x": -2.79996899999999, "y": 2.4000460000000032 }] }), jsxRuntime.jsx("silkscreentext", { text: "{NAME}", pcbX: "-0.202819mm", pcbY: "3.537714mm", anchorAlignment: "center", fontSize: "1mm" }), jsxRuntime.jsx("courtyardoutline", { outline: [{ "x": -4.034219000000007, "y": 2.787713999999994 }, { "x": 3.628580999999997, "y": 2.787713999999994 }, { "x": 3.628580999999997, "y": -2.741486000000009 }, { "x": -4.034219000000007, "y": -2.741486000000009 }, { "x": -4.034219000000007, "y": 2.787713999999994 }] })] }), cadModel: {
            objUrl: "https://modelcdn.tscircuit.com/easyeda_models/assets/C22461793.obj?uuid=df86fdf032664dc8a1d2316c54569add",
            stepUrl: "https://modelcdn.tscircuit.com/easyeda_models/assets/C22461793.step?uuid=df86fdf032664dc8a1d2316c54569add",
            pcbRotationOffset: 180,
            modelOriginPosition: { x: 0.000012700000013410317, y: 0, z: -0.041787 },
        }, ...props }));
};

const ROWS = 8;
const COLS = 8;
const LED_COUNT = ROWS * COLS;
const LED_PITCH_MM = 8;
const MATRIX_WIDTH_MM = (COLS - 1) * LED_PITCH_MM;
const MATRIX_HEIGHT_MM = (ROWS - 1) * LED_PITCH_MM;
const BOARD_SIZE_MM = 78;
const MATRIX_CENTER_Y_MM = 0;
const XIAO_CENTER_X_MM = 30;
const XIAO_CENTER_Y_MM = 0;
const xiaoBottomFootprint = (jsxRuntime.jsxs("footprint", { children: [Array.from({ length: 7 }, (_, i) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("smtpad", { portHints: [`pin${i + 1}`], layer: "bottom", shape: "rect", pcbX: "-7.55mm", pcbY: `${7.62 - i * 2.54}mm`, width: "2.4mm", height: "1.6mm" }) }, `xiao-left-${i + 1}`))), Array.from({ length: 7 }, (_, i) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("smtpad", { portHints: [`pin${i + 8}`], layer: "bottom", shape: "rect", pcbX: "7.55mm", pcbY: `${ -7.62 + i * 2.54}mm`, width: "2.4mm", height: "1.6mm" }) }, `xiao-right-${i + 8}`)))] }));
const dataOrder = Array.from({ length: LED_COUNT }, (_, i) => i + 1);
const pixelPlacements = Array.from({ length: LED_COUNT }, (_, physicalIndex) => {
    const row = Math.floor(physicalIndex / COLS);
    const col = physicalIndex % COLS;
    const serpentineIndex = row % 2 === 0 ? row * COLS + col : row * COLS + (COLS - 1 - col);
    return {
        name: `D${serpentineIndex + 1}`,
        col,
        row,
        x: (col - (COLS - 1) / 2) * LED_PITCH_MM,
        y: (row - (ROWS - 1) / 2) * LED_PITCH_MM + MATRIX_CENTER_Y_MM,
        rotation: row % 2 === 0 ? 0 : 180,
    };
});
function DeskLedMatrix() {
    return (jsxRuntime.jsxs("board", { title: "Desk WLED Pixel Art Matrix", width: `${BOARD_SIZE_MM}mm`, height: `${BOARD_SIZE_MM}mm`, borderRadius: "2mm", solderMaskColor: "black", silkscreenColor: "white", children: [jsxRuntime.jsx("net", { name: "V5", isPowerNet: true, nominalTraceWidth: "0.45mm", highlightColor: "#ff4a36" }), jsxRuntime.jsx("net", { name: "GND", isGroundNet: true, nominalTraceWidth: "0.45mm", highlightColor: "#4aa3ff" }), jsxRuntime.jsx("net", { name: "DATA_IN", nominalTraceWidth: "0.2mm", highlightColor: "#ffd166" }), jsxRuntime.jsx("chip", { name: "U1", manufacturerPartNumber: "Seeed Studio XIAO ESP32-C3", footprint: xiaoBottomFootprint, pcbX: XIAO_CENTER_X_MM, pcbY: XIAO_CENTER_Y_MM, pinLabels: {
                    1: "D0_GPIO2",
                    2: "D1_GPIO3",
                    3: "D2_GPIO4",
                    4: "D3_GPIO5",
                    5: "D4_GPIO6",
                    6: "D5_GPIO7",
                    7: "D6_GPIO21",
                    8: "D7_GPIO20",
                    9: "D8_GPIO8",
                    10: "D9_GPIO9",
                    11: "D10_GPIO10",
                    12: "3V3",
                    13: "GND",
                    14: "5V",
                }, pcbPinLabels: {
                    pin1: "D0",
                    pin2: "D1",
                    pin3: "D2",
                    pin4: "D3",
                    pin5: "D4",
                    pin6: "D5",
                    pin7: "D6",
                    pin8: "D7",
                    pin9: "D8",
                    pin10: "D9",
                    pin11: "D10",
                    pin12: "3V3",
                    pin13: "GND",
                    pin14: "5V",
                }, pcbRotation: 90, pinAttributes: {
                    D4_GPIO6: { isGpio: true },
                    GND: { requiresGround: true },
                    "5V": { requiresPower: true, requiresVoltage: "5V" },
                    "3V3": { providesPower: true, providesVoltage: "3.3V" },
                } }), jsxRuntime.jsx("resistor", { name: "RDATA", resistance: "330", footprint: "0603", layer: "bottom", pcbX: -18, pcbY: -BOARD_SIZE_MM / 2 + 12, schOrientation: "horizontal" }), jsxRuntime.jsx("capacitor", { name: "CBULK", capacitance: "1000uF", polarized: true, footprint: "1206", layer: "bottom", pcbX: 18, pcbY: -BOARD_SIZE_MM / 2 + 12, schOrientation: "vertical" }), jsxRuntime.jsx("trace", { from: ".U1 > .pin14", to: "net.V5", width: "0.5mm" }), jsxRuntime.jsx("trace", { from: ".U1 > .pin13", to: "net.GND", width: "0.5mm" }), jsxRuntime.jsx("trace", { from: ".U1 > .pin5", to: ".RDATA > .pin1", width: "0.2mm" }), jsxRuntime.jsx("trace", { from: ".RDATA > .pin2", to: ".D1 > .DI", width: "0.2mm" }), jsxRuntime.jsx("trace", { from: ".CBULK > .pos", to: "net.V5", width: "0.7mm" }), jsxRuntime.jsx("trace", { from: ".CBULK > .neg", to: "net.GND", width: "0.7mm" }), pixelPlacements.map((pixel) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx(WLED, { name: pixel.name, pcbX: pixel.x, pcbY: pixel.y, pcbRotation: pixel.rotation, pcbPinLabels: {
                        pin1: "VDD",
                        pin2: "DO",
                        pin3: "GND",
                        pin4: "DI",
                    }, pinAttributes: {
                        VDD: { requiresPower: true, requiresVoltage: "5V" },
                        pin1: { requiresPower: true, requiresVoltage: "5V" },
                        pin2: { isGpio: true },
                        GND: { requiresGround: true },
                        pin3: { requiresGround: true },
                        pin4: { isGpio: true },
                        DI: { isGpio: true },
                        DO: { isGpio: true },
                    } }) }, pixel.name))), dataOrder.slice(0, -1).map((ledNumber) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("trace", { from: `.D${ledNumber} > .DO`, to: `.D${ledNumber + 1} > .DI`, width: "0.18mm" }) }, `data-${ledNumber}`))), dataOrder.map((ledNumber) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("trace", { from: `.D${ledNumber} > .VDD`, to: "net.V5", width: "0.35mm" }) }, `v5-${ledNumber}`))), dataOrder.map((ledNumber) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("trace", { from: `.D${ledNumber} > .GND`, to: "net.GND", width: "0.35mm" }) }, `gnd-${ledNumber}`))), Array.from({ length: ROWS }, (_, row) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("capacitor", { name: `CROW${row + 1}`, capacitance: "100nF", footprint: "0402", layer: "bottom", pcbX: -BOARD_SIZE_MM / 2 + 4, pcbY: (row - (ROWS - 1) / 2) * LED_PITCH_MM + MATRIX_CENTER_Y_MM, connections: {
                        pin1: "net.V5",
                        pin2: "net.GND",
                    } }) }, `crow-${row + 1}`))), jsxRuntime.jsx("silkscreenrect", { pcbX: 0, pcbY: MATRIX_CENTER_Y_MM, width: `${MATRIX_WIDTH_MM + 5}mm`, height: `${MATRIX_HEIGHT_MM + 5}mm`, filled: false, stroke: "solid", strokeWidth: "0.18mm" }), pixelPlacements.map((pixel) => (jsxRuntime.jsx(react.Fragment, { children: jsxRuntime.jsx("silkscreenrect", { pcbX: pixel.x, pcbY: pixel.y, width: "5.4mm", height: "5.4mm", filled: false, stroke: "solid", strokeWidth: "0.08mm" }) }, `pixel-frame-${pixel.name}`))), jsxRuntime.jsx("silkscreentext", { text: "XIAO WLED 8x8 SERPENTINE", pcbX: 0, pcbY: BOARD_SIZE_MM / 2 - 2.2, fontSize: "1.2mm" }), jsxRuntime.jsx("silkscreenrect", { layer: "bottom", pcbX: XIAO_CENTER_X_MM, pcbY: XIAO_CENTER_Y_MM, width: "17.5mm", height: "21mm", filled: false, stroke: "dashed", strokeWidth: "0.12mm" }), jsxRuntime.jsx("silkscreentext", { layer: "bottom", text: "XIAO ESP32-C3", pcbX: XIAO_CENTER_X_MM, pcbY: XIAO_CENTER_Y_MM + 11.5, fontSize: "1mm" }), jsxRuntime.jsx("silkscreentext", { layer: "bottom", text: "USB", pcbX: XIAO_CENTER_X_MM, pcbY: XIAO_CENTER_Y_MM - 11.5, fontSize: "0.9mm" }), jsxRuntime.jsx("silkscreentext", { text: "D1", pcbX: -MATRIX_WIDTH_MM / 2, pcbY: MATRIX_CENTER_Y_MM - MATRIX_HEIGHT_MM / 2 - 1, fontSize: "0.9mm" })] }));
}

module.exports = DeskLedMatrix;