Has anyone come up with anything better than this?

Has anyone come up with anything better than this? (I am not saying this is good in any way!)

Using a floating point number to assign colour to an LED — so if you set the position as something like 34.5 then 34 and 35 are half lit. Trying to get a “softer” transition when moving “pixels” on a strip of LEDs.

leds[int(floor(pos))%60] = CRGB::White;
leds[int(floor(pos))%60] %= cubicwave8((1.0-(pos-floor(pos))) * 24);
leds[int(ceil(pos))%60] = CRGB::White;
leds[int(ceil(pos))%60] %= cubicwave8((1.0-(ceil(pos)-pos)) * 24);

James

I use 16 bit pixel values. the high 8 bits are the pixel index, and the the low 8 bits are the fractional:

uint16_t pos = 0;

void setPartialPixel(uint16_t pos, CRGB & color) {
CRGB c1(color),c2(color);
uint8_t frac = pos & 0xFF;
uint8_t idx = pos >> 8;

c1.nscale8(255 - frac);
c2.nscale8(frac);

leds[idx] = c1;
leds[idx+1] = c2;
}

you can use other mechanisms to slide between the two values - but basically, frac is a value that indicates how much to remove of the passed in color for the first physical led and how much to keep of the passed in color for the second physical led.

Thanks Daniel — any idea why I keep getting “CRGB has not been declared” when using CRGB in functions?

void function(CRGB& colour) { } etc

For another example of anti-aliasing and fractional pixel illumination check out https://plus.google.com/app/basic/stream/z13jcntovnbripxcc23edpmxkov1zr23m (code, video demo, and discussion).

Brilliant — thanks Mark!

Make sure you’re #include<FastLED.h> in the files where you’ve got void function :slight_smile:

This would be a really cool thing to have in the wiki… I’ve wondered this myself!

Or even having the logic masked as a general FastLED utility

@Mark_Kriegsman and I have been doing a lot of talking about containers for accessing sets of leds that would provide for things like fractional access, rotation, 2d mapping, etc… Getting an interface together that’s high performant, easy to use/understand, and general enough for what the bulk of the people using it would be doing is … well, an art :slight_smile:

(My personal version of a library doing this stuff is currently on its 3rd complete rewrite)

Well I look forward to seeing it hit the light of day :slight_smile: you guys are awesome

@Daniel_Garcia pretty sure I have the define in there— or I’m going mad!— switched off my machine for the night so will double check later

@Daniel_Garcia It was because I was using CRGB::White solved by doing CRGB whiteVar = CRGB(255,255,255) and then using whiteVar with the function.