int main(int argc, char* argv[]) { initscr(); // initialize ncurses display nodelay(stdscr, 1); // don't wait for key presses noecho(); // don't echo key presses gz_spi_set_width(3); // Pass blocks of 3 bytes on SPI erase(); printw("Toggling all outputs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); int key = 0; while(1) { exercise_outputs(0xffffff, 0x000000); key = getch(); if (key != -1) { break; } } if (key == 'n') { erase(); printw("Toggling alternate outputs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); while(1) { exercise_outputs(0xaaaaaa, 0x555555); key = getch(); if (key != -1) { break; } } } if (key == 'n') { erase(); printw("Walking outputs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); uint32_t current = 0xfffffe; while(1) { exercise_outputs(current, (current << 1) | 0x01); current = (current << 2) | 0x03; if ((current & 0xffffff) == 0xffffff) { current = 0xfffffe; } key = getch(); if (key != -1) { break; } } } if (key == 'n') { erase(); curs_set(0); // Hide the cursor // Set RPI pin P1-07 to be an input INP_GPIO(PIN); // with a pullup -- see BCM2835 ARM Peripherals page 101 GPIO_PULL = 2; usleep(1); GPIO_PULLCLK0 = 1 << PIN; usleep(1); GPIO_PULL = 0; GPIO_PULLCLK0 = 0; printw("Reading input.\n"); printw("Press any key to stop.\n"); while(1) { display_input(); key = getch(); if (key != -1) { break; } } move(getcury(stdscr) + 1 ,0); curs_set(1); refresh(); } gz_spi_close(); // close SPI channel erase(); reset_shell_mode(); // turn off ncurses return 0; }
int main(int argc, char* argv[]) { initscr(); // initialize ncurses display nodelay(stdscr, 1); // don't wait for key presses noecho(); // don't echo key presses gz_spi_set_width(2); // Pass blocks of 2 bytes on SPI gz_clock_ena(GZ_CLK_5MHz, 0x02); // 2.5 MHz erase(); outputs_off(); printw("Modulating PWMs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); int key = 0; while(1) { exercise_pwms(); key = getch(); if (key != -1) { break; } } if (key == 'n') { printw("Toggling all outputs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); while(1) { exercise_outputs(0xff, 0x00); key = getch(); if (key != -1) { break; } } } if (key == 'n') { erase(); printw("Toggling alternate outputs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); while(1) { exercise_outputs(0xaa, 0x55); key = getch(); if (key != -1) { break; } } } if (key == 'n') { erase(); printw("Walking outputs.\n"); printw("Press 'n' for next test, any other key to stop.\n"); unsigned char current = 0xfe; while(1) { exercise_outputs(current, (current << 1) | 0x01); current = (current << 2) | 0x03; if (current == 0xff) { current = 0xfe; } key = getch(); if (key != -1) { break; } } } if (key == 'n') { erase(); curs_set(0); // Hide the cursor printw("Reading inputs.\n"); printw("Press any key to stop.\n"); while(1) { display_inputs(); key = getch(); if (key != -1) { break; } } move(getcury(stdscr) + 1 ,0); curs_set(1); refresh(); } gz_spi_close(); // close SPI channel erase(); reset_shell_mode(); // turn off ncurses return 0; }