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
80d80835
Commit
80d80835
authored
7 years ago
by
Alessandro Simovic
Committed by
Beat Küng
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
libtunes: fixed some type conversions and other minor changes
parent
92b89368
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib/tunes/tunes.cpp
+1
-2
1 addition, 2 deletions
src/lib/tunes/tunes.cpp
src/lib/tunes/tunes.h
+3
-3
3 additions, 3 deletions
src/lib/tunes/tunes.h
src/systemcmds/tune_control/tune_control.cpp
+6
-5
6 additions, 5 deletions
src/systemcmds/tune_control/tune_control.cpp
with
10 additions
and
10 deletions
src/lib/tunes/tunes.cpp
+
1
−
2
View file @
80d80835
...
...
@@ -115,7 +115,6 @@ int Tunes::set_control(const tune_control_s &tune_control)
// Special treatment for custom tunes
if
(
tune_control
.
tune_id
==
static_cast
<
int
>
(
TuneID
::
CUSTOM
))
{
_using_custom_msg
=
true
;
_tune
=
nullptr
;
// remove tune in case of override
_frequency
=
(
unsigned
)
tune_control
.
frequency
;
_duration
=
(
unsigned
)
tune_control
.
duration
;
_silence
=
(
unsigned
)
tune_control
.
silence
;
...
...
@@ -144,7 +143,7 @@ void Tunes::set_string(const char *const string, uint8_t strength)
}
int
Tunes
::
get_next_tune
(
unsigned
&
frequency
,
unsigned
&
duration
,
unsigned
&
silence
,
u
nsigned
&
strength
)
unsigned
&
silence
,
u
int8_t
&
strength
)
{
int
ret
=
get_next_tune
(
frequency
,
duration
,
silence
);
...
...
This diff is collapsed.
Click to expand it.
src/lib/tunes/tunes.h
+
3
−
3
View file @
80d80835
...
...
@@ -93,7 +93,7 @@ public:
*
* @param string tune input string
*/
void
set_string
(
const
char
*
const
string
);
void
set_string
(
const
char
*
const
string
,
uint8_t
strength
);
/**
* Get next note in the current tune, which has been provided by either
...
...
@@ -115,7 +115,7 @@ public:
* @return -1 for error, 0 for play one tone and 1 for continue a sequence
*/
int
get_next_tune
(
unsigned
&
frequency
,
unsigned
&
duration
,
unsigned
&
silence
,
u
nsigned
&
strength
);
u
int8_t
&
strength
);
/**
* Get the number of default tunes. This is useful for when a tune is
...
...
@@ -148,7 +148,7 @@ private:
unsigned
_frequency
;
unsigned
_duration
;
unsigned
_silence
;
u
nsigned
_strength
;
u
int8_t
_strength
;
bool
_using_custom_msg
=
false
;
/**
...
...
This diff is collapsed.
Click to expand it.
src/systemcmds/tune_control/tune_control.cpp
+
6
−
5
View file @
80d80835
...
...
@@ -72,7 +72,7 @@ usage()
"
\t
-s <strength>
\t\t
Strength of the tone between 0-100
\n
"
"
\t
-m <melody>
\t\t
Melody in a string form ex:
\"
MFT200e8a8a
\"\n
"
"
\n
"
"tune_control stop
\t\t
Stops playback, useful for repeated tunes
\n
"
"tune_control stop
\t\t
Stops playback, useful for repeated tunes
\n
"
);
}
...
...
@@ -147,7 +147,7 @@ tune_control_main(int argc, char *argv[])
break
;
case
's'
:
value
=
(
uint
16
_t
)(
strtol
(
myoptarg
,
nullptr
,
0
));
value
=
(
uint
8
_t
)(
strtol
(
myoptarg
,
nullptr
,
0
));
if
(
value
>
0
&&
value
<
100
)
{
tune_control
.
strength
=
value
;
...
...
@@ -170,20 +170,21 @@ tune_control_main(int argc, char *argv[])
return
1
;
}
unsigned
frequency
,
duration
,
silence
,
strength
;
unsigned
frequency
,
duration
,
silence
;
uint8_t
strength
;
int
exit_counter
=
0
;
if
(
!
strcmp
(
argv
[
myoptind
],
"play"
))
{
if
(
string_input
)
{
PX4_INFO
(
"Start playback..."
);
tunes
.
set_string
(
tune_string
);
tunes
.
set_string
(
tune_string
,
tune_control
.
strength
);
while
(
tunes
.
get_next_tune
(
frequency
,
duration
,
silence
,
strength
)
>
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
=
(
uint
32
_t
)
strength
;
tune_control
.
strength
=
(
uint
8
_t
)
strength
;
publish_tune_control
(
tune_control
);
usleep
(
duration
+
silence
);
exit_counter
++
;
...
...
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