Lib-electronic-components similarity-led

Use when working with LED similarity calculations - comparing LED MPNs, understanding color bins, brightness bins, families, or LED-specific similarity logic.

install
source · Clone the upstream repo
git clone https://github.com/Cantara/lib-electronic-components
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Cantara/lib-electronic-components "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/similarity-led" ~/.claude/skills/cantara-lib-electronic-components-similarity-led && rm -rf "$T"
manifest: .claude/skills/similarity-led/SKILL.md
source content

LED Similarity Calculator Skill

Guidance for working with

LEDSimilarityCalculator
in the lib-electronic-components library.


For metadata-driven similarity architecture, see

/similarity-metadata
:

  • SpecImportance levels (CRITICAL, HIGH, MEDIUM, LOW, OPTIONAL)
  • ToleranceRule types (exactMatch, percentageTolerance, minimumRequired, etc.)
  • SimilarityProfile contexts (DESIGN_PHASE, REPLACEMENT, COST_OPTIMIZATION, etc.)
  • Calculator integration patterns and gotchas

Overview

The

LEDSimilarityCalculator
compares LEDs based on:

  • LED family - Same manufacturer series
  • Bin codes - Brightness and color temperature bins
  • Color temperature - Must match for high similarity

Applicable Types

ComponentType.LED
// Any type starting with "LED_"
// Uses getBaseType() == ComponentType.LED

Returns

false
for
null
type.

Similarity Thresholds

HIGH_SIMILARITY = 0.9;   // Same LED, same color temp
MEDIUM_SIMILARITY = 0.7; // Different families but valid LEDs
LOW_SIMILARITY = 0.3;    // Different color temperatures

LED Equivalent Groups

TI High-Power LED Series

GroupMembers
TLHR5400 (Red)TLHR5400, TLHR5401, TLHR5402, TLHR5403
TLHG5800 (Green)TLHG5800, TLHG5801, TLHG5802, TLHG5803
TLHB5800 (Blue)TLHB5800, TLHB5801, TLHB5802, TLHB5803

LG LED Series

GroupMembers
LG R971 (Red)LG R971, LG R971-KN, LG R971-PK
LG B971 (Blue)LG B971, LG B971-KN, LG B971-PK
LG G971 (Green)LG G971, LG G971-KN, LG G971-PK

Samsung LM Series

GroupMembers
LM301BLM301B, LM301B-K, LM301B-V2
LM281BLM281B, LM281B-K, LM281B-V2

Nichia NCS Series

GroupMembers
NCSW (White)NCSW170, NCSW170T, NCSW170AT
NCSR (Red)NCSR170, NCSR170T, NCSR170AT

Bin Code Handling

LEDs use bin codes for brightness and color sorting:

Brightness Bins (Typical)

  • K
    ,
    L
    ,
    M
    ,
    N
    - Brightness grades

Color Temperature Bins (Cree)

  • FK*
    - One color temperature
  • FC*
    - Different color temperature
// Same color temperature = HIGH
calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FKB", registry);
// Returns 0.9

// Different color temperatures = LOW
calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);
// Returns 0.3

Family Detection

PrefixManufacturerFamily
TLHRTIRed LED
TLHGTIGreen LED
TLHBTIBlue LED
TLWTIWhite LED
LG R/B/GLGColor LEDs
LW, LR, LSOsramStandard LEDs
XP, XB, XQCreeHigh-power LEDs
L130, L135LumiledsLUXEON series
LMSamsungLM series
NCSNichiaStandard series

Package Compatibility

Package TypeCompatible Packages
SMDSMD, PLCC, 3528, 5050, 2835, 3030, 5630, 0603, 0805, 1206
Through-HoleTH, DIP, 5MM, 3MM, 8MM, 10MM, T-1, T-1¾
High-PowerSTAR, MCE, XPE, XPG, XML, LUXEON, REBEL

Test Examples

// Same LED
calculator.calculateSimilarity("TLHR5400", "TLHR5400", registry);
// Returns 0.9

// Same family, different bin
calculator.calculateSimilarity("TLHR5400", "TLHR5401", registry);
// Returns 0.9

// LG variants with suffix
calculator.calculateSimilarity("LG R971", "LG R971-KN", registry);
// Returns 0.9

// Different color temps
calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);
// Returns 0.3

Metadata-Driven Implementation (January 2026)

Status: ✅ Converted (PR #118)

The

LEDSimilarityCalculator
now uses a metadata-driven approach with spec-based comparison.

Specs Compared

SpecImportanceTolerance RuleDescription
colorCRITICALexactMatchRed, Green, Blue, White, etc.
familyHIGHexactMatchTLHR, LG R, LM301, XP-E, etc.
brightnessHIGHexactMatchBrightness bin code
packageLOWexactMatch0603, 0805, 5mm, SMD, etc.

Implementation Pattern

// Short-circuit check for CRITICAL incompatibility
if (!color1.isEmpty() && !color2.isEmpty() && !color1.equals(color2)) {
    return LOW_SIMILARITY;
}

// Weighted spec scoring
// color: CRITICAL (1.0 weight)
// family: HIGH (0.7 weight)
// brightness: HIGH (0.7 weight)
// package: LOW (0.2 weight)

// Family boost for known equivalent groups
if (areSameFamily(mpn1, mpn2)) {
    similarity = Math.max(similarity, HIGH_SIMILARITY);
}

Behavior Changes

ComparisonLegacy ResultMetadata ResultNotes
TLHR5400 vs TLHR54010.90.96Same family, different bins
LG R971 vs LG R971-KN0.91.0Exact family + color match
TLHR5400 vs LCW E6SF0.70.66Different families, same color
XPERED-L1-FKA vs XPERED-L1-FCA0.30.3Short-circuit on color temp

Why more accurate: Metadata approach prioritizes color matching (CRITICAL) and separates family from brightness considerations.


Learnings & Quirks

Color Temperature Codes

  • Cree uses
    FK
    /
    FC
    in bin codes to indicate color temp
  • Same base LED with different color temps are NOT equivalent

Brightness Bin Codes

  • Adjacent brightness bins (K vs L) are usually interchangeable
  • Large gaps in brightness bins may not be suitable substitutes

LG LED Format

  • Format:
    LG R971-KN
    where
    -KN
    is the suffix variant
  • All suffix variants of same base part are equivalent

Package Suffixes

  • -RL
    ,
    -RT
    = Tape and reel packaging
  • -TUBE
    = Tube packaging
  • These don't affect LED equivalence
<!-- Add new learnings above this line -->