Skip to content

Commit

Permalink
samples: subsys: usb: audio: headset: Add volume control case
Browse files Browse the repository at this point in the history
Add sample code for getting volume to headset sample and
headphone_microphone sample

Signed-off-by: Saw Xu <Saw1993@126.com>
  • Loading branch information
SawXu committed Aug 1, 2023
1 parent d16ded2 commit 41980c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions samples/subsys/usb/audio/headphones_microphone/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ static void data_received(const struct device *dev,
static void feature_update(const struct device *dev,
const struct usb_audio_fu_evt *evt)
{
int16_t volume = 0;
LOG_DBG("Control selector %d for channel %d updated",
evt->cs, evt->channel);
switch (evt->cs) {
case USB_AUDIO_FU_MUTE_CONTROL:
break;
case USB_AUDIO_FU_VOLUME_CONTROL:
volume = *((int16_t *)(evt->val));
LOG_INF("set volume: %d", volume);
break;
default:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions samples/subsys/usb/audio/headset/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ static void data_received(const struct device *dev,
static void feature_update(const struct device *dev,
const struct usb_audio_fu_evt *evt)
{
int16_t volume = 0;
LOG_DBG("Control selector %d for channel %d updated",
evt->cs, evt->channel);
switch (evt->cs) {
case USB_AUDIO_FU_MUTE_CONTROL:
break;
case USB_AUDIO_FU_VOLUME_CONTROL:
volume = *((int16_t *)(evt->val));
LOG_INF("set volume: %d", volume);
break;
default:
break;
}
Expand Down

0 comments on commit 41980c2

Please sign in to comment.