Jump to content

Using bitmasks in conditions


brockp

Recommended Posts

Posted

I would like to use bitmasks in my programs.  I the idea being that each 'bit' represents some state of a system.  I found that I can do bit math when setting a variable, but I want to use that in conditionals.

 

I want todo this so that a variable for an item such as 'garage lights'  can remember all the programs that should still be true. Example I want to have them on between some given time period, but I also want to control them when my opener is operated.  I don't want the opener timeout to shut off the outside if the other program is still in effect.  Each bit would represent this sort of, 'don't forget you should still be doing this other code path while this one finished'.

 

Any thoughts how todo this?  It doesn't look like you can do variable math in the conditional at all.

 

Thanks

Posted

Doesn't look like it.

 

What I would do is add "And Program 'Lights On in Evening' is False" to the conditions for my "Turn off Garage Lights When Door Closes" program;  this way the program doesn't run if the other program is currently true.

 

I also have programs that exist just to provide a 'true' or 'false' statement for whether another program has run recently, like this:

Garage Door Opened Recently

If
        From    Last Run Time for 'Garage Door Opened'
        To      Last Run Time for 'Garage Door Opened' +  1 hour  (same day)
 
Then
        Wait  1 hour and 1 second

This makes it easy to add And Program 'Garage Door Opened Recently' is False" as a condition for other programs, and I edit just one program to change the definition of "Recently" everywhere it is used (maybe I want to make it 30 minutes instead of an hour).

 

I'm not sure if the wait does anything.

Guest
This topic is now closed to further replies.

×
×
  • Create New...