Skip to content

feat(components): add diode variants and potentiometer/rheostat - #67

Merged
eduardozf merged 7 commits into
mainfrom
feat/diode-variants-and-pot
Sep 6, 2026
Merged

eduardozf merged 7 commits into
mainfrom
feat/diode-variants-and-pot

Conversation

@eduardozf

@eduardozf eduardozf commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

Adds ZenerDiode, SchottkyDiode, Photodiode, Rheostat, and the three-terminal Potentiometer to the standard library, with catalog, authoring docs, and rendered gallery examples.

Potentiometer labels sit opposite the wiper and its arrow touches the track. The layout can mirror the wiper toward its load. Vertical two-terminal branches use connection order and explicit power/ground references to choose their orientation in horizontal flows. Adjacent facing terminals connect directly, and lower-rail ground connections pass around the glyph rather than through its bars. Vertical optical component labels leave space for the light arrows.

The examples now describe coherent circuits:

  • The diode example uses a 1 kΩ resistor ahead of the shared Zener bias, displays voltage=3.3V, reverse-biases the photodiode, and connects its 100 kΩ sense resistor and Zener return to one explicit GND net.
  • The divider example identifies the rheostat as an output load, uses a vertical track with a right-facing wiper, and labels OUT.
  • Named ground and sense connections remove long return loops.

Closes #25
Closes #26

Validation

All 173 tests pass, plus typecheck, lint, docs formatting, and full build. Both examples pass the bundled CLI with zero diagnostics.

Regression checks cover the original potentiometer label/arrow issues across four directions and two orientations, outward ground-terminal approach, example net memberships, diode polarity, Zener voltage labels, direct connections, visible OUT, and absence of collinear overlaps and foreign-terminal hits in both examples.

Release 0.3.1 alone did not fix the reported discrete-component issues. These fixes are included here. General annotation collision avoidance is unchanged.

Render comparisons

Images and exact fixtures live on the throwaway demo/pr-67-v031-assets branch under docs/assets/pr-67-v031/realistic/, outside the feature branch. All images use the bundled SVG renderer and Resvg.

The following unchanged sources compile on main. Main 0.3.1 94896ab is on the left; this branch is on the right.

Direct connection

Main This branch
Main Branch

Ground terminal approach

Main This branch
Main Branch

Vertical diode branch

Main This branch
Main Branch

The new types do not compile on main. These gallery comparisons show the prior PR examples at d3a1828 on the left and the corrected circuits on the right. They include the source edits described above.

Loaded divider

Previous example Corrected example
Before After

Diode bias and sensing circuit

Previous example Corrected example
Before After

Investigation and fix report

