-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question/Feature: Get current brightness #117
Comments
The "current" brightness level is a function of time, and calculated on-demand. JLed does not store the lastly written level, since this would require an additional byte in the internal state, which I want to keep as small as possible. I'll check if it's possible to return the current level with the |
@arnolddej, On the auto result = led.Update(); // returns now an `UpdateResult` object that can be cast to a `bool`
// signals that a new value was written out to the LED
if (result.WasChanged()) {
auto level = result.Value();
// do something with the level ....
} |
Thanks! I will try it asap. |
@jandelgado I've tested it. It seems like the value not always correspond to the actual brightness whenever you interrupt the running Fade() command with another Fade() command. Also whenever you interrupt the running cmd it sometimes will start at the minimum/maximum brightness level while its current value is only half for example. Is it even possible to call Fade() with another Fade() on the same object while the first cmd isn't finished yet. My current turn on/off code: void turn_on() {
if (ledstrip1.IsRunning()) {
ledstrip1.Stop();
}
ledstrip1.Fade(current_value_ledstrip1, 255, DURATION);
}
void turn_off() {
if (ledstrip1.IsRunning()) {
ledstrip1.Stop();
}
ledstrip1.Fade(current_value_ledstrip1, 0, DURATION);
} |
Hello. I have the same problem. I follow your correspondence silently. :) |
@arnolddej |
@aGGreSSiv please open another issue with your question and don't post code with secrets! |
I am currently on holiday for a week. Will share the code when I'm back. Basically, I assign a global |
No problem - me too :-) Anyway, I think i found the problem in the meantime ... |
@arnolddej I did a few changes, please test again. |
@jandelgado Unfortunately I already had to build in the lighting. Will test the circuit on a breadboard soon. |
Could you elaborate a bit more. I do understand the concept outlined above, yet I do not see how you implemented the update() return. I am working on a ESP32 so an array of uint's for the duty cycles * 16 channel is not really a memory constraint. Any example possible ? |
@SaKiEQ: I just started to (re-)implemented the feature. You can now pass an optional pointer to |
Currently building a cabinet light using this library. Absolutely fantastic.
But I have one question. Is it possible to get the current brightness level.
It's not a first world problem, but whenever the doors of the cabinet opens/closes too fast it start at the max or min brightness level while its for example only half way. I'm using only FadeOn and FadeOff functions btw. When I could get the current brightness this can be fixed using the Fade function.
It is basically a follow up question on #66
The text was updated successfully, but these errors were encountered: