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

📄 volume.c

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

#include <message.h>


/*
    sendVolume

    Internal function to tell the framework to change the volume and
    communicate this to the Audio Gateway (AG).
*/
static void sendVolume(int8_t  inc, uint8_t gn)
{
    /* Send a volume request to the framework lib */
    MAKE_MSG(HS_VGS_REQ);
    msg->increment = (int8) inc;
    msg->gain = gn;
    putMsg(msg);
}


/*
    onVolumeUp

    Called by checkButtons whenever the volume up button is seen to
    have changed state.
*/
static void onVolumeUp(void)
{
    sendVolume(VGS_VOLUME_UP, VGS_ZERO_GAIN);
}


/*
    onVolumeDown 

    Called by checkButtons whenever the volume down button is seen to
    have changed state.
*/
static void onVolumeDown(void)
{
    sendVolume(VGS_VOLUME_DOWN, VGS_ZERO_GAIN);
}


/*
    hfSendInitialVolume

    Sends the initial volume of the handsfree on connection establishment.
*/
void hfSendInitialVolume(void)
{
    sendVolume(VGS_ZERO_INCREMENT, VGS_ZERO_GAIN);
}


/*
    volumeReqAction

    Used for interfacing with the GUI, interprets the request and
    sends a volume command.
*/
void volumeReqAction(int8 increment, uint8 gain)
{
    if (increment == 1)    
        onVolumeUp();    
    else if (increment == (int8 )-1)    
        onVolumeDown();    
    else    
        sendVolume(0, gain);
}


/*
    hfVolumeInd

    Called by the headsetframework whenever a VGS is received.  This
    may be as a result of us sending a VGS_REQ because the user
    pressed a volume button.
 
    Note that we will always get a VGS_IND even if we are already at
    minimum or maximum volume.  This is to allow us to give a warning
    beep.
*/
void hfVolumeInd(const HS_VGS_IND_T * ind)
{
     /*set the volume locally */
    hfHalSetSpeakerGain(ind->gain);

    /* Tell the interface the volume has changed */
    handleVolInd(ind->gain);
}

⌨️ 快捷键说明

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