I found no sketches using uint8_t luma = leds[i].getLuma(); uint8_t avgLight = leds[i].getAverageLight();

I found no sketches using

uint8_t luma = leds[i].getLuma();
uint8_t avgLight = leds[i].getAverageLight();

to return brightness. What is the output of these methods? A value between 0 and 255? What is “average light”?

Is there a straightforward

uint8_t getBrightness = leds[i].getBrightness();

method to find out about the brightness of a leds array element, so one can use the returned value in if-checking?

Also, is there a straightforward

uint8_t setBrightness = leds[i].setBrightness();

method to set the brightness of individual LEDs?

Thanks

I answered this on one of your previous questions: https://plus.google.com/118424881866989540369/posts/V7nyraRPncX

Thanks, sorry, my old age is showing… so the two methods above are not good or not useful, which is why I can’t find simple examples of where they’re used, right?

Then, with your recent suggestion you linked to, the only reliable way to 1. get the brightness of a leds array element and then 2. check if it is above/below a certain value and 3. then set an appropriate state flag and darken/brighten/donothing is:

#define DARKEST_COLOUR CRGB(32,32,32)
#define BRIGHTEST_COLOUR CRGB(240,240,240)
#define DARKEN_LED CRGB(32,32,32)
#define BRIGHTEN_LED CRGB(16,16,16)

CHSV currentBrightness = rgb2hsv_approximate(leds[i]);

for ( byte i = 0; i < ledCount; i++) {
if ( ledState[i] == ledConstant) {
if ( random8() < 11) {
ledState[i] = ledBrightens;
}

} else if ( ledState[i] == ledBrightens ) {
  if ( <b>currentBrightness</b> >= BRIGHTEST_COLOUR ) {
    ledState[i] = ledDarkens;
  } else {
    leds[i] += BRIGHTEN_LED;
  }

} else {
  if ( <b>currentBrightness</b> <= DARKEST_COLOUR ) {
    leds[i] = DARKEST_COLOUR;
    ledState[i] = ledConstant;
  } else {
    leds[i] -= DARKEN_LED;
  }
}

}

Did I get this right now, you think?

@Jason_Coon Since I have only a bunch of Trinkets and no serial output - what does

CHSV currentBrightness = rgb2hsv_approximate(leds[i]);

output: a number between 0 - 255 or a h, s, v number triple? I mean, should one test with

if ( currentBrightness.val >= 64 ) {

for example?

Thanks!

http://bfy.tw/KPlQ :slight_smile:

I looked but found no simple animations where rgb2hsv_approximate is used… But I found this example https://github.com/FastLED/FastLED/issues/436

So, from that, I think one should 1. find and then 2. compare the brightness and 3. increase (or diminish) it this way:

CHSV currentHSV = rgb2hsv_approximate(leds[i]);

if ( currentHSV.val <= 32 ) {

currentHSV.val +=;

Would that be “allowed”?

@Andreas_Hopf In case you’re curious, here’s a sketch that converts random RGB colors to HSV so you can get an idea how close (or not) it gets.

https://github.com/marmilicious/FastLED_examples/blob/master/RGB_2_HSV_2_RGB_convert.ino
https://github.com/marmilicious/FastLED_examples/blob/master/RGB_2_HSV_2_RGB_convert.ino

Thanks; how close were your results? I have only a box of Pro Trinkets at my disposal in my retreat, so no serial output for me : (

I tried the method above to convert the only 3 brightness related lines of code (79, 89, 90) in @Mark_Kriegsman example https://gist.github.com/kriegsman/88954aae22b03a664081 that shimmers just perfect; but in my case, many LEDs just randomly get to zero or blink. I suspect the

CHSV currentHSV = rgb2hsv_approximate(leds[i]);

to get at the brightness, like he does with BASE_COLOR and PEAK_COLOR, which he hard-coded, does not work when your LED strip is constantly filled from a gradient palette.

Did you try setting BASE_COLOR to whatever color you’re grabbing from the gradient palette?
Change BASE_COLOR from a #define to something like this:
CRGB BASE_COLOR = CRGB(200,64,200);
so you can update it whenever you need to.

Also, you should really consider getting one of ANY other controller that can actually use the serial monitor. It would make things much easier to debug and be able to see what’s going on. Once you have your code all sorted out and don’t need the serial monitor anymore, then you can upload it to that board.

(I bought exactly one of those cute little boards and then never another because not being able to use the serial monitor is a pain!)

@marmil Thank you very much for your quick reply and bearing with by beginnerdom. I’m in the middle of nowhere, it’ll take weeks to get another µc…

In my sketch EVERY_N_MILLISECONDS (every 14062 milliseconds to be precise) the paletteIndex++ and then I use

CRGB colour = ColorFromPalette(activePalette, paletteIndex, maxBrightness, LINEARBLEND);
fill_solid(leds, ledCount, colour);

to fill all 144 LEDs with the interpolated colour from the gradient palette over one hour, later to be several hours.

Trouble is, if I now want to have all 144 LEDs shimmer as in https://gist.github.com/kriegsman/88954aae22b03a664081 then I need to set a status flag when PEAK_COLOR or BASE_COLOR is reached. But those are not known from the interpolated palette, or I am at a loss how to find them.

I thought I somehow need to make the if… else… checking independent from hard-coded PEAK and BASE colours, in order to apply the shimmer so nicely demonstrated in that sketch. I already tried to modify the many remotely similar examples I saw, but they are either rhythmic or not granular or they just flicker nervously, instead of shimmering very slowly.

I have been at this for over two weeks now, also taking that HSV detour, but not came no further…