LED Similarity Calculator Skill
Guidance for working with LEDSimilarityCalculator in the lib-electronic-components library.
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
| Group |
Members |
| TLHR5400 (Red) |
TLHR5400, TLHR5401, TLHR5402, TLHR5403 |
| TLHG5800 (Green) |
TLHG5800, TLHG5801, TLHG5802, TLHG5803 |
| TLHB5800 (Blue) |
TLHB5800, TLHB5801, TLHB5802, TLHB5803 |
LG LED Series
| Group |
Members |
| 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
| Group |
Members |
| LM301B |
LM301B, LM301B-K, LM301B-V2 |
| LM281B |
LM281B, LM281B-K, LM281B-V2 |
Nichia NCS Series
| Group |
Members |
| 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
| Prefix |
Manufacturer |
Family |
| TLHR |
TI |
Red LED |
| TLHG |
TI |
Green LED |
| TLHB |
TI |
Blue LED |
| TLW |
TI |
White LED |
| LG R/B/G |
LG |
Color LEDs |
| LW, LR, LS |
Osram |
Standard LEDs |
| XP, XB, XQ |
Cree |
High-power LEDs |
| L130, L135 |
Lumileds |
LUXEON series |
| LM |
Samsung |
LM series |
| NCS |
Nichia |
Standard series |
Package Compatibility
| Package Type |
Compatible Packages |
| SMD |
SMD, PLCC, 3528, 5050, 2835, 3030, 5630, 0603, 0805, 1206 |
| Through-Hole |
TH, DIP, 5MM, 3MM, 8MM, 10MM, T-1, T-1¾ |
| High-Power |
STAR, 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
| Spec |
Importance |
Tolerance Rule |
Description |
| color |
CRITICAL |
exactMatch |
Red, Green, Blue, White, etc. |
| family |
HIGH |
exactMatch |
TLHR, LG R, LM301, XP-E, etc. |
| brightness |
HIGH |
exactMatch |
Brightness bin code |
| package |
LOW |
exactMatch |
0603, 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
| Comparison |
Legacy Result |
Metadata Result |
Notes |
| TLHR5400 vs TLHR5401 |
0.9 |
0.96 |
Same family, different bins |
| LG R971 vs LG R971-KN |
0.9 |
1.0 |
Exact family + color match |
| TLHR5400 vs LCW E6SF |
0.7 |
0.66 |
Different families, same color |
| XPERED-L1-FKA vs XPERED-L1-FCA |
0.3 |
0.3 |
Short-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
1---2name: similarity-led-23description: Use when working with LED similarity calculations - comparing LED MPNs, understanding color bins, brightness bins, families, or LED-specific similarity logic.4---56# LED Similarity Calculator Skill78Guidance for working with `LEDSimilarityCalculator` in the lib-electronic-components library.910## Overview1112The `LEDSimilarityCalculator` compares LEDs based on:13- **LED family** - Same manufacturer series14- **Bin codes** - Brightness and color temperature bins15- **Color temperature** - Must match for high similarity1617## Applicable Types1819```java20ComponentType.LED21// Any type starting with "LED_"22// Uses getBaseType() == ComponentType.LED23```2425Returns `false` for `null` type.2627## Similarity Thresholds2829```java30HIGH_SIMILARITY = 0.9; // Same LED, same color temp31MEDIUM_SIMILARITY = 0.7; // Different families but valid LEDs32LOW_SIMILARITY = 0.3; // Different color temperatures33```3435## LED Equivalent Groups3637### TI High-Power LED Series38| Group | Members |39|-------|---------|40| TLHR5400 (Red) | TLHR5400, TLHR5401, TLHR5402, TLHR5403 |41| TLHG5800 (Green) | TLHG5800, TLHG5801, TLHG5802, TLHG5803 |42| TLHB5800 (Blue) | TLHB5800, TLHB5801, TLHB5802, TLHB5803 |4344### LG LED Series45| Group | Members |46|-------|---------|47| LG R971 (Red) | LG R971, LG R971-KN, LG R971-PK |48| LG B971 (Blue) | LG B971, LG B971-KN, LG B971-PK |49| LG G971 (Green) | LG G971, LG G971-KN, LG G971-PK |5051### Samsung LM Series52| Group | Members |53|-------|---------|54| LM301B | LM301B, LM301B-K, LM301B-V2 |55| LM281B | LM281B, LM281B-K, LM281B-V2 |5657### Nichia NCS Series58| Group | Members |59|-------|---------|60| NCSW (White) | NCSW170, NCSW170T, NCSW170AT |61| NCSR (Red) | NCSR170, NCSR170T, NCSR170AT |6263## Bin Code Handling6465LEDs use bin codes for brightness and color sorting:6667### Brightness Bins (Typical)68- `K`, `L`, `M`, `N` - Brightness grades6970### Color Temperature Bins (Cree)71- `FK*` - One color temperature72- `FC*` - Different color temperature7374```java75// Same color temperature = HIGH76calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FKB", registry);77// Returns 0.97879// Different color temperatures = LOW80calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);81// Returns 0.382```8384## Family Detection8586| Prefix | Manufacturer | Family |87|--------|--------------|--------|88| TLHR | TI | Red LED |89| TLHG | TI | Green LED |90| TLHB | TI | Blue LED |91| TLW | TI | White LED |92| LG R/B/G | LG | Color LEDs |93| LW, LR, LS | Osram | Standard LEDs |94| XP, XB, XQ | Cree | High-power LEDs |95| L130, L135 | Lumileds | LUXEON series |96| LM | Samsung | LM series |97| NCS | Nichia | Standard series |9899## Package Compatibility100101| Package Type | Compatible Packages |102|--------------|---------------------|103| SMD | SMD, PLCC, 3528, 5050, 2835, 3030, 5630, 0603, 0805, 1206 |104| Through-Hole | TH, DIP, 5MM, 3MM, 8MM, 10MM, T-1, T-1¾ |105| High-Power | STAR, MCE, XPE, XPG, XML, LUXEON, REBEL |106107## Test Examples108109```java110// Same LED111calculator.calculateSimilarity("TLHR5400", "TLHR5400", registry);112// Returns 0.9113114// Same family, different bin115calculator.calculateSimilarity("TLHR5400", "TLHR5401", registry);116// Returns 0.9117118// LG variants with suffix119calculator.calculateSimilarity("LG R971", "LG R971-KN", registry);120// Returns 0.9121122// Different color temps123calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);124// Returns 0.3125```126127---128129## Metadata-Driven Implementation (January 2026)130131**Status**: ✅ Converted (PR #118)132133The `LEDSimilarityCalculator` now uses a **metadata-driven approach** with spec-based comparison.134135### Specs Compared136137| Spec | Importance | Tolerance Rule | Description |138|------|-----------|----------------|-------------|139| **color** | CRITICAL | exactMatch | Red, Green, Blue, White, etc. |140| **family** | HIGH | exactMatch | TLHR, LG R, LM301, XP-E, etc. |141| **brightness** | HIGH | exactMatch | Brightness bin code |142| **package** | LOW | exactMatch | 0603, 0805, 5mm, SMD, etc. |143144### Implementation Pattern145146```java147// Short-circuit check for CRITICAL incompatibility148if (!color1.isEmpty() && !color2.isEmpty() && !color1.equals(color2)) {149 return LOW_SIMILARITY;150}151152// Weighted spec scoring153// color: CRITICAL (1.0 weight)154// family: HIGH (0.7 weight)155// brightness: HIGH (0.7 weight)156// package: LOW (0.2 weight)157158// Family boost for known equivalent groups159if (areSameFamily(mpn1, mpn2)) {160 similarity = Math.max(similarity, HIGH_SIMILARITY);161}162```163164### Behavior Changes165166| Comparison | Legacy Result | Metadata Result | Notes |167|-----------|--------------|-----------------|-------|168| TLHR5400 vs TLHR5401 | 0.9 | 0.96 | Same family, different bins |169| LG R971 vs LG R971-KN | 0.9 | 1.0 | Exact family + color match |170| TLHR5400 vs LCW E6SF | 0.7 | 0.66 | Different families, same color |171| XPERED-L1-FKA vs XPERED-L1-FCA | 0.3 | 0.3 | Short-circuit on color temp |172173**Why more accurate**: Metadata approach prioritizes color matching (CRITICAL) and separates family from brightness considerations.174175---176177## Learnings & Quirks178179### Color Temperature Codes180- Cree uses `FK`/`FC` in bin codes to indicate color temp181- Same base LED with different color temps are NOT equivalent182183### Brightness Bin Codes184- Adjacent brightness bins (K vs L) are usually interchangeable185- Large gaps in brightness bins may not be suitable substitutes186187### LG LED Format188- Format: `LG R971-KN` where `-KN` is the suffix variant189- All suffix variants of same base part are equivalent190191### Package Suffixes192- `-RL`, `-RT` = Tape and reel packaging193- `-TUBE` = Tube packaging194- These don't affect LED equivalence195196<!-- Add new learnings above this line -->