📄 volume.c
字号:
/*
Volume.c
Handles the volume control for the headset These functions can be
called either when a volume button is pressed or when a VGS
command is received.
*/
#include "demohs.h"
#include "hal.h"
#include <message.h>
#include <framework.h>
/*
sendVolume
Internal function to tell the framework to change the volume and
communicate this to the Audio Gateway (AG).
*/
static void sendVolume(int8 inc, uint8 gn)
{
MAKE_MSG(HS_VGS_REQ); /* Create a message primitive */
msg->increment = (int8) inc; /* populate the message */
msg->gain = gn; /* populate the message */
putMsg(msg); /* put the message in the sceduler queue */
}
/*
sendInitialVolume
Sends the initial volume of the headset on connection
establishment. See demohs.h for default values.
*/
void sendInitialVolume()
{
sendVolume(VG_ZERO_INCREMENT, VG_ZERO_GAIN);
}
/*
onVolumeUp
Called by checkButtons whenever the volume up button is seen to
have changed state.
*/
void onVolumeUp()
{
sendVolume(VG_VOLUME_UP, VG_ZERO_GAIN);
}
/*
onVolumeDown
Called by checkButtons whenever the volume down button is seen to
have changed state.
*/
void onVolumeDown()
{
sendVolume(VG_VOLUME_DOWN, VG_ZERO_GAIN);
}
/*
vgsInd
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 vgsInd(const HS_VGS_IND_T * ind)
{
HALsetVolume(ind->gain) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -