in reply to Saving Options

Seems that, to your controller, the most significant bit is expected to be aways set, the 4th bit sets the lights and the 5th the bell. So you can store the start state (or we could call it reset state) "128" in a variable, toggle the state of each bit with XOR bitwise against a mask and interpolate with a command to receiver "<f 1108 ...

To start only (not toggling) you could check the state with AND against the interest mask, if state is off the AND result is zero (or false):

my $state = 128; # start state, binary: 1000 0000 my $lightmask = 16; # 0001 0000 my $bellmask = 8; # 0000 1000 sub togglelight { $state = $state ^ $lightmask; $port->write("<f 1108 $state"); $port->lookclear(); } sub bellon { if (not ($state & $bellmask)) { $state = $state ^ $bellmask; $port->write("<f 1108 $state"); $port->lookclear(); } } sub belloff { if ($state & $bellmask) { $state = $state ^ $bellmask; $port->write("<f 1108 $state"); $port->lookclear(); } }

Hope this helps.

Cleyton

Replies are listed 'Best First'.
Re^2: Saving Options
by PilotinControl (Pilgrim) on Dec 20, 2015 at 22:15 UTC

    I will try this and report back....I can do the not state with the lights as well....since I can turn the lights on and off too the same as the bell and horn correct?

      Yes, Each call to togglelight inverses the state. Useful to have a flashing light.

      Calling bellon/belloff there are a conditional, so it only executes the block (and send command to receiver) if needed.

      These are two ways to send command, with toggle and with pre-determined state. If you want to determine the state of the lights use the bellon/belloff example, only changing bell by light. One will not interfere in other.

      We don't have the horn code. Take the horn number, subtract 128, the result will be the hornmask.