@ -86,11 +86,11 @@ $ tune_control play -t 2
@@ -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 to ne in Hz (0-22kHz) " , true ) ;
PRINT_MODULE_USAGE_PARAM_INT ( ' d ' , - 1 , 1 , 21 , " Duration of to ne in us " , true ) ;
PRINT_MODULE_USAGE_PARAM_INT ( ' s ' , 40 , 0 , 100 , " Strength of ton e (0-100)" , true ) ;
PRINT_MODULE_USAGE_PARAM_INT ( ' f ' , - 1 , 0 , 22 , " Frequency of not e in Hz (0-22kHz) " , true ) ;
PRINT_MODULE_USAGE_PARAM_INT ( ' d ' , - 1 , 1 , 21 , " Duration of not e in us " , true ) ;
PRINT_MODULE_USAGE_PARAM_INT ( ' s ' , 40 , 0 , 100 , " Volume level (loudness) of the not e (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[])
@@ -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[])
@@ -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[])
@@ -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[])
@@ -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[])
@@ -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 ( ) ) ;