# Enclosure for a circuit board ## What this builds A box and a lid for a circuit board, to print on a 3D printer. The model is written as code, so the size follows the person's numbers, and a script measures what was built against what this spec says it must be. Read `spekkr.inputs.json` first. The inside of the box is `inner_length` by `inner_width` by `inner_height`, the walls are `wall` thick, and the outside corners have `corner_radius`. `standoffs` and `cable_slot` add features. `tool` says what the model is written in. All lengths are millimetres. ## Out of scope - Screws through the lid, hinges and seals. The lid is held by its fit. - Openings for particular connectors, displays or buttons. - Slicing for a particular printer. ## Requirements Each requirement has an id. Checks name the id they cover. ### R1. Inputs - The five lengths are numbers. `wall` is from 1.2 to 5. `corner_radius` is 0 or more, and at most half the smaller outside side. - The inside must be at least 20 by 20 by 10. - A value outside these is refused before anything is modelled, with a message that names the input and the limit. Accept when: each limit has a check with a value just inside and one just outside. ### R2. The base - An open box. Its outside is `inner_length` plus two walls long, `inner_width` plus two walls wide, and `inner_height` plus one wall high. The floor is one wall thick. - The four vertical outside edges are rounded with `corner_radius`. The inside corners are rounded with that radius less one wall, or square if that is not more than zero. No other edge is rounded. - The origin is the centre of the outside of the floor, with the box rising along +Z. Accept when: the base's bounding box and volume match `design.md` at the default inputs, and match the formulas there at two other sets of inputs. ### R3. Standoffs Only if `standoffs` is on. - Four posts rise 5 from the floor, each 6 across with a pilot hole 2.5 across down its full height, for an M3 self-tapping screw. The hole does not go into the floor. - Their centres are 5 in from each inside wall. Accept when: the base's volume grows by the amount in `design.md`, and the four centres are where the table there puts them. ### R4. Cable slot Only if `cable_slot` is on. - A slot 12 wide and 7 deep, cut down from the top edge of the short wall at +X, centred across that wall, through the whole wall. Accept when: the base's volume shrinks by the amount in `design.md`. ### R5. The lid - A plate with the same outline as the base, one wall thick. - Under it, a lip 3 high and 1.6 thick that goes inside the base. There is 0.2 between the lip and the inside of the walls, all the way round. - Modelled in the position it prints in: plate down, lip up. Accept when: the lid's bounding box and volume match `design.md`, and with the lid placed on the base the two solids do not overlap anywhere. ### R6. Printable - Each part prints flat side down with no support: nothing overhangs by more than 45 degrees from vertical. - Each part is one closed solid, with no holes in its surface and no faces that pass through each other. Accept when: a mesh check reports each exported part as watertight, and a check of face directions finds no overhang past 45 degrees in the print position. ### R7. Files - `base` and `lid` as separate files: STEP and STL if `tool` is `cadquery`, STL if it is `openscad`. - STL files are in millimetres, with curves fine enough that no flat piece of a rounded corner is longer than 0.5. - The source that makes them, and one command that makes everything from the inputs. Accept when: running the command from a clean folder writes every file, and running it twice writes the same bytes. ### R8. A report - The command ends by writing `report.md`: the inputs, each part's bounding box and volume, what `design.md` says they should be, and pass or fail for each. Accept when: the report is written, and a deliberately wrong wall thickness in the model makes it say fail. ## Definition of done - Every acceptance check above runs from one command, and all pass at the person's inputs. - A README says how to install the tool, how to make the parts, how to print them, and what the lid's fit was designed for.