test/src/pi_lw_gpio_test.c
static void read_gpio(void) {
    // Store values and modes:
    int read_gpio_values[40];
    int read_gpio_modes[40];

    int i;

    // Read all pins and save to revert later:
    for (i = 0; i < 30; i++) {
        read_gpio_values[i] = gpio_read_level(i);
        read_gpio_modes[i] = gpio_read_mode(i);
    }

    // Display the results in a table:
    printf("+--------+---+----------+---+--------+\n"
           "|  Mode  | V | GPIO Pin | V |  Mode  |\n"
           "+--------+---+----++----+---+--------+\n");

    for (i = 0; i < 29; i+=2) {
        printf("|  %s   | %d | %2d || %2d | %d |  %s   |\n",
               (read_gpio_modes[i] == GPIO_INPUT) ? "INP" : "OUT",
               read_gpio_values[i], i, i+1, read_gpio_values[i+1],
               (read_gpio_modes[i+1] == GPIO_INPUT) ? "INP" : "OUT");
    }

    printf("+--------+---+----------+---+--------+\n"
           "|  Mode  | V | GPIO Pin | V |  Mode  |\n"
           "+--------+---+----++----+---+--------+\n");
}
// Read GPIO modes and levels and print in a table
Read GPIO modes and levels and print in a table
Read GPIO modes and levels and print in a table
static void read_gpio(void) {
    int read_gpio_values[40];
    int read_gpio_modes[40];
    int i;
    for (i = 0; i < 30; i++) {
        read_gpio_values[i] = gpio_read_level(i);
        read_gpio_modes[i] = gpio_read_mode(i);
    }
    printf("+--------+---+----------+---+--------+\n"
           "|  Mode  | V | GPIO Pin | V |  Mode  |\n"
           "+--------+---+----++----+---+--------+\n");
    for (i = 0; i < 29; i+=2) {
        printf("|  %s   | %d | %2d || %2d | %d |  %s   |\n",
               (read_gpio_modes[i] == GPIO_INPUT) ? "INP" : "OUT",
               read_gpio_values[i], i, i+1, read_gpio_values[i+1],
               (read_gpio_modes[i+1] == GPIO_INPUT) ? "INP" : "OUT");
    }
    printf("+--------+---+----------+---+--------+\n"
           "|  Mode  | V | GPIO Pin | V |  Mode  |\n"
           "+--------+---+----++----+---+--------+\n");
}
static void read_gpio ( void ) { int read_gpio_values [ 40 ] ; int read_gpio_modes [ 40 ] ; int i ; for ( i = 0 ; i < 30 ; i ++ ) { read_gpio_values [ i ] = gpio_read_level ( i ) ; read_gpio_modes [ i ] = gpio_read_mode ( i ) ; } printf ( " \n " " \n " " \n " ) ; for ( i = 0 ; i < 29 ; i += 2 ) { printf ( " \n " , ( read_gpio_modes [ i ] == GPIO_INPUT ) ? " " : " " , read_gpio_values [ i ] , i , i + 1 , read_gpio_values [ i + 1 ] , ( read_gpio_modes [ i + 1 ] == GPIO_INPUT ) ? " " : " " ) ; } printf ( " \n " " \n " " \n " ) ; }
Read GPIO modes and levels and print in a table
Read GPIO modes and levels and print in a table
// Store values and modes: // Read all pins and save to revert later: // Display the results in a table: