Internal flash bit

Hi,

I am using perspective and I need to create an internal flash bit to be ON/OFF every 1s. The goal is to bind it with components so they can start flashing. Is there a quick way to do this without scripting?
If not could someone please give guidance to create one?

Many thanks
Alex

How about a boolean expression tag where the expression is now() % 2 and the rate is 1000ms?

edit: nevermind, this isn’t great because it can miss toggles pretty easily. getSecond(now()) % 2 might work a little better, but still not bullet proof.

I make an expression tag and use {[System]Gateway/UptimeSeconds} % 2 and leave it event-driven. I use for the same thing. Like a clock bit in a plc for flashing. I haven’t ever noticed it missing. But, if it misses I don’t care.

It’s a tiny bit convoluted, but you can just use a style class for this, too:


Set the duration appropriately, then add a stop at 49% with the same color as your 0% state.
Then add a stop at 50% (and 100%) with the alternate color.

The animation will take 1s to transition through all your steps - so half the time, it will be trying to transition from step 0 to step 49 - but since they’re the same, nothing will happen. Then, after 50% of 1s has elapsed, it switches to the 50% style (and the new background color). Then it tries to “transition” between that style and the 100% style - so as long as they’re the same, there will only be a single “transition” frame between animation loops.

2 Likes

It seemed to work. Thank you very much indeed.

Thank you very much inded for that. Where shall I look In order to make the rate faster or slower? I tried altering the %2 but it only seemed to make it slower or not flash at all.

So with this expression, if the value is a Modulus of two the bit goes high. I would look towards using @PGriffith style. If you wanted to make it more variable. I sure am.

1 Like

So if the bit was to go high every 15m would this be
{[System]Gateway/UptimeSeconds} % 900000 ?

Would this method be synchronised across multiple styles classes?

I believe that’s entirely up to the browser - so, maybe (all style classes are loaded as one stylesheet, so there’s a decent chance, if that’s how they start all keyframe loops). But zero guarantees.