mirror of
https://github.com/esphome/esphome.git
synced 2024-12-23 05:54:56 +01:00
[rtttl] fix STOPPED state (#7323)
Some checks are pending
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.10) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.9) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Component test ${{ matrix.file }} (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
Some checks are pending
CI / Check black (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.10) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.9) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Component test ${{ matrix.file }} (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / Test split components (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
This commit is contained in:
parent
bd3d065a23
commit
848fd0442d
1 changed files with 5 additions and 3 deletions
|
@ -32,7 +32,7 @@ void Rtttl::play(std::string rtttl) {
|
||||||
if (this->state_ != State::STATE_STOPPED && this->state_ != State::STATE_STOPPING) {
|
if (this->state_ != State::STATE_STOPPED && this->state_ != State::STATE_STOPPING) {
|
||||||
int pos = this->rtttl_.find(':');
|
int pos = this->rtttl_.find(':');
|
||||||
auto name = this->rtttl_.substr(0, pos);
|
auto name = this->rtttl_.substr(0, pos);
|
||||||
ESP_LOGW(TAG, "RTTL Component is already playing: %s", name.c_str());
|
ESP_LOGW(TAG, "RTTTL Component is already playing: %s", name.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ void Rtttl::stop() {
|
||||||
#ifdef USE_OUTPUT
|
#ifdef USE_OUTPUT
|
||||||
if (this->output_ != nullptr) {
|
if (this->output_ != nullptr) {
|
||||||
this->output_->set_level(0.0);
|
this->output_->set_level(0.0);
|
||||||
|
this->set_state_(STATE_STOPPED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SPEAKER
|
#ifdef USE_SPEAKER
|
||||||
|
@ -129,10 +130,10 @@ void Rtttl::stop() {
|
||||||
if (this->speaker_->is_running()) {
|
if (this->speaker_->is_running()) {
|
||||||
this->speaker_->stop();
|
this->speaker_->stop();
|
||||||
}
|
}
|
||||||
|
this->set_state_(STATE_STOPPING);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
this->note_duration_ = 0;
|
this->note_duration_ = 0;
|
||||||
this->set_state_(STATE_STOPPING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rtttl::loop() {
|
void Rtttl::loop() {
|
||||||
|
@ -342,6 +343,7 @@ void Rtttl::finish_() {
|
||||||
#ifdef USE_OUTPUT
|
#ifdef USE_OUTPUT
|
||||||
if (this->output_ != nullptr) {
|
if (this->output_ != nullptr) {
|
||||||
this->output_->set_level(0.0);
|
this->output_->set_level(0.0);
|
||||||
|
this->set_state_(State::STATE_STOPPED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SPEAKER
|
#ifdef USE_SPEAKER
|
||||||
|
@ -354,9 +356,9 @@ void Rtttl::finish_() {
|
||||||
this->speaker_->play((uint8_t *) (&sample), 8);
|
this->speaker_->play((uint8_t *) (&sample), 8);
|
||||||
|
|
||||||
this->speaker_->finish();
|
this->speaker_->finish();
|
||||||
|
this->set_state_(State::STATE_STOPPING);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
this->set_state_(State::STATE_STOPPING);
|
|
||||||
this->note_duration_ = 0;
|
this->note_duration_ = 0;
|
||||||
this->on_finished_playback_callback_.call();
|
this->on_finished_playback_callback_.call();
|
||||||
ESP_LOGD(TAG, "Playback finished");
|
ESP_LOGD(TAG, "Playback finished");
|
||||||
|
|
Loading…
Reference in a new issue