示例#1
0
void check_button(void)
{
    signed short interval = -1;        
 
	if(!(PA_IDR & 0x08))//GPIO_ReadInputPin(BUTTON_KEY_PORT,(GPIO_Pin_TypeDef)BUTTON_KEY_PINS))
	{
	  _default_start_time = get_time() + 1;
      set_long_press_flag();
	}
	else
	{
	  interval = get_time() + 1 - _default_start_time;
	  if ( (_default_start_time != 0) && (interval > 10) && (interval < ShutDown_TimeOut)){
		switch(status->deviceStatus.mode)
		{
		case MODE_CLOSE:
		  status->deviceStatus.mode = MODE_SMART;
          startMotorOn();
          statusSmartMode(SMART_ON);
		  BuzzerStart(POLY_ON);
                  
		  break;
		case MODE_FLY:
		  status->deviceStatus.mode = MODE_SLEEP;
          statusSmartMode(SMART_OFF);
          changeMotorPositon(MOTOR_SLEEP);
                  ledSleepMode(SLEEP_ON);
		  BuzzerStart(MONO);
                  
		  break;
		case MODE_SMART:
		  status->deviceStatus.mode = MODE_FLY;
          statusSmartMode(SMART_OFF);
          changeMotorPositon(MOTOR_FLY);
          LED_GREEN_ON();
		  BuzzerStart(MONO);
                  
		  break;
		case MODE_SLEEP:
		  status->deviceStatus.mode = MODE_SMART;
          statusSmartMode(SMART_ON);
		  BuzzerStart(MONO);                 
		  break;
		default:
		  break;
		}
	  }
	  _default_start_time = 0;
	  reset_long_press_flag();
	}
	return;
}
示例#2
0
文件: buz.c 项目: wantf/C
//called in 5ms interrupt
void Buzzer5MSTask(void)
{
		if( (u8OutState&BuzWork) == 0) 
		{
				return;
		}
		if( u8BzrOn5MSCnt>0 )	u8BzrOn5MSCnt--;
		else
		{
				SetBuzzerEnOff();
				if( u8BzrOff5MSCnt>0 )u8BzrOff5MSCnt--;
				else if( u8BzrType<=BZR_DOWN_3 )
				{
						u8BzrFrqBuf = u16BuzSeqTab[u8BzrType-1][u8BuzStep+1];
						if(u8BzrFrqBuf != BZR_OFF_SIGN)
						{
								u8BuzStep++;

								u8BzrOn5MSCnt = BZR_Time_50ms;
								u8BzrOff5MSCnt = BZR_Time_75ms;
								BuzzerStart();
						}
						else if( u8BzrLastTim>0 )	u8BzrLastTim--;
						else	BuzzerStop();						
				}
				else if( u8BzrLastTim>0 )	u8BzrLastTim--;
				else	BuzzerStop();
		}
}
示例#3
0
int buzz(vol , bt ,bwat){  //bt;ブザーならすじかん,bwat;ブザーとめたあとまつじかん
      BuzzerSet( 90 , vol );   // 近年の流行りはピッチ90だと聞いている
	  BuzzerStart();
	  Wait(bt);
	  BuzzerStop();
	  Wait(bwat);
}
示例#4
0
void finish(){
	BuzzerSet(120,100);
	BuzzerStart();
	Wait(750);
	BuzzerStop();

}
示例#5
0
int main(void)
{
	const unsigned short MainCycle = 60;
	Init(MainCycle);

	unsigned short bw;

	Wait(1000);
	int i;
	for (i = 0; i<N; i++){
		forward(1);
		Wait(1000);
		bw = ADRead(0);
		if (bw >600){
			break;
		} else {
			;
		}
	}
		BuzzerSet(100,100);
		BuzzerStart();




	return 0;
}
示例#6
0
void buzzer(void){
    BuzzerSet(120, 100);
    BuzzerStart();
    Wait(3000);
    BuzzerStop();


}
示例#7
0
void _button_timeout_hander(void)
{
  _default_start_time = 0;
  status->deviceStatus.mode = MODE_CLOSE;
  LED_All_OFF();
  statusSmartMode(SMART_OFF);
  changeMotorPositon(MOTOR_HALT);
  BuzzerStart(POLY_OFF);
}
示例#8
0
void play(int pitch)
{
    if (pitch==NN) {
        BuzzerStop();
        Wait(DURATION+PAUSE);
    } else {
        BuzzerSet(pitch, VOL);
        BuzzerStart();
        Wait(DURATION+PAUSE);
        BuzzerStop();
    }
}
示例#9
0
void play(int pitch)
{
	if (pitch == NN) {
		BuzzerStop();
		Wait(duration + pause);
	} else {
		BuzzerSet(pitch, VOL);
		BuzzerStart();
		Wait(duration);
		BuzzerStop();
		Wait(pause);
	}
}
示例#10
0
文件: buz.c 项目: wantf/C
void buz(u8 buzIndex)
{
//	return;
		if( ((u8OutState&BuzWork)==BuzWork) && (buzIndex>BZR_DOWN_3)&& (u8BzrType<=BZR_DOWN_3) ) return;
		u8BzrType = buzIndex;
		u8BuzStep = 0;		
		u8OutState |= BuzWork;
		if( u8BzrType <= BZR_DOWN_3 )	u8BzrFrqBuf = u16BuzSeqTab[u8BzrType-1][u8BuzStep];
		else u8BzrFrqBuf = u8SingleFrq[u8BzrType-BZR_A];

		u8BzrOn5MSCnt = BZR_Time_40ms;
		u8BzrOff5MSCnt = BZR_Time_75ms;

		u8BzrLastTim = BZR_OFF_LST_1s25;
		BuzzerStart();
}
示例#11
0
int main(void)
{
	const unsigned short MainCycle = 60;
	Init(MainCycle);


    int i;
    for(i=0;i<10;i++){
	step();
	if(ADRead(0)>256){
	break;
    }


    }

BuzzerSet(100,100);
BuzzerStart();


    return 0;
}
示例#12
0
int main(void)
{
	const unsigned short MainCycle = 60;
	Init(MainCycle);
	unsigned short x;
    int i;
    for(i=0;i<10;i++){
    	step(EDGE);
    	stop();
    	x=ADRead(1);
    	if (x>500){
    		break;
    	}else{
    		;
    	}
    }
    BuzzerSet(179,100);
    BuzzerStart();
    Wait(750);
    BuzzerStop();

	return 0;
}
示例#13
0
int main(void)
{
	const unsigned short MainCycle = 60;
	Init(MainCycle);



    int i;
    unsigned short bw;
    for(i=0; i<N; i++){
      step();
      bw = ADRead(0);
       if (bw>200){
    	  break;

       }

    }
    BuzzerSet(120,100);
    BuzzerStart();
    Wait(3000);
    BuzzerStop();
	return 0;
}