**/ra/0/mux**: Get/set multiplexing output mode

The multiplex driver lets the user configure a digital output pin to control many types of multiplexing including multiplexing ICs, shift registers, slave-select, scanned element arrays, charlieplexing and counters. However note that this implementation is generally not fast enough for flicker-free LED lighting control.

Once configured the present state of a multiplexing pin can be inferred from its value in the port report.

Configuring the multiplexing mode is done with an attribute-argument list. The maximum value for any integer input is 255 and is always unsigned. The attributes may appear in any order. The options are as follows:

- \+ (int): offset
- % (int): modulus
- <, =, & (int): sets operator (< less than, = equals, & bitwise-and) and the match
- @ (int) (int): active state and inactive state

The output pin will be driven to the active state when this formula is true:

((x + offset) % modulus) (op) match

Where x is a tick counter that increments on each iteration of the micro-OSC core acquistion loop, and op is the specified operator (<, = or &).

**Example 1**: 4-way slave select, active high, inactive low.

TX: [ /ra/0/mux ,sisisisii "+" 0 "%" 4 "=" 0 "@" 1 0 ]
TX: [ /ra/1/mux ,sisisisii "+" 1 "%" 4 "=" 0 "@" 1 0 ]
TX: [ /ra/2/mux ,sisisisii "+" 2 "%" 4 "=" 0 "@" 1 0 ]
TX: [ /ra/3/mux ,sisisisii "+" 3 "%" 4 "=" 0 "@" 1 0 ]

RX: [ /ra/*/mux (same as input, reported back) ]
...
RX: [ /ra ,TFFF ]
RX: [ /ra ,FTFF ]
RX: [ /ra ,FFTF ]
RX: [ /ra ,FFFT ]

**Example 2**: Software PWM / counter on a single pin.

Note that this sequence will not be fast enough to control LED lighting intensity without perceptual flicker.

TX: [ /ra/0/mux ,sisisisii "+" 0 "%" 8 "<" 3 "@" 1 0 ]
RX: [ /ra/0/mux ,sisisisTF "+" 0 "%" 8 "<" 3 "@" ]
...
RX: [ /ra ,T... ]
RX: [ /ra ,T... ]
RX: [ /ra ,T... ]
RX: [ /ra ,F... ]
RX: [ /ra ,F... ]
RX: [ /ra ,F... ]
RX: [ /ra ,F... ]
RX: [ /ra ,F... ]
RX: [ /ra ,T... ]
... etc

**Example 3**: Binary counter from 0-15. Typically this sequence is used to drive a multiplexing IC.

TX: [ /ra/0/mux ,sisisisii "+" 0 "%" 4 "&" 1 "@" 1 0 ]
TX: [ /ra/1/mux ,sisisisii "+" 0 "%" 4 "&" 2 "@" 1 0 ]
TX: [ /ra/2/mux ,sisisisii "+" 0 "%" 4 "&" 4 "@" 1 0 ]
TX: [ /ra/3/mux ,sisisisii "+" 0 "%" 4 "&" 8 "@" 1 0 ]

RX: [ /ra/*/mux (same as input, reported back) ]
...
RX: [ /ra ,FFFF ]
RX: [ /ra ,TFFF ]
RX: [ /ra ,FTFF ]
RX: [ /ra ,TTFF ]
RX: [ /ra ,FFTF ]
RX: [ /ra ,TFTF ]
RX: [ /ra ,TTTF ]
RX: [ /ra ,FFFT ]
RX: [ /ra ,TFFT ]
... etc

**Example 4**: 2-way scanning circuit, active high, inactive floats. This can be used to implement a low-cost multiplexing circuit without a multiplexing IC.

TX: [ /ra/0/mux ,sisisisii "+" 0 "%" 2 "=" 0 "@" 1 -1 ]
TX: [ /ra/1/mux ,sisisisii "+" 1 "%" 2 "=" 0 "@" 1 -1 ]

**Example 5**: Driving an 8-bit shift register. Pin /ra/0 shifts out the bits (here, the bits of the number "5"), and pin /ra/1 commits the data with the latch pin on the 9th iteration.

TX: [ /ra/0/mux ,sisisisii "+" 0 "%" 9 "&" 5 "@" 1 0 ]
TX: [ /ra/1/mux ,sisisisii "+" 0 "%" 9 "=" 8 "@" 1 0 ]

RX: [ /ra ,TF... ]
RX: [ /ra ,FF... ]
RX: [ /ra ,TF... ]
RX: [ /ra ,FF... ]
RX: [ /ra ,FF... ]
RX: [ /ra ,FF... ]
RX: [ /ra ,FF... ]
RX: [ /ra ,FF... ]
RX: [ /ra ,FT... ]
...etc

**Example 6**: Turning off the multiplex driver: send the single argument, 0.

TX: [ /ra/0/mux ,i 0 ]
TX: [ /ra/1/mux ,i 0 ]
TX: [ /ra/2/mux ,i 0 ]
TX: [ /ra/3/mux ,i 0 ]