Firmware-72 Command-008

From I-CubeX Wiki
Jump to: navigation, search

FUNCTION (8, 08h)

The FUNCTION command enables a sensor-specific processing algorithm. Functions are available for both analog sensors as well as digital (I2C) sensors, where the latter also operate in stand-alone mode. The full list of functions can be found in the section on sensor functions.

When enabling host mode function numbers are reset (ie. set to 0) for each input and the other function settings are retrieved from non-volatile memory. When enabling stand-alone mode all function settings are retrieved from non-volatile memory. The command can be used in both host and stand-alone modes of operation. In both modes the function number is stored in volatile memory and in host mode the other function settings are stored in non-volatile memory while in stand-alone mode all function settings are stored in non-volatile memory. Upon completion of the FUNCTION command the USB-microDig sends out the same message.

In host mode raw sensor data will be output immediately in I2C DATA messages. In stand-alone mode a suitable configuration has to be set using the EDIT CONFIG command before any MIDI messages will be output. The sensor parameter’s raw values as output in an I2C DATA message are offset and scaled so as to fit in the channel voice MIDI value range of either 0..127 (eg. control-change message) or 0..16383 (pitch-bend message).

The [BODY] of the FUNCTION command consists of four 7-bit bytes with the following format:

Analog sensors:

00000yyy: yyy = [0..7]; sensor input number, where the first input number = 0 and the last (8th) input number = 7
0ddddddd: ddddddd = [0-127]; function parameter 2 (FP2)
0nnnnnnn: nnnnnnn = [1-63]; function number
0ppppppp: ppppppp = [0-127]; function method or parameter 1 (FP1)

Digital (I2C) sensors:

00000yyy: yyy = [0..6]; I2C port number, where the first port number = 0 and the last (7th) port number = 6
0ddddddd: ddddddd = [0-126]; I2C device address
0nnnnnnn: nnnnnnn = [64-127]; function number
0ppppppp: ppppppp = [0-127]; function method or parameter (FP)

Examples:

In order to set I2C port 2 (input 3 and 4) to use the Orient3D function, method 1 (heading/pitch/roll) for an Orient3D sensor with address 96, the following message is sent:

240, 125, 0 {DEV}, 8 {FUNCTION}, 2 {port number}, 96 {address of device}, 125 {Orient3D}, 1 {heading/pitch/roll}, 247 (F0h, 7Dh, 00h, 08h, 60h, 7Dh, 01h, F7h)

In order to turn the function off, the following message is sent:

240, 125, 0 {DEV}, 8 {FUNCTION}, 0 {address}, 0 {function}, 0 {parameter}, 247 (F0h, 7Dh, 00h, 08h, 00h, 00h, 00h, F7h)