mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
[rtttl] Clamp gain between 0 and 1 (#7793)
This commit is contained in:
parent
6d4f787f67
commit
fbb9967117
1 changed files with 1 additions and 7 deletions
|
@ -40,13 +40,7 @@ class Rtttl : public Component {
|
||||||
void set_speaker(speaker::Speaker *speaker) { this->speaker_ = speaker; }
|
void set_speaker(speaker::Speaker *speaker) { this->speaker_ = speaker; }
|
||||||
#endif
|
#endif
|
||||||
float get_gain() { return gain_; }
|
float get_gain() { return gain_; }
|
||||||
void set_gain(float gain) {
|
void set_gain(float gain) { this->gain_ = clamp(gain, 0.0f, 1.0f); }
|
||||||
if (gain < 0.1f)
|
|
||||||
gain = 0.1f;
|
|
||||||
if (gain > 1.0f)
|
|
||||||
gain = 1.0f;
|
|
||||||
this->gain_ = gain;
|
|
||||||
}
|
|
||||||
void play(std::string rtttl);
|
void play(std::string rtttl);
|
||||||
void stop();
|
void stop();
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
Loading…
Reference in a new issue