ESPHome
2024.10.2
esphome
esphome
components
output
button
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
9
void
OutputButton::dump_config
() {
10
LOG_BUTTON(
""
,
"Output Button"
,
this
);
11
ESP_LOGCONFIG(TAG,
" Duration: %.1fs"
, this->
duration_
/ 1e3f);
12
}
13
void
OutputButton::press_action
() {
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
esphome::output::BinaryOutput::turn_on
virtual void turn_on()
Enable this binary output.
Definition:
binary_output.h:43
esphome::output::OutputButton::press_action
void press_action() override
Definition:
output_button.cpp:13
esphome::output::BinaryOutput::turn_off
virtual void turn_off()
Disable this binary output.
Definition:
binary_output.h:51
esphome::Component::set_timeout
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_button.h
esphome::output::OutputButton::dump_config
void dump_config() override
Definition:
output_button.cpp:9
esphome::output::OutputButton::output_
output::BinaryOutput * output_
Definition:
output_button.h:20
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
log.h
esphome::output::OutputButton::duration_
uint32_t duration_
Definition:
output_button.h:21
Generated by
1.8.13