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

📄 piohshf_buttons.c

📁 蓝牙HANDFREE软件源代码
💻 C
字号:
#include "piohshf_private.h"
#include "handsfree.h"

#include <button.h>
#include <print.h>



#define cancelButtonTimer() (void) 0


/*
    handleButtonChange

    Called by the button library when the buttons may have changed.
*/
ButtonChangeResult handleButtonChange(uint16 pressed, uint16 changed)
{
	
    /* Firstly check for chords being pressed */
    if((pressed & PIOHSHF_PAIR_CHORD) == PIOHSHF_PAIR_CHORD &&
       (changed & PIOHSHF_PAIR_CHORD) != 0)
    {
        cancelButtonTimer();
        if (!isLocalStateConnected())
        {
            /* Enter or exit pairing mode */
            pioHsHfPairButton();
            return ButtonChangeContinue;
        }
    }

    if ((pressed & PIOHSHF_REDIAL_CHORD) == PIOHSHF_REDIAL_CHORD &&
        (changed & PIOHSHF_REDIAL_CHORD) != 0)
    {
        if (isLocalStateConnected())
        {
            PRINT(("Number redial\n"));
            lastNumberRedialAction();
            return ButtonChangeContinue;
        }
    }

    if ((pressed & PIOHSHF_MUTE_CHORD) == PIOHSHF_MUTE_CHORD && 
       (changed & PIOHSHF_MUTE_CHORD) != 0)
    {
        cancelButtonTimer();
        if (HFstate.connectState == scoConnected)
        {
            /* Try to mute/unmute mic only if we're already connected */
            PRINT(("Mute\n"));
            hfToggleMuteMicAction();
        }
    }
    else
    {
        uint16 new_set = pressed & changed;

        if (new_set & BTN_CALL_ACCEPT && ((changed & BTN_CALL_ACCEPT) != 0))
        {
            /* Process the call accept button press */
            pioHshfCallAcceptButton();
        }
        else if (new_set & BTN_CALL_REJECT && ((changed & BTN_CALL_REJECT) != 0))
        {
            cancelButtonTimer();
            /* Process the call reject button press */
            PRINT(("Call Reject\n"));
            pioHshfCallRejectButton();
        }
        else if (new_set & BTN_VOLUME_DOWN)
        {
            cancelButtonTimer();
            /* Process the volume down button press */
            PRINT(("Volume down\n"));
            pioHshfVolumeDownButton();
        }
        else if(new_set & BTN_VOLUME_UP)
        {
            cancelButtonTimer();
            /* Process the volume up button press */
            PRINT(("Volume up\n"));
            pioHshfVolumeUpButton();
        }
    }

    return ButtonChangeContinue;
}


⌨️ 快捷键说明

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