ESPHome  2024.10.2
automation.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "display_menu_base.h"
5 
6 namespace esphome {
7 namespace display_menu_base {
8 
9 template<typename... Ts> class UpAction : public Action<Ts...> {
10  public:
11  explicit UpAction(DisplayMenuComponent *menu) : menu_(menu) {}
12 
13  void play(Ts... x) override { this->menu_->up(); }
14 
15  protected:
17 };
18 
19 template<typename... Ts> class DownAction : public Action<Ts...> {
20  public:
21  explicit DownAction(DisplayMenuComponent *menu) : menu_(menu) {}
22 
23  void play(Ts... x) override { this->menu_->down(); }
24 
25  protected:
27 };
28 
29 template<typename... Ts> class LeftAction : public Action<Ts...> {
30  public:
31  explicit LeftAction(DisplayMenuComponent *menu) : menu_(menu) {}
32 
33  void play(Ts... x) override { this->menu_->left(); }
34 
35  protected:
37 };
38 
39 template<typename... Ts> class RightAction : public Action<Ts...> {
40  public:
41  explicit RightAction(DisplayMenuComponent *menu) : menu_(menu) {}
42 
43  void play(Ts... x) override { this->menu_->right(); }
44 
45  protected:
47 };
48 
49 template<typename... Ts> class EnterAction : public Action<Ts...> {
50  public:
51  explicit EnterAction(DisplayMenuComponent *menu) : menu_(menu) {}
52 
53  void play(Ts... x) override { this->menu_->enter(); }
54 
55  protected:
57 };
58 
59 template<typename... Ts> class ShowAction : public Action<Ts...> {
60  public:
61  explicit ShowAction(DisplayMenuComponent *menu) : menu_(menu) {}
62 
63  void play(Ts... x) override { this->menu_->show(); }
64 
65  protected:
67 };
68 
69 template<typename... Ts> class HideAction : public Action<Ts...> {
70  public:
71  explicit HideAction(DisplayMenuComponent *menu) : menu_(menu) {}
72 
73  void play(Ts... x) override { this->menu_->hide(); }
74 
75  protected:
77 };
78 
79 template<typename... Ts> class ShowMainAction : public Action<Ts...> {
80  public:
81  explicit ShowMainAction(DisplayMenuComponent *menu) : menu_(menu) {}
82 
83  void play(Ts... x) override { this->menu_->show_main(); }
84 
85  protected:
87 };
88 template<typename... Ts> class IsActiveCondition : public Condition<Ts...> {
89  public:
90  explicit IsActiveCondition(DisplayMenuComponent *menu) : menu_(menu) {}
91  bool check(Ts... x) override { return this->menu_->is_active(); }
92 
93  protected:
95 };
96 
97 class DisplayMenuOnEnterTrigger : public Trigger<const MenuItem *> {
98  public:
99  explicit DisplayMenuOnEnterTrigger(MenuItem *parent) {
100  parent->add_on_enter_callback([this, parent]() { this->trigger(parent); });
101  }
102 };
103 
104 class DisplayMenuOnLeaveTrigger : public Trigger<const MenuItem *> {
105  public:
107  parent->add_on_leave_callback([this, parent]() { this->trigger(parent); });
108  }
109 };
110 
111 class DisplayMenuOnValueTrigger : public Trigger<const MenuItem *> {
112  public:
114  parent->add_on_value_callback([this, parent]() { this->trigger(parent); });
115  }
116 };
117 
118 class DisplayMenuOnNextTrigger : public Trigger<const MenuItem *> {
119  public:
121  parent->add_on_next_callback([this, parent]() { this->trigger(parent); });
122  }
123 };
124 
125 class DisplayMenuOnPrevTrigger : public Trigger<const MenuItem *> {
126  public:
128  parent->add_on_prev_callback([this, parent]() { this->trigger(parent); });
129  }
130 };
131 
132 } // namespace display_menu_base
133 } // namespace esphome
ShowAction(DisplayMenuComponent *menu)
Definition: automation.h:61
UpAction(DisplayMenuComponent *menu)
Definition: automation.h:11
DisplayMenuComponent * menu_
Definition: automation.h:66
DownAction(DisplayMenuComponent *menu)
Definition: automation.h:21
uint16_t x
Definition: tt21100.cpp:17
void play(Ts... x) override
Definition: automation.h:13
RightAction(DisplayMenuComponent *menu)
Definition: automation.h:41
void add_on_prev_callback(std::function< void()> &&cb)
Definition: menu_item.h:174
DisplayMenuComponent * menu_
Definition: automation.h:16
DisplayMenuComponent * menu_
Definition: automation.h:26
Base class for all automation conditions.
Definition: automation.h:74
void add_on_next_callback(std::function< void()> &&cb)
Definition: menu_item.h:173
HideAction(DisplayMenuComponent *menu)
Definition: automation.h:71
DisplayMenuComponent * menu_
Definition: automation.h:36
EnterAction(DisplayMenuComponent *menu)
Definition: automation.h:51
LeftAction(DisplayMenuComponent *menu)
Definition: automation.h:31
void add_on_enter_callback(std::function< void()> &&cb)
Definition: menu_item.h:47
void add_on_value_callback(std::function< void()> &&cb)
Definition: menu_item.h:49
DisplayMenuComponent * menu_
Definition: automation.h:76
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void add_on_leave_callback(std::function< void()> &&cb)
Definition: menu_item.h:48
Class to display a hierarchical menu.
ShowMainAction(DisplayMenuComponent *menu)
Definition: automation.h:81
IsActiveCondition(DisplayMenuComponent *menu)
Definition: automation.h:90