int main( void ) { mInit(); mUSBInit(); mBusInit(); // Set up usb interface bQueue in_q; bQueue out_q; usbIface usb( &in_q, &out_q ); // picker_setup(); stepper_setup(); // set_timer5 (60000,30000,1200); setMode( STEP_8TH); setSpeedLimits( 65, 500 ); set_speed(m_speed_min); setAccelerationLimit(100); //5000 is good uint8_t cmd; uint16_t pos = 0; while(1) { usb.readBytes(); // Handle bytes if (!in_q.isempty() ) { mBlueTOGGLE; in_q.dequeue(&cmd); if ( cmd == 'l' ) { pos += 10; } else if ( cmd == 'h' ) { pos -= 10; } } update(pos); } return(0); }
int main (void) { mInit(); mBusInit(); mUSBInit(); mWhiteOFF; mRedOFF; mGreenON; for (uint8_t i = 0; i < COMMAND_SIZE + 1; i++) command_buffer[i] = '\0'; // initialize command buffer bool sd_initialized = false; reconnect: while (bDeviceState != CONFIGURED); sd_initialized = m_sd_init(); mWaitms (1000); welcome_screen(); if (!sd_initialized) printf ("ERROR: Could not initialize microSD card\r\n"); printf ("> "); for (;;) { if (bDeviceState != CONFIGURED) { goto reconnect; } const int rchar = getchar(); if (rchar < 0) continue; const char c = (char)rchar; if (c == '\n' || c == '\r') { // received 'enter' printf ("\r\n"); if (sd_initialized) { process_command(); if (fatal_error) sd_initialized = false; } else { if (m_sd_init()) { fatal_error = false; sd_initialized = true; process_command(); if (fatal_error) sd_initialized = false; } else { printf ("ERROR: Could not initialize microSD card: error code %d\r\n", m_sd_error_code); } } command_ptr = command_buffer; // reset the current command length to 0 printf ("> "); } else if (c == 8 || c == 127) { // received backspace (or delete) if (command_ptr > command_buffer) { command_ptr--; putchar (27); // escape printf ("[1D"); // move the cursor back 1 character putchar (27); printf ("[K"); // erase from the cursor position to the end of the line } } else if (c >= 32 && c < 127) { // received a printable character or escape if (command_ptr < command_buffer + COMMAND_SIZE) { *command_ptr = c; command_ptr++; putchar (c); } else { // out of command space: send bell putchar (7); } } } return 0; }
void mBusRestart(uint8_t i2cNum) { mBusInit(i2cNum); }
void mBusRestart(void) { mBusInit(); }