ESPHome
2024.12.2
esphome
esphome
components
button
button.cpp
Go to the documentation of this file.
1
#include "
button.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome
{
5
namespace
button {
6
7
static
const
char
*
const
TAG =
"button"
;
8
9
void
Button::press
() {
10
ESP_LOGD(TAG,
"'%s' Pressed."
, this->
get_name
().c_str());
11
this->
press_action
();
12
this->
press_callback_
.call();
13
}
14
void
Button::add_on_press_callback
(std::function<
void
()> &&callback) { this->
press_callback_
.add(std::move(callback)); }
15
16
}
// namespace button
17
}
// namespace esphome
button.h
esphome::button::Button::press
void press()
Press this button.
Definition:
button.cpp:9
esphome::button::Button::add_on_press_callback
void add_on_press_callback(std::function< void()> &&callback)
Set callback for state changes.
Definition:
button.cpp:14
esphome::button::Button::press_action
virtual void press_action()=0
You should implement this virtual method if you want to create your own button.
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
log.h
esphome::button::Button::press_callback_
CallbackManager< void()> press_callback_
Definition:
button.h:48
esphome::EntityBase::get_name
const StringRef & get_name() const
Definition:
entity_base.cpp:10
Generated by
1.8.13