⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 on_off.c

📁 蓝牙耳机软件源代码
💻 C
字号:
#include "demohs.h"

#include <batt.h>
#include <pio.h>


/*
    enterDeepSleepAsap
    
    Disconnect everything and disable all you can to enable to chip
    to go into deep sleep as soon as possible
*/
void enterDeepSleepAsap(void)
{    
    hsState.turnOffHs = 1;

    /* Disable battery monitoring completely */
    BattInit(VM_ADC_TEST_A, D_NEVER);

    if (hsState.connectState == idle)
    {
        /* Cancel the flashing LEDs */
        changeFlash();
    }
    else if (hsState.connectState == connectingAsMaster ||
            hsState.connectState == connectingAsSlave ||
            hsState.connectState == pairing)
    {            
        /*
            Check the current state and cancel it
            NOTE this button only works if the headset is not already connected 
            Entering idle state will call changeFlash() and stop the LEDs
        */
        cancelOperation();  

        if (hsState.connectState == pairing)
            hsState.pairingPending = 1;
    }
    else
    {
        /* 
            Reset this flag otherwise the headset will turn off as soon 
            as the AG drops the connections and that can be confusing 
            to the user. This way the headset will go into idle mode 
            and the off button can then be pressed to switch off 
            everything else
        */
        hsState.turnOffHs = 0;
    }
}


/*
    enterActiveStateAsap

    Re-enable everything so headset can operate as before. The flashing LEDs 
    will be re-enabled when the headset changes state.
*/
void enterActiveStateAsap(void)
{
    hsState.turnOffHs = 0;

    /* enable battery monitoring */
    BattInit(VM_ADC_TEST_A, BATT_MONITOR_PERIOD);

    /* Power up into idle mode */
    updateHsConnectState(idle);

    /* 
        If we were in pairing mode before the power down go back 
        into it as all pairing info has been reset anyway. Otherwise 
        become connectable.
    */
    if (hsState.pairingPending)
        pairButton();
    else
        talkButton();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -