# Problem with custom mapping

**URL:** <https://wled.discourse.group/t/problem-with-custom-mapping/1566>\
**Category:** Questions\
**Created:** [December 5, 2020, 3:09pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566 "2020-12-05T15:09:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 5, 2020, 3:09pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/1 "2020-12-05T15:09:22Z")

</div>

In another post @tonyno helped me to found the custom mapping option which is what i need for my project.

So i made the changes and i recompile the project and load it in esp32

the custom mapping is like the following :

> //enable custom per-LED mapping. This can allow for better effects on matrices or special displays  
> #define WLED\_CUSTOM\_LED\_MAPPING
> 
> #ifdef WLED\_CUSTOM\_LED\_MAPPING  
> //for my project i need the following mapping is what i need
> 
> const uint16\_t customMappingTable = {0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 12, 14, 15, 16, 17, 21, 22, 24, 28, 32, 33, 34, 35,  
> 36, 38, 42, 48, 52, 54, 56, 59, 61, 62, 63, 64, 65, 67, 70, 71, 73, 74, 75, 78, 79, 80, 87, 90, 95, 97, 98, 99, 100, 106,  
> 108, 116, 118, 121, 123, 125, 126, 129, 131, 133, 134, 136, 139, 140, 142, 148, 152, 153, 158, 164, 165, 166, 167, 170,  
> 172, 174, 176, 182, 183, 187, 190, 196, 199, 204, 206, 207, 208, 209, 213, 214, 215, 216, 217, 218, 220, 224, 226, 227,  
> 230, 231, 232, 8, 10, 13, 18, 19, 20, 23, 25, 26, 27, 29, 30, 31, 37, 39, 40, 41, 43, 44, 45, 46, 47, 49, 50, 51, 53, 55,  
> 57, 58, 60, 66, 68, 69, 72, 76, 77, 81, 82, 83, 84, 85, 86, 88, 89, 91, 92, 93, 94, 96, 101, 102, 103, 104, 105, 107, 109,  
> 110, 111, 112, 113, 114, 115, 117, 119, 120, 122, 124, 127, 128, 130, 132, 135, 137, 138, 141, 143, 144, 145, 146, 147, 149,  
> 150, 151, 154, 155, 156, 157, 159, 160, 161, 162, 163, 168, 169, 171, 173, 175, 177, 178, 179, 180, 181, 184, 185, 186, 188, 189,  
> 191, 192, 193, 194, 195, 197, 198, 200, 201, 202, 203, 205, 210, 211, 212, 219, 221, 222, 223, 225, 228, 229};  
> `  
> But when i test the project in a spare led strip before use it in my project, something is not working as it should…probably something i am missing here.

My project is a tree, the custom mapping start with led’s which are on the wooden parts of the tree and after continues with the led’s which are on the leaves of the tree.

So now i must create 2 segments , 1 will be from led 0 to led 232 (for custom mapping) and the second will be from led 8 to led 229 (for custom mapping) wood and leaves.

But when i create the first segment 0 - 232 lights up all the 232 Led’s in strip, except the 3rd before the end.  
when i create the second segment 8 - 229 lights up from led 8 to 229 except led’s 226,225,222,220 which is totally wrong…

i can’t understand why is this happen , can someone have any idea?

Thank you

code screenshot : [Screenshot by Lightshot](http://prntscr.com/vwe3w2)

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 5, 2020, 3:51pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/2 "2020-12-05T15:51:30Z")

</div>

Segments cannot overlap.

---

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 5, 2020, 4:03pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/3 "2020-12-05T16:03:49Z")

</div>

So what can i do , to have these 2 groups separated?

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 5, 2020, 4:08pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/4 "2020-12-05T16:08:28Z")

</div>

My guess is to pretend those are in normal order and create two segments, one for each part like 0-x for the wood and x-232 for the leaves, if that makes sense.

---

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 5, 2020, 6:43pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/5 "2020-12-05T18:43:43Z")

</div>

This is what i did, not work because as you said “Segments cannot overlap” , what is the point if you cannot overlap segments to create custom mapping? Did you see the code? Do i need to edit anything else?

Thanks

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 5, 2020, 9:00pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/6 "2020-12-05T21:00:12Z")

</div>

I’d guess that if you do 0-x and x-232 they should not overlap.

---

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 5, 2020, 11:12pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/7 "2020-12-05T23:12:14Z")

</div>

> [@Chrisad](#):
>
> 0 - 232

That’s what i thought , but in fact does not work.

> when i create the first segment 0 - 232 lights up all the 232 Led’s in strip, except the 3rd before the end.  
> when i create the second segment 8 - 229 lights up from led 8 to 229 except led’s 226,225,222,220

0-232 in my custom mapping is not 232 led , it is 104 led. and  
8-229 are the rest 128 led for total : 232 that i use,

\*\*The problem is simple : \*\*

**at custom mapping you set : 0,5,14,27,45,128,32,8,200,2 …**

\*\*After if you set in segment from 14 to 128 you expect to light up 4 led’s (14,27,45,128) \*\*  
**instead that it will light up 114 led’s (the hole range, ignoring the custom mapping)**

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 5, 2020, 11:25pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/8 "2020-12-05T23:25:07Z")

</div>

No, what I meant was 0-104 (wood?) and 104-232 (leaves).

---

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 5, 2020, 11:56pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/9 "2020-12-05T23:56:34Z")

</div>

Sorry i do not understand what you mean.

Let talk with the example which exist in FX\_fcp. (Which i just tested to see what will happen)

```
const uint16_t customMappingTable[] = {
  0, 1, 2, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14,
  19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 29, 28, 27, 26, 25};

```

With this custom mapping loaded.

I create a segment from 15 to 21 and i was expected 3 led’s to light up ( led’s 15,20 and 21)

but instead lights up led’s 15,16,17,18,19, and 20

code : [http://prntscr.com/vwlrpr](http://prntscr.com/vwlrpr)  
segment : [http://prntscr.com/vwls1x](http://prntscr.com/vwls1x)  
result : [http://prntscr.com/vwlvel](http://prntscr.com/vwlvel)

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 6, 2020, 1:08am UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/10 "2020-12-06T01:08:56Z")

</div>

My expectation is, if you use that custom mapping…

```auto
const uint16_t customMappingTable[] = {
  0, 1, 2, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14,
  19, 18, 17, 16, 15, 20, 21, 22, 23, 24, 29, 28, 27, 26, 25};

```

Then a _segment_ defined as 0-9 would translate to LEDs 0, 1, 2, 3, 4, 9, 8, 7, 6, 5.

Make sense now?

---

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 6, 2020, 2:56am UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/11 "2020-12-06T02:56:16Z")

</div>

YES works great now! A tiny misunderstanding that cost me a day. But at least i learn a lot from this.

Something last , until your last post i check the JSON API , it was the easiest way to setup individual colors for each led.

**Using the `i` property of the segment object, you can set the LED colors in the segment using the JSON API**

`{"seg":{"i":[[255,0,0], [0,255,0], [0,0,255]]}}`

and worked great

But i could not manage to enable any effect to segment when **`i` property** used, is this something that supported from JSON API or not?

thanks again for your help.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [December 6, 2020, 2:29pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/12 "2020-12-06T14:29:39Z")

</div>

Not sure if you need more, but have you tried an `"fx":n` in there where n is the effect number?

---

<div class="post-metadata">

**Author:** ![Chrisad](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Chrisad](https://wled.discourse.group/u/Chrisad)\
**Post date:** [December 6, 2020, 2:52pm UTC](https://wled.discourse.group/t/problem-with-custom-mapping/1566/13 "2020-12-06T14:52:16Z")

</div>

Indeed i do not need it , remapping worked great.

Just curious, {“bri”:120} works for brightness , {“fx”:2} does not. (or any other effect number.)
