task main() { // Stop both motors motor[motorD] = 0; motor[motorE] = 0; while (true) { // Run motorD (i.e. motor 1 on the Hitechnic controller) forward and then reverse PlaySoundFile("01.rso"); // Plays file containing audio for '1' motor[motorD] = 50; wait1Msec(2000); motor[motorD] = -50; wait1Msec(2000); motor[motorD] = 0; // Run motorE (i.e. motor 2 on the Hitechnic controller) forward and then reverse PlaySoundFile("02.rso"); // Plays file containing audio for '2' motor[motorE] = 50; wait1Msec(2000); motor[motorE] = -50; wait1Msec(2000); motor[motorE] = 0; } }
task main() { clearLCDLine(0); clearLCDLine(1); displayLCDPos(0, 0); displayNextLCDString("Titties"); nVolume = 4; #ifndef NOSOUND PlaySoundFile(SONGNAME); #endif resetVars(); // reset all variables resetSensors(); // reset all sensors #ifndef NOAUTON AutoSelector();//run the RedFront autonomous Autonomous(); #endif AutoRedPost(); while (true) { #ifndef NOSOUND if (bSoundQueueAvailable) { PlaySoundFile(SONGNAME); } #endif RC(); // recieve inputs calcMotorValues(); //writeStream(); //beltPower = 127; RunRobot(); } }
//================================== // main program //================================== task main() { disableDiagnosticsDisplay(); //nMotorEncoder(lift1) = 0; //nMotorEncoder(shoulder) = 0; abs_cscreen(" "," "," "); nxtDisplayBigTextLine(7, " "); abs_smoke_test_view(test_num,test_value1,test_value2); while(true) { while(nNxtButtonPressed!=kEnterButton) { if(nNxtButtonPressed==kLeftButton&&test_num>1) { test_num--; abs_smoke_test_view(test_num,test_value1,test_value2); PlaySoundFile("! Click.rso"); while(nNxtButtonPressed==kLeftButton){} } if(nNxtButtonPressed==kRightButton&&test_num<total_tests_num) { test_num++; abs_smoke_test_view(test_num,test_value1,test_value2); PlaySoundFile("! Click.rso"); while(nNxtButtonPressed==kRightButton){} } } PlaySoundFile("! Click.rso"); while(nNxtButtonPressed==kEnterButton){} abs_smoke_execute(test_num); abs_smoke_test_view(test_num,test_value1,test_value2); } }
// Pass in the number of the song you want to loop, method must be checked every frame HRESULT SoundManager::LoopSound(int songNum) { HRESULT hr; // find the state of the source voice that is playing our song if(pSourceVoice != NULL) { XAUDIO2_VOICE_STATE state; pSourceVoice[songNum]->GetState( &state ); // if the song isn't looping, play it if(!isSongLooping) { if( FAILED(hr = PlaySoundFile(songNum))) return hr; // buffer the same song to be played after this one is done loopingSourceVoice = pSourceVoice[songNum]; loopingSourceVoice->SubmitSourceBuffer(&buffer[songNum]); isSongLooping = true; } else if(state.BuffersQueued == NULL) // a playthrough has finished, we are no longer looping { isSongLooping = false; pSourceVoice[songNum]->Stop(0, XAUDIO2_COMMIT_NOW); } } return 0; }
void CSoundOptionsDlg::OnPlay2() { CString Temp; m_ProcessCompleteCtrl.GetWindowText(Temp); PlaySoundFile ( Temp ); }
int CDuffDlg::Search() { m_Status.SetWindowText( StringFromResource(IDS_STATUS_BUSY) ); if (m_bAnimateControl) { m_AnimateControl.ShowWindow(SW_SHOW); m_AnimateControl.Play(ALL); } g_DupeFileFind.StartSearch(); if (m_bAnimateControl) { m_AnimateControl.Stop(); } m_Status.SetWindowText( StringFromResource(IDS_STATUS_IDLE) ); OnTimer(TIMER_PROGRESS); KillTimer(TIMER_PROGRESS); if ( theApp.m_DuffOptions.Sound.Enabled ) PlaySoundFile( theApp.m_DuffOptions.Sound.ProcessComplete ); return 0; }
void getButton() { //gets next button press while (true) { button = nNxtButtonPressed; if (button != -1) break; } PlaySoundFile("! Click.rso"); while(nNxtButtonPressed != -1) { } }
void initializeRobot() { // Place code here to initialize servos to starting positions. if (nAvgBatteryLevel < 8000) { // brick under 8.0 volts PlayImmediateTone(1000, 100); // play a warning tone PlaySoundFile("NxtBatteryLow.rso"); } if (externalBatteryAvg < 12000) { // main battery under 12.0 int i; // play a warning siren once for // every tenth of a volt too low for (i = 0; i < (14000 - externalBatteryAvg) / 100; i++) { PlayImmediateTone(2000, 300); // play a warning tone PlaySoundFile("ExternalBatteryLow.rso"); } } return; }
void PressBumperToContinue() { nxtScrollText(""); nxtScrollText("press button"); nxtScrollText("to continue"); PlaySoundFile("! Attention.rso"); while (!TSreadState(BUMPER)) wait1Msec(10); // not pressed while (TSreadState(BUMPER)) wait1Msec(10); // pressed wait1Msec(500); }
void initializeRobot() { // Place code here to sinitialize servos to starting positions. // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize. if (nAvgBatteryLevel < 8000) { // brick under 8.0 volts PlayImmediateTone(1000, 100); // play a warning tone PlaySoundFile("NxtBatteryLow.rso"); } if (externalBatteryAvg < 14000) { // main battery under 14.0 int i; // play a warning siren once for // every tenth of a volt too low for (i = 0; i < (14000 - externalBatteryAvg) / 100; i++) { PlayImmediateTone(2000, 300); // play a warning tone PlaySoundFile("ExternalBatteryLow.rso"); } } return; }
void PlayEndSound() { nVolume = 4; PlaySoundFile("stopped.rso"); while (bSoundActive) {}; wait1Msec(1000); PlaySound(soundFastUpwardTones); while (bSoundActive) {}; wait1Msec(2000); while (true) { PlaySoundFile("3.rso"); PlaySoundFile("7.rso"); PlaySoundFile("6.rso"); PlaySoundFile("3.rso"); while (bSoundActive) {}; wait1Msec(1000); } }
void PlaySoundForColor (ColorClass cc) { switch (cc) { case ColorShout: PlaySoundFile(appData.soundShout); break; case ColorSShout: PlaySoundFile(appData.soundSShout); break; case ColorChannel1: PlaySoundFile(appData.soundChannel1); break; case ColorChannel: PlaySoundFile(appData.soundChannel); break; case ColorKibitz: PlaySoundFile(appData.soundKibitz); break; case ColorTell: PlaySoundFile(appData.soundTell); break; case ColorChallenge: PlaySoundFile(appData.soundChallenge); break; case ColorRequest: PlaySoundFile(appData.soundRequest); break; case ColorSeek: PlaySoundFile(appData.soundSeek); break; case ColorNormal: case ColorNone: default: break; } }
// Play the Sound File identified by name and path HRESULT SoundManager::PlaySoundFile(char* songName) { int songNum = -1; // look for the song in out list of songs for(int i = 0; i < numOfFiles; i++) { char* fileName = songsLoaded[i]; if(strcmp(songName, fileName) == 0) { songNum = i; break; } } // Could not find the song so exit out of the method if(songNum == -1) return -1; PlaySoundFile(songNum); return 0; }
task main() { waitForStart(); initializeRobot(); // The amount of time the robot... // ...moves forward at an angle. const int forwardTimeA = 150; // ...turns to line up perpendicular to the center rack. const int turnTimeB = 40; // ...drives up to the peg before lifting the lift up. const int forwardTimeC = 155; // ...lifts the claw to put a ring on (row 2). const int liftTimeF = 79; // ...moves forward, putting the ring onto the peg. const int forwardTimeG = 65; // ...lowers its lift to get rid of the ring. const int liftTimeH = 55; // ...backs up and gets ready to go to a dispenser. const int backwardTimeI = 300; // ...turns to face parallel to the walls. const int turnTimeJ = 40; // ...moves forward to align itself with a dispenser. const int forwardTimeK = 100; // ...turns to face the dispenser. const int turnTimeL = 80; // ...moves forward to be under the dispenser. const int forwardTimeM = 50; Move_Forward (forwardTimeA, g_AccurateMotorPower); Turn_Left (turnTimeB, g_AccurateMotorPower, g_AccurateMotorPower); Move_Forward (forwardTimeC, g_AccurateMotorPower); Lift_Lift (liftTimeF, g_AccurateMotorPower); Move_Forward (forwardTimeG, g_AccurateMotorPower); // Lift power is negative so that the lift goes DOWN, not UP. Lift_Lift (liftTimeH, (-1) * g_AccurateMotorPower); Move_Backward (backwardTimeI, g_AccurateMotorPower); // Turn power doesn't need to be negative (turns in-place). Turn_Left (turnTimeJ, g_AccurateMotorPower, g_AccurateMotorPower); Move_Forward (forwardTimeK, g_AccurateMotorPower); Turn_Left (turnTimeL, g_AccurateMotorPower, g_AccurateMotorPower); Move_Forward (forwardTimeM, g_AccurateMotorPower); while (true) { PlaySoundFile("moo.rso"); while(bSoundActive == true) { Time_Wait(1); } } }
void track_wall() { float distanciaParaParar = 20; float distanciaAlMuro = 20; float umbral = 0; float v = 0.2; float w = 0; // Para evitar el esmorramiento contra un muro frontal while(SensorValue[sonarSensorFrontal] > distanciaParaParar) { AcquireMutex(semaphore_odometry); float x = robot_odometry.x; float y = robot_odometry.y; float th = robot_odometry.th; ReleaseMutex(semaphore_odometry); float sval = SensorValue[sonarSensorLateral]; string temp; StringFormat(temp, "%.2f", sval); nxtDisplayBigTextLine(2, temp); string temp2; StringFormat(temp2, "%.2f", th); nxtDisplayBigTextLine(5, temp2); // Oscila a una distancia segura de la pared lateral // Debe girar a la derecha porque se esta alejando if (SensorValue[sonarSensorLateral] > distanciaAlMuro + umbral) { w = -v; if(th < -0.2){ w = 0; } } // Debe girar a la izquierda porque se esta acercando else if(SensorValue[sonarSensorLateral] < distanciaAlMuro - umbral) { w = v; if(th > 0.2){ w = 0; } } else { if(th > 0.2){ w = -(v*0.9); } else if(th < -0.2){ w = v*0.9; } else{ w = 0; } } setSpeed(v,w); } // Gira al encontrarse con un muro de frente float theta, thetaFinal; float errorTheta = 0.005; // turn 90 degrees on the robot setSpeed(0,0); // condicion de parada AcquireMutex(semaphore_odometry); float x = robot_odometry.x; float y = robot_odometry.y; float th = robot_odometry.th; ReleaseMutex(semaphore_odometry); theta = th; thetaFinal = (PI)/2; PlaySoundFile("wilhelmA.rso"); Sleep(1200); v = 0; w = 1.5; setSpeed(v,w); while(abs(theta - thetaFinal) > errorTheta) { //nxtDisplayTextLine(3, "dist %2.2f", euclideanDistance(x,xFinal,y,yFinal)); //nxtDisplayTextLine(4, "Theta: %2.2f", abs(theta - thetaFinal)); AcquireMutex(semaphore_odometry); theta = robot_odometry.th; ReleaseMutex(semaphore_odometry); } }
void PlayIcsLossSound () { PlaySoundFile(appData.soundIcsLoss); }
void PlayIcsWinSound () { PlaySoundFile(appData.soundIcsWin); }
void CDuffDlg::OnTimer(UINT /*nIDEvent*/) { int i; CString Temp; CFileInfo * pFileInfo; int PercentDone; if ( g_DupeFileFind.m_DuffStatus.LockIfUnlocked() ) { m_CurrentTaskText.SetWindowText(g_DupeFileFind.m_DuffStatus.CurrentTaskStr ); m_CurrentTaskInfoText.SetWindowText(g_DupeFileFind.m_DuffStatus.CurrentTaskInfo ); m_ProgressEntire.SetRange64( g_DupeFileFind.m_DuffStatus.MainProgress.Min, g_DupeFileFind.m_DuffStatus.MainProgress.Max ); m_ProgressEntire.SetPos64( g_DupeFileFind.m_DuffStatus.MainProgress.Pos ); PercentDone = 0; if ( g_DupeFileFind.m_DuffStatus.MainProgress.Max ) PercentDone = (int) ( 100 * (double)g_DupeFileFind.m_DuffStatus.MainProgress.Pos/ (double)g_DupeFileFind.m_DuffStatus.MainProgress.Max); Temp.Format( _T("%03d %%") ,PercentDone); m_RangeEntire.SetWindowText(Temp); m_ProgressSub1.SetRange64( g_DupeFileFind.m_DuffStatus.SubProgress1.Min, g_DupeFileFind.m_DuffStatus.SubProgress1.Max ); m_ProgressSub1.SetPos64( g_DupeFileFind.m_DuffStatus.SubProgress1.Pos ); PercentDone = 0; if ( g_DupeFileFind.m_DuffStatus.SubProgress1.Max ) PercentDone = (int)(100 * (double)g_DupeFileFind.m_DuffStatus.SubProgress1.Pos / (double)g_DupeFileFind.m_DuffStatus.SubProgress1.Max); Temp.Format( _T("%03d %%") ,PercentDone); m_SubRange1.SetWindowText(Temp); m_ProgressSub2.SetRange64( g_DupeFileFind.m_DuffStatus.SubProgress2.Min, g_DupeFileFind.m_DuffStatus.SubProgress2.Max ); m_ProgressSub2.SetPos64( g_DupeFileFind.m_DuffStatus.SubProgress2.Pos ); PercentDone = 0; if ( g_DupeFileFind.m_DuffStatus.SubProgress2.Max ) PercentDone = (int)(100 * (double)g_DupeFileFind.m_DuffStatus.SubProgress2.Pos / (double)g_DupeFileFind.m_DuffStatus.SubProgress2.Max); Temp.Format( _T("%03d %%") ,PercentDone); m_SubRange2.SetWindowText(Temp); for ( i = 0; i < g_DupeFileFind.m_DuffStatus.LogQueue.GetSize(); i++ ) { Log( g_DupeFileFind.m_DuffStatus.LogQueue.ElementAt(i) ); } g_DupeFileFind.m_DuffStatus.LogQueue.RemoveAll(); if ( g_DupeFileFind.m_DuffStatus.DupeQueue.GetSize() && theApp.m_DuffOptions.Sound.Enabled ) { PlaySoundFile( theApp.m_DuffOptions.Sound.FoundDuplicate); } for ( i = 0; i < g_DupeFileFind.m_DuffStatus.DupeQueue.GetSize(); i++ ) { pFileInfo = g_DupeFileFind.m_DuffStatus.DupeQueue.ElementAt(i); ASSERT(pFileInfo); m_DuplicatePage.AddItem(pFileInfo); /* if ( pFileInfo->FirstFile ) { m_DuplicatePage.m_DuplicateSetCounter ++; } // add duplicates to list view Temp.Format("%d", m_DuplicatePage.m_DuplicateSetCounter); m_DuplicatePage.m_DupeList.InsertItem(LVIF_PARAM | LVIF_TEXT, m_DuplicatePage.m_TotalFilesCounter, Temp,NULL,NULL,NULL,(DWORD) pFileInfo ); m_DuplicatePage.m_DupeList.SetItemText( m_DuplicatePage.m_TotalFilesCounter-1,1, pFileInfo ->FullName ); buffer[0] = 0; ulonglong2str(buffer,pFileInfo->Size); m_DuplicatePage.m_DupeList.SetItemText( m_DuplicatePage.m_TotalFilesCounter-1,2,buffer); pFileInfo->InitVersion(); m_DuplicatePage.m_DupeList.SetItemText( m_DuplicatePage.m_TotalFilesCounter-1,3, pFileInfo->GetFileVersionStr()); // */ } g_DupeFileFind.m_DuffStatus.DupeQueue.RemoveAll(); if ( theApp.m_DuffOptions.General.AutoScrollDupeList ) { //if ( (unsigned long)(m_DuplicatePage.m_DupeList.GetTopIndex() + m_DuplicatePage.m_DupeList.GetCountPerPage()) == m_DuplicatePage.m_TotalFilesCounter -1 || // (unsigned long)(m_DuplicatePage.m_DupeList.GetCountPerPage()) > m_DuplicatePage.m_TotalFilesCounter -1 // ) m_DuplicatePage.m_DupeList.EnsureVisible((int)m_DuplicatePage.GetNumFiles()-1, FALSE); } g_DupeFileFind.m_DuffStatus.Unlock(); } //CResizableDialog::OnTimer(nIDEvent); }
//========================================== //========================================== //========================================== task selector() { wait1Msec(1000); while((nNxtButtonPressed != kEnterButton)) { if (nNxtButtonPressed == kLeftButton) { while(nNxtButtonPressed ==kLeftButton){}; MissionNumber = MissionNumber-1; PlaySoundFile("! Click.rso"); } if (MissionNumber < 1) { MissionNumber = 1; } if (MissionNumber > 20) { MissionNumber = 20; } if (nNxtButtonPressed == kRightButton) { while(nNxtButtonPressed ==kRightButton){}; MissionNumber = MissionNumber+1; PlaySoundFile("! Click.rso"); } nxtDisplayBigTextLine(2, "Mission"); nxtDisplayBigTextLine(5, "%2d", MissionNumber); } eraseDisplay(); string tmp = ""; StringFormat(tmp, "%3d", MissionNumber); nxtDisplayBigStringAt(20,18,tmp); while(nNxtButtonPressed == kEnterButton) {} eraseDisplay(); while(nNxtButtonPressed != kEnterButton) { nxtDisplayBigTextLine(6, "SecDelay"); nxtDisplayBigTextLine(4, "%3d", time_selector); if (nNxtButtonPressed == kLeftButton) { while(nNxtButtonPressed ==kLeftButton){}; time_selector = time_selector-1; PlaySoundFile("! Click.rso"); } if (nNxtButtonPressed == kRightButton) { while(nNxtButtonPressed ==kRightButton){} time_selector = time_selector+1; PlaySoundFile("! Click.rso"); } if(time_selector > 30) time_selector = 30; if(time_selector < 0) time_selector = 0; } PlaySound(soundException); wait1Msec(200); eraseDisplay(); while(nNxtButtonPressed == kEnterButton){} while(nNxtButtonPressed != kEnterButton) { nxtDisplayBigTextLine(6, "gyro_cal"); nxtDisplayBigTextLine(4, "%2d", gyroCalTime); if(nNxtButtonPressed == kLeftButton) { while(nNxtButtonPressed == kLeftButton){} gyroCalTime = gyroCalTime-1; PlaySoundFile("! Click.rso"); } if(nNxtButtonPressed == kRightButton) { while(nNxtButtonPressed == kRightButton){} gyroCalTime = gyroCalTime+1; PlaySoundFile("! Click.rso"); } if(gyroCalTime > 15) gyroCalTime = 15; if(gyroCalTime < 0) gyroCalTime = 0; } if(gyroCalTime > 0) calibrate = 1; PlaySound(soundException); eraseDisplay(); }
void checkLocalCell() { //uses a normalised version of the localTemp. The comparison local cells are stored as normalised when 1st created char z; char match = 0; float dotTempValue = 0; float tempAngle = 0; if(nextEmptyCell == 0) { //first localCellView fillStructArray(nextEmptyCell); nextEmptyCell++; //eraseDisplay(); //nxtDisplayCenteredTextLine(3, "New Cell Created"); //wait1Msec(1000); //eraseDisplay(); PlaySoundFile("! Attention.rso"); while(bSoundActive) {} } else { for(z = 0; z<nextEmptyCell; z++) { //search for a previous local cell that matches the current view to a certain degree fillLocalComparison(z); dotTempValue = dotMultiply(); tempAngle = acos(dotTempValue); eraseDisplay(); nxtDisplayString(5, "%3.3f", tempAngle); wait1Msec(1000); if(tempAngle<0.17) { //a match - need to check match = 1; break; } } if(match == 0) {//no match found - create a new local view cell fillStructArray(nextEmptyCell); nextEmptyCell++; // eraseDisplay(); // nxtDisplayCenteredTextLine(3, "No Match"); // nxtDisplayCenteredTextLine(4, "New Cell Created"); // wait1Msec(1000); // eraseDisplay(); PlaySoundFile("! Attention.rso"); while(bSoundActive) {} } else if(match == 1) { // eraseDisplay(); // nxtDisplayCenteredTextLine(3, "Match"); // wait1Msec(1000); // eraseDisplay(); PlaySoundFile("Woops.rso"); while(bSoundActive) {} } } }
void PlayIcsDrawSound () { PlaySoundFile(appData.soundIcsDraw); }
void PlayAlarmSound () { PlaySoundFile(appData.soundIcsAlarm); }
void PlayIcsUnfinishedSound () { PlaySoundFile(appData.soundIcsUnfinished); }
void CSoundOptionsDlg::OnPlay1() { CString Temp; m_FoundDuplicateCtrl.GetWindowText(Temp); PlaySoundFile ( Temp ); }
void PlayTellSound () { PlaySoundFile(appData.soundTell); }
void RingBell () { PlaySoundFile(appData.soundMove); }
void MechanismControl(Controller& controller) { // slide adjustment w/horizontal of DPad if ( controller.isFresh ) { if ( controller.dPad.x == -1 ) servo[Slide] += kSlideIncrement; else if ( controller.dPad.x == 1 ) servo[Slide] -= kSlideIncrement; } // intake if ( controller.leftJoystick.y > .25 ) { servo[Intake] = kIntakeReverse; } else if ( controller.leftJoystick.y < -.25 ) { servo[Intake] = kIntakeOn; } else { servo[Intake] = kIntakeOff; } // R1 kicks batons, but only when the elevator is at the top if ( ControllerButtonIsPressed(controller, ControllerButtonR1) && ElevatorIsAtTop() ) { if ( !MechanismKickerIsKicking ) { StartTask(MechanismKickerKick); PlaySoundFile("ChaChing.rso"); } } // FIXME: slide positions #define ABORT_ELEVATOR_TARGET() StopTask(MechanismElevatorTargetTask) if ( MechanismElevatorIsTargeting == false ) { if ( ControllerButtonIsPressed(controller, ControllerButton2) ) { ABORT_ELEVATOR_TARGET(); MechanismElevatorTargetEncoder = kElevatorTargetMidDispenser; StartTask(MechanismElevatorTargetTask); } else if ( ControllerButtonIsPressed(controller, ControllerButton3) ) { ABORT_ELEVATOR_TARGET(); MechanismElevatorTargetEncoder = kElevatorTargetHighDispenser; StartTask(MechanismElevatorTargetTask); } else if ( ControllerButtonIsPressed(controller, ControllerButton4) ) { ABORT_ELEVATOR_TARGET(); MechanismElevatorTargetEncoder = kElevatorTargetBridgeCrossing; StartTask(MechanismElevatorTargetTask); } } if ( !MechanismElevatorIsTargeting ) { // elevator up/down control with L1 & L2 if ( controller.dPad.y > .5 && !ElevatorIsAtTop() ) { motor[Elevator] = kElevatorSpeed; } else if ( controller.dPad.y < -.5 && !ElevatorIsAtBottom() ) { motor[Elevator] = -kElevatorSpeed; } else { motor[Elevator] = 0; } } if ( ControllerButtonIsPressed(controller, ControllerButtonL1) ) { servo[Slide] = kSlideRegularPosition; } else if ( ControllerButtonIsPressed(controller, ControllerButtonL2) ) { servo[Slide] = kSlideDownPosition; } }
// ============================== INPUT HANDLING ======================================== long TsounEditForm::DoControlClick( long arg, void *ptr ) { #ifdef __MWERKS__ #pragma unused(ptr) #endif XGListControl *pList = dynamic_cast<XGListControl *>(GetWindow()->FindViewByID( 12314 )); int sel = pList->GetValue(); tag_entry* e; tag new_id; switch( arg ) { case 12302: // Choose a tag new_id = pick_tag_of_type( 'stli', GetTag( 12302 ), fEntry ); if( new_id != 0 ) { def.subtitle_string_list_tag = new_id; SetTag( 12302, 'stli', new_id ); SetValues(); } break; case 12303: // Open tag window e = get_entry( 'stli', GetTag( 12302 ) ); if( e ) TRevengeApp::OpenItem( e ); break; case 12315: // Add { assert( def.number_of_permutations < MAXIMUM_PERMUTATIONS_PER_SOUND ); XGFileSpecifier *fs = NULL; #if OPT_MACOS fs = XGFileSpecifier::OpenDialog( 129 ); #endif #if OPT_WINOS fs = XGFileSpecifier::OpenDialog( "Wave Audio File|*.wav","WAV" ); #endif #if OPT_XWIN fs = XGFileSpecifier::OpenDialog( "wav" ); #endif if( !fs ) return 0; if( LoadSoundFile( def, fs ) == LOAD_SOUND_ERROR_SUCCESS ) { pList->Insert( def.number_of_permutations, def.sound_permutations[def.number_of_permutations].name ); pList->SetValue( def.number_of_permutations ); def.number_of_permutations++; // update perutations size and sound_offset def.permutations_size += sizeof(sound_permutation_data); def.sound_offset += sizeof(sound_permutation_data); DoListSelect( 12314, NULL ); } delete fs; } break; case 12316: // Duplicate { assert( def.number_of_permutations < MAXIMUM_PERMUTATIONS_PER_SOUND ); assert( sel != -1 && sel < def.number_of_permutations && sel < MAXIMUM_PERMUTATIONS_PER_SOUND ); int perm = def.number_of_permutations; int sample_size; // update our sound_size if( def.sampled_sound_headers[sel].flags & _sound_is_ima_compressed_flag ) sample_size = def.sampled_sound_headers[sel].number_of_samples * sizeof(apple_ima_packet_chunk); else sample_size = def.sampled_sound_headers[sel].number_of_samples << def.sampled_sound_headers[sel].physical_bytes_per_sample_minus_one; def.sound_size += (sample_size + sizeof(sampled_sound_header)); // copy the headers to the new permutaion slot def.sound_permutations[perm] = def.sound_permutations[sel]; def.sampled_sound_headers[perm] = def.sampled_sound_headers[sel]; // make a duplicate of the samples buffer assert( def.sampled_sound_headers[sel].samples ); def.sampled_sound_headers[perm].samples = malloc( sample_size ); memcpy( def.sampled_sound_headers[perm].samples, def.sampled_sound_headers[sel].samples, sample_size ); def.number_of_permutations++; // update perutations size and sound_offset def.permutations_size += sizeof(sound_permutation_data); def.sound_offset += sizeof(sound_permutation_data); // update the permutation list SetValues(); } break; case 12317: // Delete { assert( def.number_of_permutations > 0 ); assert( sel > -1 && sel < def.number_of_permutations && sel < MAXIMUM_PERMUTATIONS_PER_SOUND ); int sample_size; int ii; // update our sound_size if( def.sampled_sound_headers[sel].flags & _sound_is_ima_compressed_flag ) sample_size = def.sampled_sound_headers[sel].number_of_samples * sizeof(apple_ima_packet_chunk); else sample_size = def.sampled_sound_headers[sel].number_of_samples << def.sampled_sound_headers[sel].physical_bytes_per_sample_minus_one; def.sound_size -= (sample_size - sizeof(sampled_sound_header)); assert( def.sound_size >= 0 ); // free any data associated with our victim permutation assert( def.sampled_sound_headers[sel].samples ); // there is something wrong if no data here if( def.sampled_sound_headers[sel].samples ) free( def.sampled_sound_headers[sel].samples ); // move everything past the sel back one for( ii = sel; ii + 1 < def.number_of_permutations; ii++ ) { def.sound_permutations[ii] = def.sound_permutations[ii + 1]; def.sampled_sound_headers[ii] = def.sampled_sound_headers[ii + 1]; } // zero out the extra permutation memset( &def.sound_permutations[ii], 0x00, sizeof(sound_permutation_data) ); memset( &def.sampled_sound_headers[ii], 0x00, sizeof(sampled_sound_header) ); def.number_of_permutations--; // update perutations size and sound_offset def.permutations_size -= sizeof(sound_permutation_data); def.sound_offset -= sizeof(sound_permutation_data); // remove the item from the permutation list SetValues(); } break; case 12319: // Play sound { assert( def.number_of_permutations > 0 ); assert( sel > -1 && sel < def.number_of_permutations && sel < MAXIMUM_PERMUTATIONS_PER_SOUND ); PlaySoundFile(); } break; default: return -1; } UpdatePermutationControls(); return 0; }
task main() { waitForStart(); // Wait for the tele-op period to begin nMotorEncoder(motorLift1) = 0; // Reset the motor encoders for the arm servoTarget(clawL) = 225; // Initialize the claw to be open servoTarget(clawR) = 60; PlaySoundFile("Leroy.rso"); // Shout "LEEROY JENKINS!", just for fun wait1Msec(10); // Wait one tenth of a second while (true) { getJoystickSettings(joystick); // Read the value of the joysticks nxtDisplayTextLine(6, "Encoder: %d", nMotorEncoder[motorLift1]); // Display the value of the arm encoder // The following code makes the directional pad on controller 1 give precise digital control of the drivetrain: if (joystick.joy1_TopHat == 0) // If "up" on the directional pad is pressed: { go_forward(25); // Go forward at 25% speed } else if (joystick.joy1_TopHat == 1) // Else if "top right" on the directional pad is pressed: { strafe_forward_right(25); // Strafe diagonally forward and to the right at 25% speed } else if (joystick.joy1_TopHat == 2) // Else if "right" on the directional pad is pressed: { strafe_right(25); // Strafe to the right at 25% speed } else if (joystick.joy1_TopHat == 3) // Else if "bottom right" on the directional pad is pressed: { strafe_backward_right(25); // Strafe diagonally backward and to the right 25% speed } else if (joystick.joy1_TopHat == 4) // Else if "down" on the directional pad is pressed: { go_backward(25); // Go backward 25% speed } else if (joystick.joy1_TopHat == 5) // Else if "bottom left" on the directional pad is pressed: { strafe_backward_left(25); // Strafe diagonally backward and to the left 25% speed } else if (joystick.joy1_TopHat == 6) // Else if "left" on the directional pad is pressed: { strafe_left(25); // Strafe left 25% speed } else if (joystick.joy1_TopHat == 7) // Else if "top left" on the directional pad is pressed: { strafe_forward_left(25); // Strafe diagonally forward and to the left 25% speed } else if (joy1Btn(5)) // Else if button 6 is pressed: { rotate_clockwise(25); // Rotate the robot clockwise 25% speed } else if (joy1Btn(6)) // Else if button 5 is pressed: { rotate_counter_clockwise(25); // Rotate the robot counter-clockwise 25% speed } // The following code makes the joysticks on controller 1 give analogue control of the drivetrain: else { motor[motorFL] = scale_motor(joystick.joy1_y1 + joystick.joy1_x1 + joystick.joy1_x2); // Scale the motors to the average motor[motorFR] = scale_motor(joystick.joy1_y1 + -joystick.joy1_x1 - joystick.joy1_x2); //of the left joystick Y value and motor[motorBR] = scale_motor(joystick.joy1_y1 + joystick.joy1_x1 - joystick.joy1_x2); //the right joystick X value motor[motorBL] = scale_motor(joystick.joy1_y1 + -joystick.joy1_x1 + joystick.joy1_x2); } // The following code assigns the shoulder buttons on controller 2 to open and close the claw: if (joy2Btn(5)) { servoTarget(clawL) = 55; // If button 5 is pressed on controller 2, close the claw servoTarget(clawR) = 170; } else if (joy2Btn(6)) { servoTarget(clawL) = 115; // If button 6 is pressed on controller 2, open the claw servoTarget(clawR) = 100; } else if (joy2Btn(8)) { servoTarget(clawL) = ServoValue(clawL) + 1; // While button 7 is held, slowly close the claw servoTarget(clawR) = ServoValue(clawR) - 1; } else if (joy2Btn(7)) { servoTarget(clawL) = ServoValue(clawL) - 1; // While button 8 is held, slowly open the claw servoTarget(clawR) = ServoValue(clawR) + 1; } else { servoTarget(clawL) = ServoValue(clawL); // Otherwise, do not move the claw servoTarget(clawR) = ServoValue(clawR); } // The following code gives analogue control of the arm with the joystick, and assigns buttons 1-4 to move the arm to their respective rows on the scoring rack if (joy2Btn(1)) // If button 1 is pressed, move the arm to the lowest row on the scoring rack { moveArm(level1Value); } else if (joy2Btn(2)) // If button 2 is pressed, move the arm to the middle row on the scoring rack { moveArm(level2Value); } else if (joy2Btn(3)) // If button 3 is pressed, move the arm to the top row on the scoring rack { moveArm(level3Value); } else if (joy2Btn(4)) // If button 4 is pressed, lower the arm all the way { moveArm(0); } else { motor[motorLift1] = (joystick.joy2_y1 / 12); // Otherwise, control the arm with joystick 1 on controller 2 motor[motorLift1] = (joystick.joy2_y1 / 24); // Or control the arm at half speed with joystick 2 on controller 2 // Note: these values are divided by 12 and 24 to bring the arm speed down to a reasonable level } } }
task main() { // This task dictates what the robot will do during the autonomous period waitForStart(); // Wait for the start of the autonomous period StartTask(counter); // Begin timing the program, for use later PlaySoundFile("Leroy.rso"); // Shout "LEEROY JENKINS!", just for fun nMotorEncoder(motorLift1) = 0; // Reset the motor encoders for the arm servoTarget(clawL) = 55; // Close the claw to hold the ring servoTarget(clawR) = 170; wait1Msec(100); // Wait a tenth of a second strafeToIR(); // Strafe parallel to the scoring rack until it is lined up with the IR beacon wait1Msec(1000); // Wait for one second after this has been completed strafeToIR(); // Strafe parallel to the scoring rack until it is lined up with the IR beacon wait1Msec(1000); // Wait for one second after this has been completed // Note: this is done twice to ensure accuracy motor[motorFL] = 0; // Wait one tenth of a second in the stopped position motor[motorFR] = 0; motor[motorBR] = 0; motor[motorBL] = 0; wait1Msec(100); // The following code is used to raise the arm to the correct height: nMotorEncoderTarget[motorLift1] = -scoringPegHeight; // Set the motor encoder target for the arm to the height of the scoring peg motor[motorLift1] = -armSpeed; // Raise the arm at the designated speed while(nMotorRunState[motorLift1] != runStateIdle) // While the arm is still moving (hasn't reached the target yet) { // Do not continue } motor[motorLift1] = 0; // Once the arm has reached its target, stop moving motor[motorFL] = 100; // Drive forward towards the scoring rack motor[motorFR] = 100; motor[motorBR] = 100; motor[motorBL] = 100; wait1Msec(3000); motor[motorFL] = 0; // Wait one second in the stopped position motor[motorFR] = 0; motor[motorBR] = 0; motor[motorBL] = 0; wait1Msec(1000); servoTarget(clawL) = 115; // Open the claw to place the ring on the scoring rack servoTarget(clawR) = 100; wait1Msec(1000); motor[motorFL] = -100; // Reverse away from the scoring rack, leaving the ring on the rack motor[motorFR] = -100; motor[motorBR] = -100; motor[motorBL] = -100; wait1Msec(1800); motor[motorFL] = 0; // Wait one second in the stopped position motor[motorFR] = 0; motor[motorBR] = 0; motor[motorBL] = 0; wait1Msec(1000); servoTarget(clawL) = 55; // Close the claw servoTarget(clawR) = 170; wait1Msec(1000); // The following code is used to lower the arm back down: nMotorEncoderTarget[motorLift1] = 100; // Set the motor encoder target for the arm to the height of the scoring peg motor[motorLift1] = armSpeed; // Raise the arm at the designated speed while(nMotorRunState[motorLift1] != runStateIdle) // While the arm is still moving (hasn't reached the target yet) { // Do not continue } motor[motorLift1] = 0; // Once the arm has reached its target, stop moving }