Esempio n. 1
0
/*********************************************************************
函数名称: void Buzzer_PowerOn(void)
功    能: 上电短响两声
说    明: 
入口参数: 
返 回 值: 
设    计: 丛海旭               时    间: 2013-12-11
修    改:                      时    间: 
*********************************************************************/
void Buzzer_PowerOn(void)
{
    BuzzerOn();
    delay(40);
    BuzzerOff();
    delay(15);

    BuzzerOn();
    delay(40);
    BuzzerOff();
}
Esempio n. 2
0
void ShortBeep(){
  BeepCount=0;
  
  if(BeepID!=0){
    ReleaseTimer(BeepID);  //強迫停止..否則原本的若還在響..將會佔用1個TIMER不放
    BeepID=0;
    BuzzerOff();  //關閉並省電
  }
  if (BeepCount2>=BeepTimes){
    ReleaseTimer(BeepID2);
    BeepID2=0;
    BuzzerOff();  //關閉並省電
  }else{
    BuzzerOn();
    BeepID=TakeTimer(RANDOM,1500,SINGLE,BuzzerOff);
  }
  BeepCount2++; 
}
Esempio n. 3
0
void OPBuzzer(void)
{
    if (gb_BuzzerAlwaysOnFlg == true)
    {
        BuzzerOn();
    }
    else if (u8BuzerMode != 0)
    {
        BuzzerOn();
        if (gu32_Sys10ms - u32BuzerStarTime > u32BuzerHoldTime)
        {
            BuzzerOff();
            u8BuzerMode = 0;
        }
    }
    else if (gb_BatchOverFlg || gb_Error9Flg || ((gb_OverFlg || gb_UnderFlg) && gb_RunFlg))
        BuzzerOn();
    else
        BuzzerOff();
}
Esempio n. 4
0
void ShortBeepSetTimes(unsigned char Times){
  BeepTimes=Times;
  if(BeepID2!=0)ReleaseTimer(BeepID2); //強迫停止
  if(BeepID!=0)ReleaseTimer(BeepID);  //強迫停止
  BuzzerOff();
  BeepID2=0;
  BeepID=0;
  BeepCount2=0;
  BeepCount=0;
  BeepID2=TakeTimer(RANDOM,3000,0,ShortBeep);  //9830=32768/3
}
Esempio n. 5
0
void Beep1Sec(){
  
  if(BeepID!=0){
    ReleaseTimer(BeepID);  //強迫停止..否則原本的若還在響..將會佔用1個TIMER不放
    BeepID=0;
    BuzzerOff();  //關閉並省電
  }
  
  BuzzerOn();
  BeepID=TakeTimer(RANDOM,3000,SINGLE,BuzzerOff);
}
Esempio n. 6
0
void BuzzerS(void)
{
    BuzzerOn();
    delay(200);
    BuzzerOff();
}
Esempio n. 7
0
void MainLoop(uint8_t capPushA, uint8_t capPushB, uint16_t tempSensor, uint16_t battery) {
    if(statusChange) { // Don't detect cap touch when the LED status has just changed
        capPushA = 0;
        capPushB = 0;
        statusChange--;
    }
    if (battery < BATTERY_LOW_THRESH) {
        //About 2.5v
        if (batteryLowCounter < 200)
            batteryLowCounter++;
    }
    if ((capPushA == 1) || (capPushB == 1)) {
        beepTime = 0; // Stop beeping the buzzer when the user touches either of the capacitive touch buttons
        if (noButtonPressTime < STATUS_CANCEL_THRESH) { // Was a cap touch button pressed recently ?
            // If yes, this press must have been to increase (button A) or decrease (button B) the whistle count
            if (capPushA == 1) {
                if (whistleCount < MAX_WHISTLE_COUNT && batteryLowCounter < BATTERY_LOW_COUNT_THRESH) {
                    whistleCount++; // increase the target whistle count
                }
            } else if (capPushB == 1) {
                if (whistleCount > 0) {
                    whistleCount--; // decrease the target whistle count
                }
            }
        }
        ShowStatus(); // When a cap touch button is pressed, show status (number of whistles left) immediately
        noButtonPressTime = 0; // Keep track of how much time since a cap touch button was pressed
    } else {
        if (noButtonPressTime < 250)
            noButtonPressTime++;
        // After showing the status, blink the LED and shut it off to conserve power
        if ((noButtonPressTime > STATUS_BLINK_THRESH
                && noButtonPressTime < STATUS_CANCEL_THRESH2)
                || noButtonPressTime < STATUS_CANCEL_THRESH) {
            ShowStatus();
        } else {
            CancelStatus();
        }
    }
    time++;
    downSample++;
    if (downSample == TEMP_DOWNSAMPLE_FACTOR) {
        downSample = 0;
        uint16_t val = tempSensor; // Process thermistor samples once every ~0.25 sec

        uint32_t val_lo = mafilt(tempLow, val, TEMP_LOW_PASS_FILTER_N); // low-pass filter the thermistor (ADC) readings to suppress noise
        //sb(val_lo >> 4);
        if(val_lo > OVER_TEMP_THRESH_HI)
            overTemp = 1;
        else if(val_lo < OVER_TEMP_THRESH_LO)
            overTemp = 0;

        int32_t val_hi = (TEMP_HI_PASS_FILTER_N) * val_lo - mafilt(tempHi, val_lo, TEMP_HI_PASS_FILTER_N); // high-pass filter to detect only changes in temperature
        if (val > MIN_TEMP_WHISTLE_DETECTION && val_hi < -MIN_TEMP_FALL_WHISTLE_DETECTION) {
            // detect whistle when the temperature is high (> ~100C), and the temperature has sharply fallen
            whistleOneCount++;
        } else {
            if (whistleOneCount > MIN_TEMP_FALL_DURATION_WHISTLE_DETECTION) { // See if the temperature fell for a duration greater than 3 secs before rising again
                // Whistle detection complete !
                //sb(128);
                if (whistleCount > 0) { 
                    whistleCount--;
                    if (whistleCount == 0) { // Number of whistles == Target number of whistles ?
                        beepTime = WHISTLE_BEEP_TIME; // Start beeping the buzzer for 45 seconds or until the user touches a cap touch button
                    }
                    statusChange += 6; // to prevent false positives in cap touch after a whistle is detected and the LEDs are flashed
                }
                ShowStatus(); // after each whistle, show how many whistles are left on the LEDs
                noButtonPressTime = 0; // To blink the LED, invoke the same code that shows status when a cap button is touched
            }
            whistleOneCount = 0;
        }
        //sb(10);
    }

    if (beepTime > 0) {
        if( (beepTime & 0x0F) > 10 ) {
            BuzzerOn(); // Alternately beep the buzzer
        } else {
            BuzzerOff();
        }
        beepTime--;
    } else {
        BuzzerOff();
    }

    if(overTemp)
        BuzzerOn();

    //sb(battery >> 2);
    //sb(tempSensor >> 2);

}