update the rtttl code.

This commit is contained in:
NP v/d Spek 2024-10-25 21:27:45 +02:00
parent d15519f7d9
commit 70bd8f83b7
2 changed files with 3 additions and 11 deletions

View file

@ -161,7 +161,7 @@ void Rtttl::loop() {
audio_stream_info.sample_rate = SAMPLE_RATE;
this->speaker_->set_audio_stream_info(audio_stream_info);
// this->speaker_->set_volume(this->gain_);
this->speaker_->set_volume(this->gain_);
this->speaker_->start();
this->set_state_(State::STATE_STARTING);
}
@ -358,11 +358,6 @@ void Rtttl::finish_() {
if (this->output_ != nullptr) {
this->output_->set_level(0.0);
}
#endif
#ifdef USE_SPEAKER
if (this->speaker_ != nullptr) {
this->speaker_->finish();
}
#endif
this->set_state_(State::STATE_STOPPED);
this->note_duration_ = 0;
@ -378,8 +373,6 @@ static const LogString *state_to_string(State state) {
return LOG_STR("STATE_STARTING");
case STATE_RUNNING:
return LOG_STR("STATE_RUNNING");
case STATE_STOPPING:
return LOG_STR("STATE_STOPPING");
case STATE_INIT:
return LOG_STR("STATE_INIT");
default:
@ -390,7 +383,7 @@ static const LogString *state_to_string(State state) {
void Rtttl::set_state_(State state) {
State old_state = this->state_;
this->state_ = state;
ESP_LOGD(TAG, "State changed from %s to %s", LOG_STR_ARG(state_to_string(old_state)),
ESP_LOGV(TAG, "State changed from %s to %s", LOG_STR_ARG(state_to_string(old_state)),
LOG_STR_ARG(state_to_string(state)));
}

View file

@ -19,7 +19,6 @@ enum State : uint8_t {
STATE_INIT,
STATE_STARTING,
STATE_RUNNING,
STATE_STOPPING,
};
class Rtttl : public Component {
@ -69,7 +68,7 @@ class Rtttl : public Component {
uint16_t note_duration_;
uint32_t output_freq_;
float gain_{1.0f};
float gain_{0.9f};
State state_{State::STATE_STOPPED};
#ifdef USE_OUTPUT