void read_pedals() { int r = 0, i = 0; unsigned char query[8] = {0x01, 0x82, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char response[8]; for (i = 0 ; i < 3 ; i++) { query[3] = i + 1; usb_write(query); r = hid_read(dev, response, 8); if (r < 0) { fatal("error reading data (%ls)", hid_error(dev)); } printf("[switch %d]: ", i + 1); switch (response[1]) { case 0: printf("unconfigured"); break; case 1: case 0x81: print_key(response); break; case 2: print_mouse(response); break; case 3: print_key(response); printf(" "); print_mouse(response); break; case 4: print_string(response); break; default: fprintf(stderr, "Unknown response:\n"); debug_arr(response, 8); return; } printf("\n"); } }
/*! \brief This is an example demonstrating the accelerometer * functionalities using the accelerometer driver. */ int main(void) { volatile unsigned long i; // switch to oscillator 0 pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); // Initialize the debug USART module. init_dbg_rs232(FOSC0); acc_init(); // do a loop for (;;) { // slow down operations for ( i=0 ; i < 50000 ; i++); // display a header to user print_dbg("\x1B[2J\x1B[H\r\n\r\nAccelerometer Example\r\n\r\n"); // Get accelerometer acquisition and process data acc_update(); // test for fast or slow changes // depending on that, play with angles or moves if ( is_acc_slow() ) { print_mouse() ; print_angles() ; } else print_move() ; // MEUH // only text here , needs to be combined with PWM // meuh_stop is the "end" signal from PWM meuh_en = is_acc_meuh( meuh_stop ) ; } }