ESPHome  2022.11.3
automation.h
Go to the documentation of this file.
1 #pragma once
3 #include "nextion.h"
4 
5 namespace esphome {
6 namespace nextion {
7 
8 class SetupTrigger : public Trigger<> {
9  public:
10  explicit SetupTrigger(Nextion *nextion) {
11  nextion->add_setup_state_callback([this]() { this->trigger(); });
12  }
13 };
14 
15 class SleepTrigger : public Trigger<> {
16  public:
17  explicit SleepTrigger(Nextion *nextion) {
18  nextion->add_sleep_state_callback([this]() { this->trigger(); });
19  }
20 };
21 
22 class WakeTrigger : public Trigger<> {
23  public:
24  explicit WakeTrigger(Nextion *nextion) {
25  nextion->add_wake_state_callback([this]() { this->trigger(); });
26  }
27 };
28 
29 class PageTrigger : public Trigger<uint8_t> {
30  public:
31  explicit PageTrigger(Nextion *nextion) {
32  nextion->add_new_page_callback([this](const uint8_t page_id) { this->trigger(page_id); });
33  }
34 };
35 
36 } // namespace nextion
37 } // namespace esphome
void add_new_page_callback(std::function< void(uint8_t)> &&callback)
Add a callback to be notified when the nextion changes pages.
Definition: nextion.cpp:155
void add_wake_state_callback(std::function< void()> &&callback)
Add a callback to be notified of wake state changes.
Definition: nextion.cpp:147
void add_setup_state_callback(std::function< void()> &&callback)
Add a callback to be notified when the nextion completes its initialize setup.
Definition: nextion.cpp:151
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition: automation.h:95
void add_sleep_state_callback(std::function< void()> &&callback)
Add a callback to be notified of sleep state changes.
Definition: nextion.cpp:143
WakeTrigger(Nextion *nextion)
Definition: automation.h:24
PageTrigger(Nextion *nextion)
Definition: automation.h:31
SleepTrigger(Nextion *nextion)
Definition: automation.h:17
Definition: a4988.cpp:4
SetupTrigger(Nextion *nextion)
Definition: automation.h:10