|
1 | | -# PCB Pinout Diagram Generator |
| 1 | +# Pinout Leaf Generator |
2 | 2 |
|
3 | | -This project generates Scalable Vector Graphics (SVG) pinout diagrams for Printed Circuit Boards (PCBs) based on configuration files written in YAML or JSON. It provides both a web-based editor for interactive diagram creation and a command-line interface (CLI) for batch processing. |
| 3 | +Pinout diagrams for micro controllers and other PCBs are well known, but it can be hard always comparing the pinout |
| 4 | +diagram with the real PCB, counting pins. One solution is to print out a diagram that has exactly the right size to push |
| 5 | +the pins through the paper and have the labels right next to the actual pin. |
| 6 | + |
| 7 | +This project is meant for easily creating such pinout leafs. |
| 8 | + |
| 9 | +The pins can be described by a simple YAML based description and the tool automatically creates the diagram as a SVG. |
4 | 10 |
|
5 | 11 | ## Features |
6 | 12 |
|
7 | | -* **SVG Output:** Generates clean, scalable SVG diagrams. |
8 | | -* **Configuration:** Define pinouts, board dimensions, labels, and types using simple YAML or JSON files. |
9 | | -* **Web Editor:** |
10 | | - * Real-time preview of the diagram as you edit the configuration. |
11 | | - * Syntax highlighting for YAML. |
12 | | - * Load configurations from local files, URLs, or browser storage. |
13 | | - * Download generated SVG diagrams (front and back views). |
14 | | -* **CLI Tool:** Process multiple configuration files or entire directories to generate SVG diagrams programmatically. |
15 | | -* **Image Embedding:** Embed background images (e.g., photos of the PCB) from local paths or URLs directly into the SVG. Supports front and back images. |
16 | | -* **Customization:** Define custom types for pins with specific background and foreground colors, automatically generating a legend. |
17 | | -* **Front & Back Views:** Automatically generates diagrams for both the front and back sides of the PCB. |
| 13 | +* **SVG Output:** |
| 14 | + * Generates clean, scalable SVG diagrams. |
| 15 | + * Default sizes match the real world PCB exactly, just print at 100% |
| 16 | + * Fully self contained, font and image resources are embedded into the file so it's fully portable |
| 17 | +* **Configuration:** |
| 18 | + * Define pinouts, board dimensions, labels, and types using simple YAML or JSON files. |
| 19 | + * Custom types allow control over colors and legend labels |
| 20 | +* **Web Editor:** |
| 21 | + * Real-time preview of the diagram as you edit the configuration. |
| 22 | + * Syntax highlighting for YAML. |
| 23 | + * Download generated SVG diagrams |
| 24 | +* **CLI Tool:** |
| 25 | + * Process multiple configuration files or entire directories to generate SVG diagrams programmatically. |
| 26 | +* **Front & Back Views:** |
| 27 | + * Automatically generates diagrams for both the front and back sides of the PCB. |
| 28 | + |
| 29 | +## Limits |
| 30 | + |
| 31 | +* Only four rows of pins are supported |
| 32 | +* No weird arbitrary layouts |
| 33 | +* Only standard 0.1 inch pin raster supported (might change in the future) |
18 | 34 |
|
19 | 35 | ## Usage |
20 | 36 |
|
21 | 37 | ### Web Editor |
22 | 38 |
|
23 | | -1. Open `public/index.html` in your web browser (requires a local web server or building the project). |
24 | | -2. Edit the YAML configuration in the editor pane. |
25 | | -3. The SVG diagram preview will update automatically. |
26 | | -4. Use the "Download SVG" buttons below each preview to save the front or back view. |
| 39 | +1. Go to FIXME |
| 40 | +2. Edit the YAML configuration in the editor. |
| 41 | +3. The SVG diagrams will update automatically. |
| 42 | +4. Click the images to download them |
| 43 | + |
| 44 | +Feel free to open an issue when you create a new pinout leaf and we can add it to the list of existing leafs. |
| 45 | + |
| 46 | +### Premade Leafs |
| 47 | + |
| 48 | +Check the [pinouts](public/pinouts) directory for boards that have already been defined. Open a pull request or ticket if you made one and want it included in the repo. |
| 49 | + |
| 50 | +### Printing |
| 51 | + |
| 52 | +* Download the SVG and open it in a SVG capable tool - your browser is fine. |
| 53 | +* Print and make sure your application or printer driver does not apply and scaling (scale: 100%) |
| 54 | +* Optionally poke holes in the marked pin holes with a needle |
| 55 | +* Push your PCB's pins through the paper, enjoy the labels next to the pins |
27 | 56 |
|
28 | 57 | ### Command-Line Interface (CLI) |
29 | 58 |
|
30 | | -1. Ensure you have Node.js installed. |
31 | | -2. Run the CLI tool with configuration files or directories as arguments: |
| 59 | +1. Clone the repo |
| 60 | +2. Install dependencies: |
| 61 | +```bash |
| 62 | +npm install |
| 63 | +``` |
| 64 | +2. Build the project (for web editor and CLI): |
| 65 | + ```bash |
| 66 | + node build.js |
| 67 | + ``` |
| 68 | +3. Run the CLI tool with configuration files or directories as arguments: |
| 69 | + ```bash |
| 70 | + node public/dist/cli.js path/to/your/config.yaml |
| 71 | + ``` |
| 72 | +4. The tool will generate corresponding `.svg` files (e.g., `config.front.svg`, `config.back.svg`) in the same directory |
| 73 | + as the input files. |
32 | 74 |
|
33 | | - ```bash |
34 | | - node src/cli.js path/to/your/config.yaml path/to/another/config.json some/directory/ |
35 | | - ``` |
36 | | -3. The tool will generate corresponding `.svg` files (e.g., `config.front.svg`, `config.back.svg`) in the same directory as the input files. |
| 75 | +## Configuration Syntax |
37 | 76 |
|
38 | | -## Configuration |
| 77 | +Diagrams are configured using YAML or JSON files. Most things have sensible defaults. |
39 | 78 |
|
40 | | -Diagrams are configured using YAML or JSON files. Key sections include: |
| 79 | +### title |
41 | 80 |
|
42 | | -* `title`: The title displayed on the diagram. |
43 | | -* `width`, `height`: Board dimensions in number of pins. |
44 | | -* `pins`: Defines pin labels and types for `left`, `right`, `top`, `bottom` rows. |
45 | | -* `types`: Custom pin type definitions (colors). |
46 | | -* `image`: Configuration for embedding background images (front/back). |
| 81 | +Defines the title of the diagram |
47 | 82 |
|
48 | | -See the example files in `public/pinouts/` for detailed structure. |
| 83 | +```yaml |
| 84 | +title: "My PCB" |
| 85 | +``` |
| 86 | +
|
| 87 | +### size |
| 88 | +
|
| 89 | +The size of the PCB is defined in the number of pins (assuming a standard pin raster of 0.1 inch aka 2.54mm). Everything else is derived from this size. Best put your board on a breadboard and count. |
| 90 | +
|
| 91 | +```yaml |
| 92 | +width: 4 |
| 93 | +height: 6 |
| 94 | +``` |
| 95 | +
|
| 96 | +### pins |
| 97 | +
|
| 98 | +The tool supports up to four rows of pins: `left`, `right`, `top` and `bottom`. If your board does have a different layout, you're out of luck. |
| 99 | + |
| 100 | +For each row, you define an array of pins. For each pin you define an array of `label:type` strings. You can have empty pins in a row. |
| 101 | + |
| 102 | +```yaml |
| 103 | +pins: |
| 104 | + left: |
| 105 | + - [ "GPIO5:gpio", "A5:analog", "MISO:spi" ] |
| 106 | + - [ "GPIO6:gpio", "MOSI:spi" ] |
| 107 | + - |
| 108 | + - [ "GPIO20:gpio", "RX:uart" ] |
| 109 | + - [ "GPIO21:gpio", "TX:uart" ] |
| 110 | + right: |
| 111 | + - |
| 112 | + - |
| 113 | + - [ "5V:power" ] |
| 114 | + - [ "GND:gnd" ] |
| 115 | + - [ "3V3:power"] |
| 116 | +``` |
49 | 117 |
|
50 | | -## Development |
| 118 | +### types |
51 | 119 |
|
52 | | -1. Install dependencies: |
53 | | - ```bash |
54 | | - npm install |
55 | | - ``` |
56 | | -2. Build the project (for web editor and CLI): |
57 | | - ```bash |
58 | | - node build.js |
59 | | - ``` |
60 | | -3. Start the development server with hot reloading for the web editor: |
61 | | - ```bash |
62 | | - node build.js --serve |
63 | | - ``` |
| 120 | +Types define the background, text color and legend label for a set of pins. Simply give the type a name, define the properties and then use it by name om the pins definition. |
64 | 121 |
|
| 122 | +```yaml |
| 123 | + types: |
| 124 | + mytype: |
| 125 | + label: 'Special Pins' |
| 126 | + bgcolor: '#ff00ff' |
| 127 | + fgcolor: '#000000' |
65 | 128 | ``` |
| 129 | + |
| 130 | +There are the following predefined types, which you can use without defining them yourself: |
| 131 | + |
| 132 | +* `gpio` |
| 133 | +* `power` |
| 134 | +* `gnd` |
| 135 | +* `i2c` |
| 136 | +* `uart` |
| 137 | +* `spi` |
| 138 | +* `analog` |
| 139 | + |
| 140 | +### image |
| 141 | + |
| 142 | +For nicer diagrams you can define background images (JPEG or PNG only) to use instead of a general green PCP background. You can set a front and back side image separately. |
| 143 | + |
| 144 | +Images can be referenced as local file or as URL. In both cases the generator will try to actually embed the image in the generated SVG as a dataurl. |
| 145 | + |
| 146 | +By default your image will be stretched to exactly match the size defined by the pins. However you picture will probably not fit exactly. Using the `left`, `right`, `top` and `bottom` properties you can define offsets from the respective edges. Negative numbers will move the image edge outwards, postive numbers inwards. The offsets are given in one-hundreds of a millimeter, eg. 100 is 1mm. Best interactively experiment in the web editor until the image fits. |
| 147 | + |
| 148 | +```yaml |
| 149 | +image: |
| 150 | + front: |
| 151 | + src: "esp32-c3-super-mini.front.png" |
| 152 | + top: -200 |
| 153 | + left: 50 |
| 154 | + right: 50 |
| 155 | + bottom: -190 |
| 156 | + back: |
| 157 | + src: "https://example.com/productimage.jpeg" |
| 158 | + top: -150 |
| 159 | + left: 50 |
| 160 | + right: 50 |
| 161 | + bottom: -170 |
| 162 | +``` |
| 163 | + |
| 164 | +### offsets |
| 165 | + |
| 166 | +By default the pin rows will sit on the edge of the defined board size. Sometimes you might want to define your board's size larger than the actual pin area is. You then can use the offsets setting to move a pi row further in. |
| 167 | + |
| 168 | +For example the Raspberry Pi has two rows of Pins all the way to the right edge of a much larger board. In this case you might want to define the overall size of the board but then offset the left row of pins so it moves over nearly to the right edge. |
| 169 | + |
| 170 | +Only use positive integers and be sure to not push your row outside of the size dimensions. |
| 171 | + |
| 172 | +```yaml |
| 173 | + offsets: |
| 174 | + left: 0 |
| 175 | + top: 0 |
| 176 | + right: 0 |
| 177 | + bottom: 0 |
| 178 | +``` |
| 179 | + |
| 180 | +# License |
| 181 | + |
| 182 | +MIT License |
| 183 | + |
| 184 | +Copyright (c) 2025 Andreas Gohr |
| 185 | + |
| 186 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 187 | +of this software and associated documentation files (the "Software"), to deal |
| 188 | +in the Software without restriction, including without limitation the rights |
| 189 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 190 | +copies of the Software, and to permit persons to whom the Software is |
| 191 | +furnished to do so, subject to the following conditions: |
| 192 | + |
| 193 | +The above copyright notice and this permission notice shall be included in all |
| 194 | +copies or substantial portions of the Software. |
| 195 | + |
| 196 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 197 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 198 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 199 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 200 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 201 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 202 | +SOFTWARE. |
0 commit comments