Rename tune_control_s strength to volume to match Nuttx and Linux standard nomenclature for audio (loudness) control.

This commit is contained in:
mcsauder
2019-02-19 10:07:53 +01:00
committed by Beat Küng
parent 57dd1b7b45
commit 31f23c1e76
7 changed files with 47 additions and 46 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ int test_tone(int argc, char *argv[])
if (argc == 1) {
PX4_INFO("Volume silenced for testing predefined tunes 0-20.");
tune_control.strength = 0;
tune_control.volume = tune_control_s::VOLUME_LEVEL_MIN;
for (size_t i = 0; i <= 20; i++) {
tune_control.tune_id = i;
@@ -80,13 +80,13 @@ int test_tone(int argc, char *argv[])
}
if (argc == 3) {
int volume = 40;
int volume = tune_control_s::VOLUME_LEVEL_DEFAULT;
Tunes tunes{};
tunes.set_string(argv[2], volume);
PX4_INFO("Custom tune.");
}
tune_control.strength = 40;
tune_control.volume = tune_control_s::VOLUME_LEVEL_DEFAULT;
result = orb_publish(ORB_ID(tune_control), tune_control_pub, &tune_control);
orb_unadvertise(tune_control_pub);
+17 -15
View File
@@ -86,11 +86,11 @@ $ tune_control play -t 2
)DESCR_STR");
PRINT_MODULE_USAGE_NAME("tune_control", "system");
PRINT_MODULE_USAGE_COMMAND_DESCR("play","Play system tune, tone, or melody");
PRINT_MODULE_USAGE_COMMAND_DESCR("play","Play system tune or single note.");
PRINT_MODULE_USAGE_PARAM_INT('t', 1, 1, 21, "Play predefined system tune", true);
PRINT_MODULE_USAGE_PARAM_INT('f', -1, 0, 22, "Frequency of tone in Hz (0-22kHz)", true);
PRINT_MODULE_USAGE_PARAM_INT('d', -1, 1, 21, "Duration of tone in us", true);
PRINT_MODULE_USAGE_PARAM_INT('s', 40, 0, 100, "Strength of tone (0-100)", true);
PRINT_MODULE_USAGE_PARAM_INT('f', -1, 0, 22, "Frequency of note in Hz (0-22kHz)", true);
PRINT_MODULE_USAGE_PARAM_INT('d', -1, 1, 21, "Duration of note in us", true);
PRINT_MODULE_USAGE_PARAM_INT('s', 40, 0, 100, "Volume level (loudness) of the note (0-100)", true);
PRINT_MODULE_USAGE_PARAM_STRING('m', nullptr, R"(<string> - e.g. "MFT200e8a8a")",
"Melody in string form", true);
PRINT_MODULE_USAGE_COMMAND_DESCR("libtest","Test library");
@@ -123,7 +123,7 @@ tune_control_main(int argc, char *argv[])
unsigned int value;
tune_control_s tune_control = {};
tune_control.tune_id = 0;
tune_control.strength = tune_control_s::STRENGTH_NORMAL;
tune_control.volume = tune_control_s::VOLUME_LEVEL_DEFAULT;
while ((ch = px4_getopt(argc, argv, "f:d:t:m:s:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
@@ -172,11 +172,11 @@ tune_control_main(int argc, char *argv[])
case 's':
value = (uint8_t)(strtol(myoptarg, nullptr, 0));
if (value > 0 && value < 100) {
tune_control.strength = value;
if (value <= tune_control_s::VOLUME_LEVEL_MAX) {
tune_control.volume = value;
} else {
tune_control.strength = tune_control_s::STRENGTH_NORMAL;
tune_control.volume = tune_control_s::VOLUME_LEVEL_MAX;
}
break;
@@ -194,20 +194,20 @@ tune_control_main(int argc, char *argv[])
}
unsigned frequency, duration, silence;
uint8_t strength;
uint8_t volume;
int exit_counter = 0;
if (!strcmp(argv[myoptind], "play")) {
if (string_input) {
PX4_INFO("Start playback...");
tunes.set_string(tune_string, tune_control.strength);
tunes.set_string(tune_string, tune_control.volume);
while (tunes.get_next_note(frequency, duration, silence, strength) > 0) {
while (tunes.get_next_note(frequency, duration, silence, volume) > 0) {
tune_control.tune_id = 0;
tune_control.frequency = (uint16_t)frequency;
tune_control.duration = (uint32_t)duration;
tune_control.silence = (uint32_t)silence;
tune_control.strength = (uint8_t)strength;
tune_control.volume = (uint8_t)volume;
publish_tune_control(tune_control);
px4_usleep(duration + silence);
exit_counter++;
@@ -236,9 +236,10 @@ tune_control_main(int argc, char *argv[])
PX4_WARN("Tune ID not recognized.");
}
while (tunes.get_next_note(frequency, duration, silence, strength) > 0) {
PX4_INFO("frequency: %d, duration %d, silence %d, strength%d",
frequency, duration, silence, strength);
while (tunes.get_next_note(frequency, duration, silence, volume) > 0) {
PX4_INFO("frequency: %d, duration %d, silence %d, volume %d",
frequency, duration, silence, volume);
px4_usleep(500000);
exit_counter++;
@@ -256,6 +257,7 @@ tune_control_main(int argc, char *argv[])
tune_control.silence = 0;
tune_control.tune_override = true;
publish_tune_control(tune_control);
// We wait the maximum update interval to ensure
// The stop will not be overwritten
px4_usleep(tunes.get_maximum_update_interval());