Toggling

magicizaproblem

2018-05-24 11:53:35

Im trying to find out if its possible to toggle msgs without using rules? If so how?

Steve-Bome Forum Moderator

2018-05-24 16:34:05

Hi,

Yes toggling is easy using the XOR function described in my earlier post on Bitwise

Turns out that any time you XOR a value with 1 it will reverse the current state of the input variable

1 XOR 1 = 0

0 XOR 1 = 1

In MT Pro it would look like

ga=ga^1

You can do this with multiple bits, however each bit is XOR’d so

if ga was 2  or 10 binary

ga=ga^1

would result in the value of

1^0 – 2’s column = 1

0^1 – 1’s column = 1

11 binary or 3

10

01

==

11

 

If you don’t like using XOR function you can also do this

pp=ga

if pp==0 then ga=1

if pp==1 then ga=0

I happen to remember and like the shorter version  but remember, you have 32 bits so if you want to only manipulate 1 bit, you need to extract the bit in question, manipulate it then re-insert it into the original value.

Steve

 

 

 

magicizaproblem

2018-05-26 17:10:37

As a follow up question for clarity im trying to verify that there is no way to do toggling outside of using rules is this correct?

Steve-Bome Forum Moderator

2018-05-26 17:15:27

comment

No, Bome MT requires a variable and rules to do toggling. With that said, some controllers handle their own toggling and put out a different value whether on or off. For instance, I can program some of my controllers to put out 127 when on and then push again and output 0.
If this is the case then MT Pro probably doesn’t need to keep a variable to determine the button’s state, it can just use the incoming value. You could have one translator to monitory for 127 value and another for 0 value and each translator perform their own unique output.

Steve