Skip to content

Commit

Permalink
Added shell command for gain
Browse files Browse the repository at this point in the history
  • Loading branch information
ArekBalysNordic committed Jan 30, 2024
1 parent 87355af commit de0c79f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions applications/nrf5340_audio/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ CONFIG_KERNEL_SHELL=y
CONFIG_USE_SEGGER_RTT=y
## Disable logs on RTT
CONFIG_SHELL_RTT_INIT_LOG_LEVEL_NONE=y
CONFIG_SHELL_BACKEND_RTT=y
CONFIG_SHELL_BACKEND_SERIAL=n
CONFIG_SHELL_BACKEND_RTT=n
CONFIG_SHELL_BACKEND_SERIAL=y
CONFIG_SHELL_VT100_COLORS=y
CONFIG_SHELL_STACK_SIZE=1024
CONFIG_SHELL_CMD_BUFF_SIZE=128
Expand Down
27 changes: 27 additions & 0 deletions applications/nrf5340_audio/src/modules/hw_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,37 @@ static int cmd_input(const struct shell *shell, size_t argc, char **argv)
return 0;
}

static int cmd_gain(const struct shell *shell, size_t argc, char **argv)
{
uint8_t gain = 0;

if (argc == 1) {
shell_print(shell, "Current gain %u dB", gain);
return 0;
}

if (argc != 2) {
shell_error(shell, "Only one argument required, provided: %d", argc);
return -EINVAL;
}

if (!isdigit((int)argv[1][0])) {
shell_error(shell, "Supplied argument is not numeric");
return -EINVAL;
}

gain = strtoul(argv[1], NULL, BASE_10);

shell_print(shell, "Selected gain: %u dB", gain);

return 0;
}

SHELL_STATIC_SUBCMD_SET_CREATE(hw_codec_cmd,
SHELL_COND_CMD(CONFIG_SHELL, input, NULL,
" Select input\n\t0: LINE_IN\n\t\t1: PDM_MIC",
cmd_input),
SHELL_COND_CMD(CONFIG_SHELL, gain, NULL, " Set gain [dB]", cmd_gain),
SHELL_SUBCMD_SET_END);

SHELL_CMD_REGISTER(hw_codec, &hw_codec_cmd, "Change settings on HW codec", NULL);

0 comments on commit de0c79f

Please sign in to comment.