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

📄 checkbuttons.c

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

#include <button.h>





/*
    handleButtonChange

    Called by the button library when the buttons may have changed.
*/

ButtonChangeResult handleButtonChange(uint16 pressed, uint16 changed)
{
#ifdef DEV_BOARD_HS    
    uint16 tmp_set = pressed & changed;
    if (tmp_set & PIO_DEEP_SLEEP_NOW)
    {        
        if (!hsState.turnOffHs)
        {
            /* 
                If on/off button pressed go into deep sleep and 
                ignore the other buttons 
            */
            enterDeepSleepAsap();
            return ButtonChangeStop;
        }
        else
        {
            /* If we're already in deep sleep then wake everything up */
            enterActiveStateAsap();
        }
    }
    else
    {
        /* Only allow wake up if on/ off button pressed */
        if (hsState.turnOffHs)
            return ButtonChangeStop;
    }
#endif

    /* Check for chords first */
    if((pressed & RESET_CONDITION) == RESET_CONDITION &&
        (changed &RESET_CONDITION) != 0)
    {
        if (hsState.connectState != connected)
        {
            resetReq();            
        }
    }

    if((pressed & MUTE_CONDITION) == MUTE_CONDITION && 
       (changed & MUTE_CONDITION) != 0)
    {
        if (hsState.connectState == connected)
        {
            /* Chord is down, and wasn't before */
            muteRequest();
        }
    }
    else
    {
        uint16 new_set = pressed & changed;
        /* Try single buttons */
        if (new_set & PIO_TALK)
        {
            /* Process the talk button press */
            talkButton();
        }
        else if(new_set & PIO_VOLUME_DOWN)
        {
            /* Process the volume DOWN button press */
            onVolumeDown();
        }        
        else if(new_set & PIO_VOLUME_UP)
        {
            /* Process the volume UP button press */
            onVolumeUp();
        }
    }
    return ButtonChangeContinue;
}


⌨️ 快捷键说明

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