diff --git a/doc/PDL.md b/doc/PDL.md index 6989e82..991450e 100644 --- a/doc/PDL.md +++ b/doc/PDL.md @@ -4,6 +4,8 @@ A `.pdl` file describes a circuit part as data: its artwork, its pins, the properties a user can edit, and how it behaves in a simulation. Parts written this way need no Dart and no rebuild — drop the file and its SVG into `packages/pinbench_parts/assets/parts//` and it appears in the palette. +A part can also take its drawing from a Dart painter instead of an SVG, and +keep everything else as data — see [PAINTER](#painter). This exists because most parts do not need bespoke drawing code. A sensor, a module, a passive component: a photograph-accurate body from an SVG, a few @@ -21,15 +23,22 @@ shipped parts and draws them. | Part | Exercises | | --- | --- | -| `ldr` — photoresistor | `PHYSICS resistor` driven by a property | +| `ldr` — photoresistor | `PHYSICS resistor` driven by a property; a `PAINTER` body and an `ALIAS` | | `thermistor` — 10k NTC | an exponential curve (`exp`) over two steps of state | | `slide_switch` — SPST | a boolean property, and `visual.*` driving a shape | -| `cr2032` — coin cell | `PHYSICS voltageSource` | -| `diode_1n4148` | `PHYSICS` only — no rules at all | +| `cr2032` — coin cell | `PHYSICS voltageSource`; a `PAINTER` body | +| `capacitor_electrolytic` — polarized | `PHYSICS capacitor` driven by a µF property; a `PAINTER` body | +| `diode_1n4148` — switching | `PHYSICS` only — no rules at all; a `PAINTER` body | +| `diode_1n4007` — rectifier, `diode_1n5819` — Schottky | `PHYSICS diode` with each part's own model numbers; one `PAINTER` shared by three parts | | `pir_sensor` — PIR motion | `LOGIC` — a one-shot needing a clock | | `tmp36`, `lm35` — analog temperature | `PHYSICS voltageSource` driven by a property, read by `analogRead` | | `soil_moisture` — capacitive probe | an inverted, offset output range in two steps of state | -| `battery_9v` | `PHYSICS voltageSource`, like the coin cell | +| `battery_9v` | `PHYSICS voltageSource`, like the coin cell; a `PAINTER` body | +| `transistor` — seven types, TO-92 and TO-220 | `CONFIGURATION` — one part picked by its Type: `PHYSICS npn`/`pnp`/`nmos`/`pmos`/`npnDarlington`, power MOSFETs with their own `vto` and `kp` | +| `slide_switch_spdt` — SPDT | `PHYSICS spdt` thrown by an `enum` property; a `PAINTER` that slides its lever to match | +| `seven_segment` — common cathode | `PHYSICS ledArray` of eight dies and two tied cathode pins; `LOGIC` into `STATE` per segment; a `PAINTER` that lights each | +| `ir_receiver` — VS1838B | `PHYSICS resistor` only — its internal pull-up; the IR Remote part's presses arrive on OUT as timed NEC codes, played in by the engine | +| `rgb_led` — common cathode | `PHYSICS rgbLed`, the `led_array` `LOGIC` reading a current per pin into `STATE`, and a `PAINTER` that lights up from that state | | `bh1750` — light, I²C | `LOGIC` serving a pointer-less register bank; opcodes tracked in `STATE` | | `mpu6050` — accelerometer + gyro, I²C | `LOGIC` serving registers the sketch configures; an address set by wiring AD0 | | `ds1307` — real-time clock, I²C | `LOGIC` keeping time on the simulated clock; an `enum` property | @@ -37,24 +46,26 @@ shipped parts and draws them. ## A complete example -This is the part shipped at `assets/parts/ldr/ldr.pdl`. Nothing else is -needed to make a working photoresistor. +This is the part shipped at `assets/parts/ldr/ldr.pdl`. Everything about how +it behaves is here; the only Dart it leans on is its drawing, the `ldr` +painter. ```pdl -# Photoresistor (LDR) — resistance falls as light rises. +# LDR (photoresistor) — resistance falls as light rises. -PART "Photoresistor" +PART "LDR" +ALIAS "Photoresistor" ID ldr CATEGORY sensors DESCRIPTION "Light-dependent resistor" -SIZE 12.7mm 6.35mm -SVG "ldr.svg" +SIZE 56px 52px +PAINTER ldr PINS # id x y role label - a 4px 20px passive "A" - b 68px 20px passive "B" + a 20px 52px passive "A" + b 36px 52px passive "B" PROPERTIES darkResistance number 1000000 unit:"Ω" label:"Dark resistance" @@ -104,18 +115,80 @@ body sizes so the part is drawn the size the real thing is. | `ID ` | yes | Stable key. **Permanent** — see below. | | `SIZE ` | yes | Footprint. | | `SVG ""` | yes¹ | Artwork, relative to this file. | +| `PAINTER ` | yes¹ | Draws the body with a registered Dart painter — see [PAINTER](#painter). | +| `ALIAS ""` | no | Another name the part answers to. Repeatable. | | `CATEGORY ` | no | Palette group (`sensors`, `basic`, `actuators`, …). | | `DESCRIPTION ""` | no | Palette tooltip. | | `ORIGIN ` | no | Part origin inside the footprint. Defaults to the centre. | | `LOGIC ` | no | Names a Dart behaviour — see [LOGIC](#logic). | +| `CONFIGURATION "