attenuator: rename functions to make them more descriptive

This commit is contained in:
Harald Welte 2021-05-06 08:20:03 +02:00
parent 6284afc23d
commit 5d2e32e4b8
3 changed files with 10 additions and 10 deletions

View File

@ -75,7 +75,7 @@ static void _attenuator_stage_set(uint8_t channel, uint8_t stage, uint8_t val_qd
* \param stage Attenuator stage (0..1) * \param stage Attenuator stage (0..1)
* \param value in quarter-dB (0..124) * \param value in quarter-dB (0..124)
*/ */
int attenuator_set(uint8_t channel, uint8_t stage, uint8_t val_qdb) int attenuator_stage_set(uint8_t channel, uint8_t stage, uint8_t val_qdb)
{ {
uint8_t val = val_qdb/4; /* whole dB for this attenuator */ uint8_t val = val_qdb/4; /* whole dB for this attenuator */
@ -99,7 +99,7 @@ int attenuator_set(uint8_t channel, uint8_t stage, uint8_t val_qdb)
} }
/* get current attenuator value in quarter-dB */ /* get current attenuator value in quarter-dB */
int attenuator_get(uint8_t channel, uint8_t stage, enum attenuator_value av) int attenuator_stage_get(uint8_t channel, uint8_t stage, enum attenuator_value av)
{ {
if (!g_att_cfg) if (!g_att_cfg)
return -ENODEV; return -ENODEV;

View File

@ -39,7 +39,7 @@ struct attenuator_state {
} value_qdB; } value_qdB;
}; };
int attenuator_set(uint8_t channel, uint8_t stage, uint8_t val_qdb); int attenuator_stage_set(uint8_t channel, uint8_t stage, uint8_t val_qdb);
int attenuator_get(uint8_t channel, uint8_t stage, enum attenuator_value av); int attenuator_stage_get(uint8_t channel, uint8_t stage, enum attenuator_value av);
void attenuator_init(const struct attenuator_cfg *cfg, void attenuator_init(const struct attenuator_cfg *cfg,
struct attenuator_state **state); struct attenuator_state **state);

View File

@ -189,7 +189,7 @@ DEFUN(att_show, att_show_cmd, "show", "Show state of all attenuators")
int sum_qdb = 0; int sum_qdb = 0;
for (stage = 0; stage < ARRAY_SIZE(stage_qdb); stage++) { for (stage = 0; stage < ARRAY_SIZE(stage_qdb); stage++) {
stage_qdb[stage] = attenuator_get(channel, stage, ATT_VAL_CURRENT); stage_qdb[stage] = attenuator_stage_get(channel, stage, ATT_VAL_CURRENT);
sum_qdb += stage_qdb[stage]; sum_qdb += stage_qdb[stage];
} }
printf("Channel %02u: Stage1 %02d dB, Stage2 %02d dB, Sum %02d dB\r\n", printf("Channel %02u: Stage1 %02d dB, Stage2 %02d dB, Sum %02d dB\r\n",
@ -213,7 +213,7 @@ DEFUN(att_set, att_set_cmd, "set",
printf("Setting attenuator channel %d stage %d to %d dB...\r\n", channel, stage, dB); printf("Setting attenuator channel %d stage %d to %d dB...\r\n", channel, stage, dB);
rc = attenuator_set(channel, stage, dB*4); rc = attenuator_stage_set(channel, stage, dB*4);
if (rc < 0) if (rc < 0)
printf("Error setting attenuator: %d\r\n", rc); printf("Error setting attenuator: %d\r\n", rc);
} }
@ -240,7 +240,7 @@ DEFUN(interact, interact_cmd, "interact", "Enter interactive single-key mode")
case '1': case '2': case '3': case '4': /* channel number */ case '1': case '2': case '3': case '4': /* channel number */
g_chan = ch - '1'; g_chan = ch - '1';
g_stage = 0; g_stage = 0;
g_val = attenuator_get(g_chan, g_stage, ATT_VAL_CURRENT); g_val = attenuator_stage_get(g_chan, g_stage, ATT_VAL_CURRENT);
break; break;
case '0': /* set to 0dB */ case '0': /* set to 0dB */
g_val = 0; g_val = 0;
@ -259,17 +259,17 @@ DEFUN(interact, interact_cmd, "interact", "Enter interactive single-key mode")
case 'a': /* stage 0 */ case 'a': /* stage 0 */
if (g_stage != 0) { if (g_stage != 0) {
g_stage = 0; g_stage = 0;
g_val = attenuator_get(g_chan, g_stage, ATT_VAL_CURRENT); g_val = attenuator_stage_get(g_chan, g_stage, ATT_VAL_CURRENT);
} }
break; break;
case 'b': /* stage 1 */ case 'b': /* stage 1 */
if (g_stage != 1) { if (g_stage != 1) {
g_stage = 1; g_stage = 1;
g_val = attenuator_get(g_chan, g_stage, ATT_VAL_CURRENT); g_val = attenuator_stage_get(g_chan, g_stage, ATT_VAL_CURRENT);
} }
break; break;
} }
rc = attenuator_set(g_chan, g_stage, g_val*4); rc = attenuator_stage_set(g_chan, g_stage, g_val*4);
if (rc < 0) if (rc < 0)
printf("Error setting attenuator: %d\r\n", rc); printf("Error setting attenuator: %d\r\n", rc);
} }