void lostBall() { //Unfortunately we lost track of where the ball was. //We could try to relocate it, we're going back to seek mode. setSpeed(0); clearLCD(LCD); sendStringToLCD(LCD, "Lost the ball!"); _delay_ms(10); unsigned dirL = getDirL(); unsigned dirR = getDirR(); setDirL(-1); setDirR(-1); setSpeed(EVASIVE_SPEED); _delay_ms(EVASIVE_REV_DURATION); setSpeed(0); _delay_ms(250); setDir(1); setSpeed(0); setDirL(dirL); setDirR(dirR); //disableTBDetect(); botState.phoneLooking = false; setBotMode(MODE_PICKUP); }
void csetDirL( char *pszFrame ) { //setLCDCursor(LCD, LCD->config.lineLength); //sendStringToLCD(LCD, pszFrame); clearLCD(LCD); if(strcmp(pszFrame,"F") == 0) { setDirL(1); sendStringToLCD(LCD, "Set L to fwd"); } else if(strcmp(pszFrame,"R") == 0) { setDirL(-1); sendStringToLCD(LCD, "Set L to rev"); } else { sendStringToLCD(LCD, "Could not understand Ldir"); } }
void evasiveTurn( int dir ) { setSpeed(0); _delay_ms(10); unsigned dirL = getDirL(); unsigned dirR = getDirR(); setDirL((dir<0?-1:1)); setDirR((dir<0?1:-1)); setSpeed(EVASIVE_SPEED); _delay_ms(EVASIVE_TURN_DURATION); setSpeed(0); _delay_ms(150); setDir(-1); setSpeed(EVASIVE_SPEED); _delay_ms(EVASIVE_REV_DURATION); setSpeed(0); setDirL(dirL); setDirR(dirR); }
void Backward (void) { uprintf("Command Excepted\r"); setDirL(-1); setDirR(-1); SetPin('B',0,0); SetPin('B',1,1); SetPin('B',2,0); SetPin('B',3,1); setCHA10(ExtractNum(8)); setCHB10(ExtractNum(8)); }
void Forward (void) { uprintf("Command Excepted\r"); setDirL(1); setDirR(1); SetPin('B',0,1); SetPin('B',1,0); SetPin('B',2,1); SetPin('B',3,0); setCHA10(ExtractNum(7)); setCHB10(ExtractNum(7)); }
void Stop (void) { uprintf("Command Excepted\r"); setDirL(0); setDirR(0); SetPin('B',0,0); SetPin('B',1,0); SetPin('B',2,0); SetPin('B',3,0); setCHA10(0); setCHB10(0); }
void TurnR (void) { uprintf("Command Excepted\r"); setDirL(1); setDirR(0); SetPin('B',0,1); SetPin('B',1,0); SetPin('B',2,0); SetPin('B',3,0); setCHA10(ExtractNum(5)); setCHB10(ExtractNum(5)); }
void SpinL (void) { uprintf("Command Excepted\r"); setDirL(-1); setDirR(1); SetPin('B',0,0); SetPin('B',1,1); SetPin('B',2,1); SetPin('B',3,0); setCHA10(ExtractNum(5)); setCHB10(ExtractNum(5)); }
void setDir( int dir ) { setDirL(dir); setDirR(dir); }