FastLed - how to get inbetween values? Map function

I am trying to map 15 input pixels to 9 output pixels (and also to 7 and 8 output pixels. to be precise it is 7,8,9,8,7 placed vertical next to each other)

I can use: map(i,0,8,0,14)

the problem is that this results in discrete values. So there are situations where this looks kind of wierd because the way map rounds to discrete values. So I was thinking about calculating the color value based on inbetween values.....

So on the 9 pixel strip, pixel #8 should have the value of 8/9 * 15 = 13,3. So the value of pixel 13,3. The color 1/3th between pixel #13 and #14.

Any advice?

1 Like

You need to do the math - after deciding what number of splits are needed for your application.

e.g. 1/3, 1/4, 1/2 etc. then you’ll need to determine if adjacent LEDs should both be full on, or both run at reduced brightness (equally, or proportionally)

Then you can create your own ‘split’ function to drive the pixels.

Not simple, but certainly doable.

1 Like

The problem I am facing is more how to calculate the color.... So I have Pixel A with R,G,B values and a brightness and I have Pixel B with R,G,B values and a brightness. So how do I calculate the R.G,B value and brightness of a virtual pixel at, lets say, 30% inbetween?

Is it like deltaR * 30%, deltaG * 30%, deltaB * 30%? is it linear or should I convert RGB to a single value first?

1 Like

The human eye certainly isn't.

1 Like

Perhaps the Pixel Blending Functions from colorutils.h will be helpful.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.