当前位置: 首页>>代码示例>>C++>>正文


C++ PlayTone函数代码示例

本文整理汇总了C++中PlayTone函数的典型用法代码示例。如果您正苦于以下问题:C++ PlayTone函数的具体用法?C++ PlayTone怎么用?C++ PlayTone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PlayTone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gyro

//------------
//=================================================
// Task to handle the gyro and the other sensors hooked up to the sensor mux
//=================================================
task gyro()
{
	float currDir = 0.0; float prevDir = 0.0;
	long currtime,prevtime;
	ir_mux_status=HTSMUXreadPowerStatus(IR_MUX);				// read the sensor multiplexor status
	gyro_mux_status=HTSMUXreadPowerStatus(GYRO_MUX);		// read the sensor multiplexor status
	while (ir_mux_status || gyro_mux_status)  					// check good battery power on both muxes
	{
		PlayTone(750,25);
		wait1Msec(500);
	}

	wait1Msec(300);

	for (int i=0;i<5;i++)            // check if there is too much spread in the data
	{
		if (gyro_noise>10)
		{
			PlayTone (250,25);
			wait1Msec(500);
		}
	}
	calibrate = 2;
	prevtime = nPgmTime;
	while(true)
	{
		currtime=nPgmTime;
		rawgyro = (float)HTGYROreadRot(HTGYRO);
		constHeading += (rawgyro - drift) * (float)(currtime-prevtime)/1000;
		relHeading += (rawgyro - drift) * (float)(currtime-prevtime)/1000;
		prevtime = currtime;
		wait1Msec(1);
		prevDir = currDir;
	}
}
开发者ID:GotRobotFTC5037,项目名称:BlockParty2015,代码行数:39,代码来源:teleop2_v12r1+(Kristen+McKellar's+conflicted+copy+2013-04-02).c

示例2: main

task main()
{
	nMotorEncoder[motorRight] = 0;
	nMotorEncoder[motorLeft] = 0;
	motor[motorLeft] = 20;
	motor[motorRight] = 20;
	while ( SensorValue[IRsensor] != 6)
	{
		wait1Msec(10);
		nxtDisplayCenteredTextLine(3, "Sensor Value: %d", SensorValue[IRsensor]);

	}

		motor[motorLeft] = 0;
		motor[motorRight] = 0;
		PlayTone(736, 50);
		wait1Msec(1000);

		//Now go for x amount of encoder counts//

		motor[motorLeft] = 20;
		motor[motorRight] = 20;
		while ( nMotorEncoder[motorLeft] < (360 * 4 * 9.5))
		{
			wait10Msec(1);
		}

		motor[motorLeft] = 0;
		motor[motorRight] = 0;
		PlayTone(736, 50);
		wait1Msec(1000);

}
开发者ID:IronEagles,项目名称:Prime,代码行数:33,代码来源:first_Auto.c

示例3: strlen

//--------------------------------------------------------------------------------------------------
static void* PlayDtmfThread
(
    void* contextPtr
)
{
    DtmfThreadCtx_t *threadCtxPtr = (DtmfThreadCtx_t*) contextPtr;
    size_t           dtmfLen = strlen(threadCtxPtr->dtmfPtr);
    uint32_t         i;

    for (i=0 ; i< dtmfLen ; i++)
    {
        LE_INFO("Play digit.%c", threadCtxPtr->dtmfPtr[i]);

        PlayTone(threadCtxPtr->pipefd[1], threadCtxPtr->sampleRate,
                 Digit2LowFreq(threadCtxPtr->dtmfPtr[i]), DTMF_AMPLITUDE,
                 Digit2HighFreq(threadCtxPtr->dtmfPtr[i]), DTMF_AMPLITUDE,
                 threadCtxPtr->duration);

        if (threadCtxPtr->pause)
        {
            // Play silence
            PlayTone(threadCtxPtr->pipefd[1], threadCtxPtr->sampleRate,
                     0, 0,
                     0, 0,
                     threadCtxPtr->pause);
        }
    }

    return NULL;
}
开发者ID:mbaglin,项目名称:legato-af,代码行数:31,代码来源:le_media.c

示例4: calibrateScales

// Allow the user to calibrate the scales
void calibrateScales()
{
  int calibrateWeight = 0;

  eraseDisplay();
  nxtDisplayCenteredTextLine(0, "GlideWheel-AS");
  nxtDisplayCenteredTextLine(2, "Place the object");
  nxtDisplayCenteredTextLine(3, "on the scales");
  nxtDisplayCenteredTextLine(4, "and press");
  nxtDisplayCenteredTextLine(5, "[enter]");
  nxtDisplayCenteredTextLine(6, "to calibrate");
  while (nNxtButtonPressed != kEnterButton) EndTimeSlice();
  debounce();
  eraseDisplay();
  calibrateWeight = weighObject();
  nxtDisplayCenteredTextLine(0, "GlideWheel-AS");
  nxtDisplayCenteredTextLine(2, "Enter the weight");
  nxtDisplayCenteredTextLine(3, "in grams");
  nxtDisplayCenteredTextLine(7, "-     OK     +");
  while (true)
  {
    nxtDisplayCenteredBigTextLine(5, "%d", calibrateWeight);
    switch(nNxtButtonPressed)
    {
      case kLeftButton: PlayTone(500,10); calibrateWeight--; calibrateWeight = max2(0, calibrateWeight); break;
      case kRightButton: PlayTone(1000,10); calibrateWeight++; break;
      case kEnterButton: PlayTone(1500,10);gramsPerUnit = (float)calibrateWeight / (float)MSANGreadRaw(MSANG); eraseDisplay(); return;
    }
    wait1Msec(20);
    debounce();
  }
}
开发者ID:BRHSRoboSoccer,项目名称:robonauts-2013,代码行数:33,代码来源:mindsensors-angle-test2.c

示例5: StallCode

int StallCode(tMotor motorSentTo, int wantedPower)
{
	int motorIndex;  //index value for the arrays we are storing values in.
	int direction = 0;
	switch(motorSentTo) //which motor power is being sent to
	{
		case LeftMotor: // This is the name of one of the motors as referenced in the configuraiton.
			motorIndex = 0;
			break;
		case RightMotor:
			motorIndex = 1;
			break;
		/*case ForkLift:
			motorIndex = 2;
			break;*/
		default:
			break;
	}

	if (abs(wantedPower) < deadZone)  // Power below threshold, mark as stopped.
		direction = 0;
  else
  	direction = (wantedPower < 0) ? -1 : 1;

	if (direction == 0 || lastDirection[motorIndex] != direction)  // Stopped or changed direction.	Allow whatever power desired this time.
		{
    	lastDirection[motorIndex] = direction;
			timeLastSigMove[motorIndex]	 = time1[T1];
			encLastSigMove[motorIndex] = nMotorEncoder[motorSentTo];

			return wantedPower;
		}

 	lastDirection[motorIndex] = direction;

	if ( abs(encLastSigMove[motorIndex] - nMotorEncoder[motorSentTo]) > sigMove)  // Moved far enough to be considered significant, mark
		{
			timeLastSigMove[motorIndex]	= time1[T1];
			encLastSigMove[motorIndex] = nMotorEncoder[motorSentTo];

			return wantedPower;
		}

	if ( (time1[T1] - timeLastSigMove[motorIndex]) > wayTooLong )  // Time since last significant move too long, stalled
		{
			PlayTone(650,4);
			return 0;
		}

	if ( (time1[T1] - timeLastSigMove[motorIndex]) > tooLong )  // Time since last significant move too long, stalled
		{
			PlayTone(365,4);
			return wantedPower / 2;
		}

	return wantedPower;	// Haven’t moved far enough yet to be significant but haven’t timed out yet
}
开发者ID:SwerveRobotics,项目名称:ftcrobotc,代码行数:57,代码来源:Mark5IRbasket.c

示例6: soundSpeedDown

/* Shooter speed decrease feedback */
task soundSpeedDown(){
  //        140 = Tempo
  //          5 = Default octave
  //    Quarter = Default note length
  //        10% = Break between notes
  //
  PlayTone(  932,   19); wait1Msec( 214);  // Note(A#, Duration(Eighth))
  PlayTone(  698,   19); wait1Msec( 214);  // Note(F, Duration(Eighth))
}
开发者ID:shivamdaboss,项目名称:750E,代码行数:10,代码来源:CharlesLib.c

示例7: main

task main()
{
	nxtDisplayCenteredTextLine(3, "Servos");
	wait1Msec(750);
	servo [scoopCover] = 230;
	servo [leftLatch] = 252;
	servo [rightLatch] = 10;
	eraseDisplay();
	wait1Msec(750);
	nxtDisplayCenteredTextLine(3, "Lift 1");
	nxtDisplayCenteredTextLine(5, "Orange stops");
	while (nNxtButtonPressed != 3)
	{
		motor [leftLift] = -50;
	}
	while (nNxtButtonPressed != (-1))
	{
	}
	motor [leftLift] = 0;
	eraseDisplay();
	wait1Msec(750);
	nxtDisplayCenteredTextLine(3, "Lift 2");
	nxtDisplayCenteredTextLine(5, "Orange stops");
	while (nNxtButtonPressed != 3)
	{
		motor [rightLift] = -50;
	}
	while (nNxtButtonPressed != (-1))
	{
	}
	motor [rightLift] = 0;
	eraseDisplay();
	wait1Msec(750);
	nxtDisplayCenteredTextLine(3, "Arm");
	nxtDisplayCenteredTextLine(5, "Orange stops");
	while (nNxtButtonPressed != 3)
	{
		motor [arm] = -15;
	}
	if (nNxtButtonPressed == 3) {
		while (nNxtButtonPressed != (-1))
		{
		}
		motor [arm] = 0;
		eraseDisplay();
	}
	nxtDisplayCenteredTextLine(3, "Stored.");
	PlayTone (1000, 70);
	wait1Msec (1000);
	PlayTone (1000, 70);
	wait1Msec (1000);
}
开发者ID:coder-bot,项目名称:ftc5602-code,代码行数:52,代码来源:Storage.c

示例8: Cocacola

// All done tones.
void Cocacola()
{
  //        125 = Tempo
  //          5 = Default octave
  //    Quarter = Default note length
  //        10% = Break between notes
  //

  PlayTone(  988,   22); wait1Msec( 240);  // Note(E6, Duration(Eighth))
  PlayTone( 1320,   22); wait1Msec( 240);  // Note(A6, Duration(Eighth))
  PlayTone( 1109,   43); wait1Msec( 480);  // Note(F#6)
  PlayTone(  880,   43); wait1Msec( 480);  // Note(D6)
  PlayTone(    0,   86); wait1Msec( 960);  // Note(Rest, Duration(Half))
  return;
}
开发者ID:OutlawsRobotics,项目名称:2014ftc,代码行数:16,代码来源:common6819.c

示例9: swapJoys

void swapJoys()
{
  motor[leftMotor] = 0;
  motor[rightMotor] = 0;
  joySwap = !joySwap;
  PlayTone(784, 50);
}
开发者ID:jjkoletar,项目名称:FTC-4140-FishInTheBoat,代码行数:7,代码来源:FITBIncludes.c

示例10: NavigateByTachometer

task NavigateByTachometer()
{
     tnFlags flags = tnFlagsReadOnly;
     ResetAllTachoCounts(flags.leftMotor);
     ResetAllTachoCounts(flags.rightMotor);
     unsigned int time;
     unsigned int delta;
     while(true)
     {
          TextOut(0, flags.posLine,
              "P: " + v2AsString(flags.position) +
              "          " , DRAW_OPT_NORMAL);
          TextOut(0, flags.headLine, "H: " +
              NumToStr(flags.heading) +
              "          " , DRAW_OPT_NORMAL);
          time = CurrentTick();
          tnFlags temp = __updateHeadingPosition(flags, time + 50);
          if(temp.convergenceFailure)
              PlayTone(2000, 100);
          else
              flags = temp;
          delta = CurrentTick() - time;
          tnFlagsReadOnly = flags;
          if(delta < 25)
              Wait(25 - delta);

     }
}
开发者ID:FireStormOOO,项目名称:FireStormNXC,代码行数:28,代码来源:TachoNav.c

示例11: turnOnSpot

/*turn on the spot if the timer expires, return false if it could not find another branch*/
bool turnOnSpot(short target, bool greyPatch){

  float cur_compass = compass();

  //start rotating
  stop();
  control(-rotateSpeed, rotateSpeed);

  while(compass() - cur_compass < 390){
    float diff = compass() - cur_compass;
    if(SensorValue[Light] < target && (diff < 180 || diff > 250)){ // ignore the original branch
      time1[T1] = 0;
      PlayTone(1175,20);
      stop();
      adjustCount++;
      return true; // return true if it finds another branch
    }
  }

  // on the endpoint
  stop();
  
  if(!greyPatch){ // if not yet detect a grey patch, turn back
      control(-rotateSpeed, rotateSpeed);
      while(SensorValue[Light] > target){}
      stop();
  }

  return false;
}
开发者ID:jimmycode,项目名称:INB860,代码行数:31,代码来源:E1.c

示例12: navigateToWaypoint

void navigateToWaypoint(float xtarget, float ytarget)
{
    while(!atTarget(xtarget, x) || (!atTarget(ytarget, y)))
    {
        float distance = calcDistance(xtarget, ytarget);
        float angle = calcAngle(xtarget, ytarget);

        float driveDistance = 0; //initialise
        if (distance < stepDistance)
        {
            driveDistance = distance;
        }
        else
        {
            driveDistance = stepDistance;
        }

        // co-ordinate system is different so cos and sin are swapped - take from current location not origin
        float tempWaypointX = x + (driveDistance * cos(angle));
        float tempWaypointY = y + (driveDistance * sin(angle));


        driveToWaypoint(tempWaypointX, tempWaypointY);
        monteCarlo();

        eraseDisplay();
        drawMap();
        drawParticles();
        wait1Msec(100);

    }

    PlayTone(784, 15);
}
开发者ID:giovannic,项目名称:robotics,代码行数:34,代码来源:expMC.c

示例13: F_STATE_LINHA

//************************
// Segue Linha
//************************
void F_STATE_LINHA()
{
  MTASK_SET_RUN(MT_STOP_BUTTON);

  int Error = 0;

  while(ESTADO_IS_CURRENT())
  {
    //=====================================
    int Error = LLreadAverage(S1)-45;

    if(Error ==-45){
      Error = 0;
      PlayTone(200,1);
    }
  	nxtDisplayStringAt(20, 20, "%i",Error);

    motor[motorA]=-20 - Error;
    motor[motorC]=-20 + Error;

    //Se detectou rampa com acceleracao, sobe a rampa
    if(ACCEL_Rampa)ESTADO_SET_TARGET(ST_SOBE);
    //=====================================
  }
}
开发者ID:ivanseidel,项目名称:Robot-Rescue-2011,代码行数:28,代码来源:main-05.c

示例14: initialize

void initialize()
{
  motor[frontLeftWheel] = 0;
  motor[frontRightWheel] = 0;
  motor[backLeftWheel] = 0;
  motor[backRightWheel] = 0;
  motor[leftArm] = 0;
  motor[rightArm] = 0;
  nMotorEncoder[rightArm] = 0;
  //nMotorEncoderTarget[rightArm] = 10;
  servo[leftClaw] = LCLAWOPEN;
  servo[rightClaw] = RCLAWOPEN;

  string BatteryLevel = externalBatteryAvg;

  nxtDisplayCenteredBigTextLine (3, BatteryLevel);

  if(externalBatteryAvg<13000){
    PlayTone(500,10*(13000-externalBatteryAvg));
  }

  wait1Msec(5000);

  nxtDisplayCenteredBigTextLine (5, "Teleop Running.");

}
开发者ID:RMRobotics,项目名称:FTC-2011-12,代码行数:26,代码来源:Teleop.c

示例15: SG

void SG(int samples){

	PlayTone(300,10);
	//De quantos em quantos valores ele ira ler
	if(samples<=100){
		SG_jump=1;
	}else{
		SG_jump=2;
	}
	//Configs: Jump, yScale, EXIT
	eraseDisplay();
	SG_ySpace=0;
	SG_yScale=2;
	SG_update=0;
	SG_exit=0;
	SG_pos=1;
	SG_xSpace=1;
	while(SG_exit==0){
		SG_Button();
		if(SG_update==0){
			eraseDisplay();
			for(int i=1;i<100 && i<samples/SG_jump;i++){
			  nxtDrawRect(i+SG_xSpace, SG_ySpace+AUlt[(i-1)*SG_jump]/SG_yScale,i+1+SG_xSpace,SG_ySpace+AUlt[i*SG_jump]/SG_yScale);
		  }
			SG_Config(0);
		  SG_update=1;
		}
	}
}
开发者ID:ivanseidel,项目名称:Robot-Rescue-2011,代码行数:29,代码来源:INC-ShowGraphic.c


注:本文中的PlayTone函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。