Expand the standard library with the most-reached-for variable resistors
and diode-family parts (closes #25, closes #26).

#26 — Diode variants:
- ZenerDiode, SchottkyDiode, Photodiode, all reusing the Diode A/C
  terminals and anode/cathode roles.
- Refactor drawDiode into a shared drawDiodeBody helper; each variant adds a
  distinct cathode treatment (Zener lip bar, Schottky squared-S hooks,
  Photodiode inward "incident light" arrows).

#25 — Potentiometer + Rheostat:
- Rheostat: two-terminal variable resistor (resistor body + diagonal arrow).
- Potentiometer: three-terminal (1, W, 2) with a wiper role. Adds a layout
  geometry branch placing the wiper as a perpendicular midpoint tap and an
  absolute-coordinate drawer, the same approach used for the transistor.
  The wiper auto-derives its side from position, so orientation hints rotate
  it correctly.

Tests: parts-catalog resolution for the new two-terminal parts, a
potentiometer block covering the wiper role and alias, and a snapshot.
Docs: MVP component table, CONTEXT wiper role, the authoring skill, plus two
new gallery examples (pot-divider, diode-variants).
@eduardozf eduardozf self-assigned this Jun 30, 2026
The Zener used a non-standard bracket-shaped cathode bar (both ends bent
toward the anode) to avoid resembling the existing TVS mark. That reads as
wrong. Use the canonical Zener "Z" bar instead — top end bent toward the
anode, bottom toward the cathode. A unidirectional TVS shares this standard
mark by design; the bidirectional TVS remains the two-triangle form.
@eduardozf

Copy link
Copy Markdown
Owner Author

Fixed the Zener symbol after review. It was drawn with a non-standard bracket-shaped cathode bar (both ends bent toward the anode) to avoid resembling the existing TVS mark — but that just looked wrong.

Now it uses the canonical Zener "Z" bar (top end bent toward the anode, bottom toward the cathode). A unidirectional TVS shares this standard mark by design; the bidirectional TVS stays the two-triangle form. Pushed as ae5795c, and the diode-variants image above is updated.

Re-checked the rest of the family against the standard symbols and the existing house style — all correct:

  • Diode straight bar · Schottky squared-S hooks · Photodiode straight bar + inward "incident light" arrows (the inverse of the LED's outward arrows, same label placement the LED already uses)
  • Potentiometer resistor body + perpendicular wiper tap · Rheostat resistor + diagonal arrow

@eduardozf

Copy link
Copy Markdown
Owner Author

Audit visual verification

main cannot compile these new component types, so the meaningful before is the original PR head (60b044d) and after is the audited fix set. The after-side code changes are prepared in the isolated audit worktree and still need to be applied to the PR branch.

All images were produced from real .wire source with the bundled scripts/wire-to-png.mjs renderer at 1200 px. The focused sources pass wire check. Assets live on demo/pr-67-audit-assets at docs/assets/pr-67-audit/ (commit 63b7b0a).

Potentiometer divider — wiper contact and label clearance

Before, RV1/10k sits on the connected wiper wire and the arrow stops short of the track. After, the arrow touches the track and labels move laterally clear of the wire.

Before — original PR head After — audited fix
Potentiometer divider before Potentiometer divider after

Vertical potentiometer — rotated label clearance

Before, the labels overlap the upper terminal wire. After, the wiper, track, and labels rotate together with the labels clear of the connection.

Before — original PR head After — audited fix
Vertical potentiometer before Vertical potentiometer after

Semantic diode roles — reversed local terminal declaration

The local component declares K before P but maps anode=P and cathode=K. Before, the glyph follows declaration order and incorrectly points toward ANODE. After, it follows the semantic role mapping and points toward CATHODE.

Before — original PR head After — audited fix
Semantic photodiode before Semantic photodiode after

Diode-family example — polarity and annotation correction

The submitted example forward-biased the photodiode despite describing a sensing leg, and the Zener annotation crossed a wire. After, the photodiode is reverse-biased and the obstructing annotation is removed.

Before — original PR head After — audited fix
Diode-family example before Diode-family example after

@eduardozf

Copy link
Copy Markdown
Owner Author

Implemented all five review fixes in 753539f:

  • Reverse-biased the photodiode, with its cathode connected to the bias rail.
  • Added a 1 kΩ resistor ahead of the Zener branch and displayed its nominal 3.3 V rating.
  • Joined the returns into one explicit GND net.
  • Simplified routing, oriented the divider wiper toward its load, and routed ground connections around the symbol bars.
  • Corrected the divider description: the rheostat loads OUT to ground. OUT and SENSE are now visible.

All 173 tests pass, along with typecheck, lint, docs formatting, and the full build. Both examples compile without diagnostics.

Loaded potentiometer divider

Previous example Corrected example
Divider before Divider after

Diode bias and sensing circuit

Previous example Corrected example
Diodes before Diodes after

These two comparisons include the circuit source corrections. The previous examples are from PR commit d3a1828.

Ground connection regression

Same source on main 0.3.1 94896ab and the fixed branch. The wire now approaches the terminal from outside the glyph instead of passing through its bars.

Main Fixed branch
Ground before Ground after

Direct connection

Same source on main 0.3.1 and the fixed branch. Adjacent facing terminals now connect directly.

Main Fixed branch
Connection before Connection after

All images were generated from actual .wire sources using the bundled SVG renderer and Resvg. Images and source fixtures live on the throwaway demo/pr-67-v031-assets branch under docs/assets/pr-67-v031/realistic/, keeping binaries out of the feature diff.

@eduardozf
eduardozf merged commit 747a83f into main Sep 6, 2026
2 checks passed
@eduardozf
eduardozf deleted the feat/diode-variants-and-pot branch September 6, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Zener, Schottky, and photodiode diode variants Add potentiometer / variable resistor

1 participant