I'm trying to land on a value of 0 instead of 7F after engaging the toggle ON state by a remote message, after the rules receive the remote toggle ON messages in L0 then the next toggle state should always be OFF aka 0 after engaging the toggle either by J0 or I0 , L0 should only produce an ON state aka 7F, can anyone spot why I keep getting 7F instead of 0 ?
If load Ass K0 = 7F 7F #toggle ON/OFF switch Ass J0 = 90 00 7F #toggle A main control Ass I0 = 90 02 7F #toggle B main control Ass L0 = 0C 0E #remote msg for toggle A & B (only) ON states End
If M0 == J0 If M1 == J1 #1st press A toggle ON Snd B0 00 K0 Calc K0 = K0 ^ 7F #2nd press A toggle OFF Else If M1 == I1 Ass K0 = 7F #retain ON state on B toggle Else IF M1 == L0 #remote ON message for toggle A Snd B0 00 7F Ass J2 = 0 Else IF M0 == J0 J1 J2 Ass J2 = 0 #local OFF message for toggle A (not working as intended, sending 7F here instead of a 0 End End End End End
#toggle B same logic as above
if M0 == 90 If M1 == 02 Snd B0 01 K1 Calc K1 = K1 ^ 7F Else If M1 == 00 Ass K1 = 7F Else IF M1 == 0E Snd B0 01 7F Ass I2 = 0 Else IF M0 == I0 I1 I2 Ass I2 = 0 #same as above, outgoing msg should be 0 instead of 7F End End End End End Block
Post by redheronmusic on Sept 5, 2023 13:08:09 GMT
Not following your logic completely. But a few observations
1 - "Ass J2 = 0 #local OFF message for toggle A (not working as intended, sending 7F here instead of a 0"
But there is no send statement here, you are just assigning a value to J2, which doesn't change the initial message, or send a message.
2 - You explicitly define the main messages, but only define the middle byte of the remote message. I presume your remote messages are 90 0C 7F and 90 0F 7F. Keeping logic consistent and explicitly defining your stimulus messages can help identify logic issues, especially later when you are reusing the code.
3 - You are switching on a NOTE ON value of zero. Many applications will change a NOTE ON zero value to NOTE OFF. (I had to use 8X = 9X to be able to test this code.)
4 - It appears that your first three comparisons have used up all the options, M1 = 0, 2, or C, so there is no way to get to the final else statement.
Sometimes drawing a simple diagram of the desired logic can help straighten out the code.