Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
f7aad844
Commit
f7aad844
authored
8 years ago
by
Simone Guscetti
Committed by
Daniel Agar
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
tune control: added the possibility to set tunes with a string
minor changes
parent
7f1f3fa3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/systemcmds/tune_control/CMakeLists.txt
+1
-1
1 addition, 1 deletion
src/systemcmds/tune_control/CMakeLists.txt
src/systemcmds/tune_control/tune_control.cpp
+47
-31
47 additions, 31 deletions
src/systemcmds/tune_control/tune_control.cpp
with
48 additions
and
32 deletions
src/systemcmds/tune_control/CMakeLists.txt
+
1
−
1
View file @
f7aad844
...
...
@@ -33,7 +33,7 @@
px4_add_module
(
MODULE systemcmds__tune_control
MAIN tune_control
STACK_MAIN 2500
STACK_MAIN 2500
# TODO: choose an appropriate stack size
COMPILE_FLAGS
SRCS
tune_control.cpp
...
...
This diff is collapsed.
Click to expand it.
src/systemcmds/tune_control/tune_control.cpp
+
47
−
31
View file @
f7aad844
...
...
@@ -127,16 +127,33 @@ int
tune_control_main
(
int
argc
,
char
*
argv
[])
{
output
::
Tunes
tunes
;
bool
string_input
=
false
;
const
char
*
tune_string
=
NULL
;
int
myoptind
=
1
;
int
ch
;
const
char
*
myoptarg
=
NULL
;
uint8_t
value
;
tune_control_s
tune_control
=
{};
tune_control
.
tune_id
=
tune_control_s
::
STARTUP
;
tune_control
.
tune_id
=
0
;
tune_control
.
strength
=
40
;
while
((
ch
=
px4_getopt
(
argc
,
argv
,
"
t
:"
,
&
myoptind
,
&
myoptarg
))
!=
EOF
)
{
while
((
ch
=
px4_getopt
(
argc
,
argv
,
"
f:d:t:s
:"
,
&
myoptind
,
&
myoptarg
))
!=
EOF
)
{
switch
(
ch
)
{
case
'f'
:
if
((
uint16_t
)(
strtol
(
myoptarg
,
NULL
,
0
))
>
0
&&
(
uint16_t
)(
strtol
(
myoptarg
,
NULL
,
0
))
<
22000
)
{
tune_control
.
frequency
=
(
uint16_t
)(
strtol
(
myoptarg
,
NULL
,
0
));
}
else
{
usage
();
return
1
;
}
break
;
case
'd'
:
tune_control
.
duration
=
(
uint16_t
)(
strtol
(
myoptarg
,
NULL
,
0
));
break
;
case
't'
:
value
=
(
uint8_t
)(
strtol
(
myoptarg
,
NULL
,
0
));
...
...
@@ -150,23 +167,12 @@ tune_control_main(int argc, char *argv[])
break
;
case
'l'
:
// led_control.led_mask = 1 << strtol(myoptarg, NULL, 0);
break
;
case
'n'
:
// led_control.num_blinks = strtol(myoptarg, NULL, 0);
break
;
case
's'
:
if
(
!
strcmp
(
myoptarg
,
"fast"
))
{
// blink_speed = led_control_s::MODE_BLINK_FAST;
string_input
=
true
;
}
else
if
(
!
strcmp
(
myoptarg
,
"normal"
))
{
// blink_speed = led_control_s::MODE_BLINK_NORMAL;
}
else
if
(
!
strcmp
(
myoptarg
,
"slow"
))
{
// blink_speed = led_control_s::MODE_BLINK_SLOW;
// TODO: check if the string is a valid tune sequence
if
(
1
)
{
tune_string
=
myoptarg
;
}
else
{
usage
();
...
...
@@ -195,27 +201,37 @@ tune_control_main(int argc, char *argv[])
return
1
;
}
if
(
!
strcmp
(
argv
[
myoptind
],
"test"
))
{
PX4_INFO
(
"Publishing standard tune %d"
,
tune_control
.
tune_id
);
publish_tune_control
(
tune_control
);
unsigned
frequency
,
duration
,
silence
;
}
else
if
(
!
strcmp
(
argv
[
myoptind
],
"libtest"
))
{
unsigned
frequency
,
duration
,
silence
;
if
(
!
strcmp
(
argv
[
myoptind
],
"play"
))
{
if
(
string_input
)
{
PX4_INFO
(
"Start playback..."
);
while
(
tunes
.
parse_string
(
tune_string
,
frequency
,
duration
,
silence
)
>
0
)
{
tune_control
.
tune_id
=
0
;
tune_control
.
frequency
=
(
uint16_t
)
frequency
;
tune_control
.
duration
=
(
uint32_t
)
duration
;
publish_tune_control
(
tune_control
);
usleep
(
duration
+
silence
);
}
PX4_INFO
(
"Playback finished."
)
}
else
{
if
(
tune_control
.
tune_id
==
0
)
{
tune_control
.
tune_id
=
1
;
}
PX4_INFO
(
"Publishing standard tune %d"
,
tune_control
.
tune_id
);
publish_tune_control
(
tune_control
);
}
}
else
if
(
!
strcmp
(
argv
[
myoptind
],
"libtest"
))
{
while
(
tunes
.
parse_cmd
(
tune_control
,
frequency
,
duration
,
silence
)
>
0
)
{
PX4_INFO
(
"frequency: %d, duration %d, silence %d"
,
frequency
,
duration
,
silence
);
usleep
(
500000
);
}
/*} else if (!strcmp(argv[myoptind], "off")) {
led_control.mode = led_control_s::MODE_OFF;
} else if (!strcmp(argv[myoptind], "reset")) {
led_control.mode = led_control_s::MODE_DISABLED;
} else if (!strcmp(argv[myoptind], "blink")) {
led_control.mode = blink_speed;*/
}
else
{
usage
();
return
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment