Comments (8)
Yes, that's the expected behaviour:
Stop()
just stops the current effect and turns the LED offReset()
resets the state of the current effects so it will start over. The effect configuration (effect type, delay before/after) are not affected
In your case you could instead of of reconfiguring the existing effect, which will not change e.g. the delay values, you could also do a re-assignment like led = JLed(LED_PIN).Blink(500,500).Forever();
from jled.
Ah. My question is not so much about the Stop method, as about how the DelayAfter property from the FadeOn effect persisted into the Blink effect, unless I explicitly set the Blink to have a DelayAfter of 0.
So the DelayAfter setting is a property of the LED object, not a property of the FadeOn effect?
I was thinking of FadeOn as one "effect", and Blink as a different "effect", so it didn't make sense that the DelayAfter from one of them persisted to the other. But it sounds like you're referring to an "effect" as the collection of all properties of the led object. Is that right?
That makes it seem like transitioning between effects is best done with a reassignment, as you say -- otherwise, every property has to be explicitly reassigned.
Thanks for your help, and for this very helpful library!
from jled.
Yes, DelayAfter
, DelayBefore
, LowActive
, MaxBrightness
and Repeat
are properties of the LED object. The "effect" with (Blink
, Breathe
, FadeOn
, FadeOff
, Candle
) is also a property. These properties can be set individually. When an effect is set, it will restart at the beginning, but delays etc. are not affected.
from jled.
from jled.
As suggested, I used re-assignmnents to transition between effects.
I was able to compile
led = JLed(RedPin).Blink(500,500).Forever();
But when I tried
led = JLed(RedPin).Blink(500,500).Forever().Update()
, I got the following compile error:
no match for 'operator=' (operand types are 'jled::JLed' and 'bool')
Are there any other restrictions on reassignments?
from jled.
One more observation that might be of use. I'm using a common-anode tri-color LED, so needed the LowActive feature (thanks for including that!). Every time I use the reassignment as noted above, if the LED was previously off, I see a barely-visible flash of light. Is it possible that the constructor is causing the pin to default to low briefly (thus turning on the LED), before the "Low Active" setting is processed?
When I modified my code to change the properties rather than reassigning, the brief flash went away.
Thanks again!
from jled.
As suggested, I used re-assignmnents to transition between effects.
I was able to compile
led = JLed(RedPin).Blink(500,500).Forever();
But when I tried
led = JLed(RedPin).Blink(500,500).Forever().Update()
, I got the following compile error:no match for 'operator=' (operand types are 'jled::JLed' and 'bool')
Are there any other restrictions on reassignments?
Yes, that because Forever()
returns a JLed Object whereas Update()
returns a boolean. Since C++ is a typed language, you get a compile time error (note that this is a different thing then a "exception").
Have a look at the documentation for Update:
Update
Call Update() periodically to update the state of the LED. Update returns true if the effect is active, and false when it finished.
from jled.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days
from jled.
Related Issues (20)
- Blink twice HOT 2
- Evolution for non PWM pins HOT 2
- jled to control RGB? HOT 7
- times in millis should be 32bit values HOT 3
- Make fade-resolution choosable HOT 5
- Why is 'MinBrightness' not in red font HOT 2
- CTRL_ANODE HOT 4
- how can i use to pca9685 HOT 5
- 255 value change 4095 how to HOT 2
- Update MaxBrightness Dynamically? HOT 5
- Pulse LED? HOT 6
- User provided functions never get to max `t` HOT 3
- FadeOn and stay on forever HOT 7
- Change effect works in setup() only HOT 4
- can the candle or other examples be ran inside a function
- Candle to turn off after effect. HOT 12
- Multiple HALs HOT 7
- Change PWM base frequency HOT 4
- Question: How to pass to funtion HOT 2
- Minimum brightness HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jled.