t2:get_port

get_port


get_port — Get origin port of I/O value

Description


uint8 get_port(uint8 io);

Retrieve the port that originated the I/O value indexed by io.

Parameters


  • io: Index of an I/O value.

Return Value


The port index, accordingly table 1.

Table 1
Index Port Designator Port Label
1 PORT_USB_A Input-A
2 PORT_USB_B Input-B
0 PORT_USB_C Output
3 PORT_USB_D Prog
4 PORT_BT_A
5 PORT_BT_B
6 PORT_BT_C

Examples


Example #1 get_port() example

main {
    // If BUTTON_16 is active ...
    if(get_actual(BUTTON_16)) {
        // and if the value is comming from USB-B ...
        if(get_port(BUTTON_16) == PORT_USB_B) {
            // don't forward the input to the console.
            set_val(BUTTON_16, 0.0);
        }
    } 
}

See Also

t2/get_port.txt · Last modified: 2020/04/21 06:01 by J2Kbr