Giter Site home page Giter Site logo

Comments (8)

jandelgado avatar jandelgado commented on May 25, 2024

Yes, that's the expected behaviour:

  • Stop() just stops the current effect and turns the LED off
  • Reset() 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.

voidcreatrix avatar voidcreatrix commented on May 25, 2024

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.

jandelgado avatar jandelgado commented on May 25, 2024

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.

voidcreatrix avatar voidcreatrix commented on May 25, 2024

from jled.

voidcreatrix avatar voidcreatrix commented on May 25, 2024

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.

voidcreatrix avatar voidcreatrix commented on May 25, 2024

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.

jandelgado avatar jandelgado commented on May 25, 2024

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.

github-actions avatar github-actions commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.