mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 15:58:52 +08:00
libtunes: added TUNE_MAX_STRENGTH
This commit is contained in:
committed by
Beat Küng
parent
80d80835a0
commit
6e1c495268
+13
-2
@@ -110,7 +110,12 @@ int Tunes::set_control(const tune_control_s &tune_control)
|
||||
reset(_repeat);
|
||||
|
||||
// Strength will remain valid for the entire tune, unless interrupted.
|
||||
_strength = (unsigned)tune_control.strength;
|
||||
if ((unsigned)tune_control.strength <= TUNE_MAX_STRENGTH) {
|
||||
_strength = (unsigned)tune_control.strength;
|
||||
|
||||
} else {
|
||||
_strength = TUNE_MAX_STRENGTH;
|
||||
}
|
||||
|
||||
// Special treatment for custom tunes
|
||||
if (tune_control.tune_id == static_cast<int>(TuneID::CUSTOM)) {
|
||||
@@ -138,7 +143,13 @@ void Tunes::set_string(const char *const string, uint8_t strength)
|
||||
_tune = string;
|
||||
_tune_start_ptr = string;
|
||||
_next = _tune;
|
||||
_strength = strength;
|
||||
|
||||
if (strength <= TUNE_MAX_STRENGTH) {
|
||||
_strength = strength;
|
||||
|
||||
} else {
|
||||
_strength = TUNE_MAX_STRENGTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#define TUNE_DEFAULT_TEMPO 120
|
||||
#define TUNE_DEFAULT_OCTAVE 4
|
||||
#define TUNE_DEFAULT_NOTE_LENGTH 4
|
||||
#define TUNE_MAX_STRENGTH 100
|
||||
|
||||
|
||||
/**
|
||||
* Library for parsing tunes from melody-strings or dedicated tune messages.
|
||||
|
||||
Reference in New Issue
Block a user