ESPHome 2025.5.0
Loading...
Searching...
No Matches
button.cpp
Go to the documentation of this file.
1#include "button.h"
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace button {
6
7static const char *const TAG = "button";
8
10 ESP_LOGD(TAG, "'%s' Pressed.", this->get_name().c_str());
11 this->press_action();
12 this->press_callback_.call();
13}
14void Button::add_on_press_callback(std::function<void()> &&callback) { this->press_callback_.add(std::move(callback)); }
15
16} // namespace button
17} // namespace esphome
const StringRef & get_name() const
void add_on_press_callback(std::function< void()> &&callback)
Set callback for state changes.
Definition button.cpp:14
CallbackManager< void()> press_callback_
Definition button.h:48
void press()
Press this button.
Definition button.cpp:9
virtual void press_action()=0
You should implement this virtual method if you want to create your own button.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7