Skip to content

Treat uppercase M as mega when grouping component values - #584

Merged
qu1ck merged 1 commit into
openscopeproject:masterfrom
DominikPalo:fix-mega-milli-units
Oct 6, 2026
Merged

qu1ck merged 1 commit into
openscopeproject:masterfrom
DominikPalo:fix-mega-milli-units

Conversation

@DominikPalo

Copy link
Copy Markdown
Contributor

units.compMatch (used by componentValue to build the BOM grouping key for the Value column) lowercased the whole value before parsing. A single-letter M prefix was therefore always read as milli, since PREFIX_MILLI contains "m" and PREFIX_MEGA only has "mega"/"meg".

As a result, a 1 MΩ resistor and a 1 mΩ current-sense shunt with the same footprint were grouped into one BOM row, and the row was labelled with the first part's value (e.g. "1M"). Values like 4M7 (4.7 MΩ) or 2.2MΩ were also treated as milli.

This change still matches case-insensitively, but when the parsed prefix is the single letter m it checks the original character: uppercase M resolves to mega. Nothing else changes: Meg/MEG/mega, all other prefixes, the 4M7 style and the decimal/thousands separator handling behave as before.

Testing

componentValue() on master vs this branch:

Value master this PR
1M, 1MOhm (R) 0.001 R 1e6 R
4M7 (R) 0.0047 R 4.7e6 R
2.2MΩ (R) 0.0022 R 2.2e6 R
10M (C) 0.01 F 1e7 F
1m, 1mR, 1mOhm, 4m7, 2.2mΩ, 10mH milli milli (unchanged)
1Meg, 1MEG, 1meg, 1mega, 4k7, 4K7, 0R1, 100n, 1,000 unchanged

End to end, an Eagle test board with three parts in the same package with values 1M, 1m and 1MOhm:

  • master: one BOM row [R1, R2, R3], all shown as "1M"
  • this PR: [R1, R3] ("1M") and [R2] ("1m")

Note: this follows the SI prefix letter strictly, so a value like 10M on a capacitor now parses as megafarads rather than millifarads. Neither is a realistic capacitor value. Legacy notations like 10MFD for microfarads were not recognized before and still aren't.

🤖 Generated with Claude Code

compMatch lowercased the value before parsing, so a single letter M
prefix was always read as milli. 1M, 1m and 1MOhm resistors were
grouped into one BOM row (all shown as 1M), and values like 4M7 or 10M
were misinterpreted. Keep matching case-insensitively but resolve a
single letter m prefix to mega when it was written as uppercase M.
Other prefixes and spellings like Meg or mega are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qu1ck
qu1ck merged commit cd5db44 into openscopeproject:master Oct 6, 2026
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.

2 participants