Add resistor/capacitor/SMD value calculator with component image generation#1435
Open
Sebbeben wants to merge 1 commit into
Open
Add resistor/capacitor/SMD value calculator with component image generation#1435Sebbeben wants to merge 1 commit into
Sebbeben wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1435 +/- ##
============================================
+ Coverage 58.49% 58.86% +0.36%
- Complexity 8701 8856 +155
============================================
Files 638 640 +2
Lines 28123 28530 +407
============================================
+ Hits 16451 16793 +342
- Misses 11672 11737 +65 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bedfb8b to
27e99c8
Compare
…ration Draws schematic-style SVG pictures of passive components from their value and attaches them to parts — for illustrating bulk assortments imported without pictures. - Value calculator tool (Tools menu): interactive resistor (colour bands), SMD resistor (3/4-digit/EIA-96 code) and ceramic capacitor (disc/MLCC) drawing, with bidirectionally-linked value/code/band fields and appearance controls. - "Generate image" button on parts without a picture, opening the calculator pre-filled from the part's value and attaching via AJAX. - "Generate component images" parts-table bulk action: classifies the selected parts, reads their properties, shows a live-preview review table, then batch-attaches pictures and/or writes suggested KiCad symbol/footprint/reference. - ComponentValueGuesser service: classification + value/tolerance/voltage/power/ ppm/pitch/diameter/colour/SMD-package detection from parameters or name/description. - GeneratedImageAttachmentHelper: stores the SVG as a sanitized picture attachment via the existing upload pipeline, with optional overwrite of a prior generated image. - New @tools.value_calculator permission; edit-permission + CSRF-guarded endpoints. - Unit tests (ComponentValueGuesser) + functional tests (tool controllers); usage documentation.
27e99c8 to
9ebf399
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
I often order component assortments — resistor and capacitor kits — from AliExpress. They show up as a big box of values, and when I import them into Part-DB it's honestly a bit sad to see rows of blank thumbnails with almost no information. So I built a tool that draws a clean, consistent picture for each passive component straight from its value, and can illustrate a whole assortment in one go.
What it does
Value calculator (Tools → Value calculator) — interactively draw a:
Value ⇄ code ⇄ bands are bidirectionally linked and the picture redraws live. Output is a transparent SVG, so it stays crisp at any size.
Generate on a part — a part with no picture shows a Generate image button in the picture area that opens the calculator pre-filled from the part's value; attach it without leaving the page.
Bulk "Generate component images" — a parts-table action that classifies the selected parts, reads their value and properties (from parameters, else the name/description), and shows a review table with a live preview per part. From there you can attach the pictures and/or write suggested KiCad symbol / footprint / reference to the parts. Only parts without a picture are listed; an overwrite mode can re-generate ones that already have a (generated) picture.
Detection follows real-world conventions: capacitor tolerance → code letter (
104K), through-hole resistor tolerance/ppm → colour bands, SMD resistor tolerance → 3- vs 4-digit code, power → resistor body size, etc.Implementation notes
ComponentValueGuesserservice classifies a part and parses value / tolerance / voltage / power / ppm / pitch / diameter / body-colour / SMD-package from parameters or free text (name/description), and suggests a KiCad symbol + footprint.GeneratedImageAttachmentHelperstores the SVG as a picture attachment through the existing upload pipeline (so the SVG is sanitized), optionally replacing a previous generated image — manually uploaded pictures are never removed.generate_imageandset_edaendpoints requireediton the part plus a per-part CSRF token; the tool sits behind a new@tools.value_calculatorpermission.ComponentValueGuesser; usage docs atdocs/usage/component_image_generator.md.The generated images are illustrations (code/bands + dimension callouts), not photographs.
Screenshots
Value calculator (resistor / SMD / capacitor tabs)



"How to get the most auto-filled" help panel

Bulk action in the parts table

Bulk review with live previews

Testing
ComponentValueGuesserTestcovers value parsing (including the kΩ/MΩ cases), classification, and the property/EDA detection.