/******************************************************************************* AlphaBot - Artistic mode implementation Artistic.c *******************************************************************************/ #include "AlphaBot.h" //------------------------------------------------------------------------------ #define SN SPEED_NORMAL #define DANCE_END 0,0,0,0 #define DANCE_MAX_MILEAGE 0xFF #define DANCE_MAX_DURATION 30 SECONDS _rom struct { char cSpeedLeft, cSpeedRight; uchar ucMileage; uint uiDuration; } DanceData [] = //------------------------------------------------------------------------------ { SN, SN, 10, 0, 0, 0, 0, 3 SECONDS, SN, 0, 6, 0, 0, 0, 0, 3 SECONDS, SN, SN, 10, 0, 0, 0, 0, 3 SECONDS, SN, 0, 6, 0, 0, 0, 0, 3 SECONDS, SN, SN, 10, 0, 0, 0, 0, 3 SECONDS, SN, 0, 6, 0, 0, 0, 0, 3 SECONDS, SN, SN, 10, 0, 0, 0, 0, 3 SECONDS, SN, 0, 6, 0, 0, 0, 0, 3 SECONDS, DANCE_END }; //------------------------------------------------------------------------------ void Dance(void) { static uint i = 0; _idat Side eSide; _idat ulong ulDriveUntilClicks, ulDoUntil; if( // DanceData[i].cSpeedLeft == 0 && // DANCE_END? // DanceData[i].cSpeedLeft == 0 && DanceData[i].ucMileage == 0 && DanceData[i].uiDuration == 0 ) { Show(S_DANCE_END); i = 0; //-- Start Over } eSide = ( DanceData[i].cSpeedLeft > DanceData[i].cSpeedRight ) ? LEFT : RIGHT; cSpeed[LEFT] = DanceData[i].cSpeedLeft; cSpeed[RIGHT] = DanceData[i].cSpeedRight; ulDriveUntilClicks = ulMileage[eSide] + (DanceData[i].ucMileage?DanceData[i].ucMileage:DANCE_MAX_MILEAGE); ulDoUntil = ulTickCount + (DanceData[i].uiDuration?DanceData[i].uiDuration:DANCE_MAX_DURATION); if( DanceData[i].cSpeedLeft == 0 && DanceData[i].cSpeedRight == 0 ) // Stops are hard MOTOR_L_SPEED_F = MOTOR_R_SPEED_F = MOTOR_L_SPEED_B = MOTOR_R_SPEED_B = 0; while( ulMileage[eSide] < ulDriveUntilClicks && ulTickCount < ulDoUntil ) { MaintainSpeed(); HeartBeat(); } i++; Show(S_DANCE_STEP); } // Dance //------------------------------------------------------------------------------