ESPHome  2024.11.0
output_button.cpp
Go to the documentation of this file.
1 #include "output_button.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace output {
6 
7 static const char *const TAG = "output.button";
8 
10  LOG_BUTTON("", "Output Button", this);
11  ESP_LOGCONFIG(TAG, " Duration: %.1fs", this->duration_ / 1e3f);
12 }
14  this->output_->turn_on();
15 
16  // Use a named timeout so that it's automatically cancelled if button is pressed again before it's reset
17  this->set_timeout("reset", this->duration_, [this]() { this->output_->turn_off(); });
18 }
19 
20 } // namespace output
21 } // namespace esphome
virtual void turn_on()
Enable this binary output.
Definition: binary_output.h:43
virtual void turn_off()
Disable this binary output.
Definition: binary_output.h:51
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
Definition: component.cpp:69
output::BinaryOutput * output_
Definition: output_button.h:20
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7