ESPHome
2024.9.2
esphome
esphome
components
display_menu_base
display_menu_base.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
5
#include "
menu_item.h
"
6
7
#include <forward_list>
8
9
namespace
esphome
{
10
namespace
display_menu_base {
11
12
enum
MenuMode
{
13
MENU_MODE_ROTARY
,
14
MENU_MODE_JOYSTICK
,
15
};
16
17
class
MenuItem
;
18
22
class
DisplayMenuComponent
:
public
Component
{
23
public
:
24
void
set_root_item
(
MenuItemMenu
*item) { this->
displayed_item_
= this->
root_item_
= item; }
25
void
set_active
(
bool
active) { this->
active_
= active; }
26
void
set_mode
(
MenuMode
mode
) { this->
mode_
=
mode
; }
27
void
set_rows
(uint8_t rows) { this->
rows_
= rows; }
28
29
float
get_setup_priority
()
const override
{
return
setup_priority::PROCESSOR
; }
30
31
void
up
();
32
void
down
();
33
void
left
();
34
void
right
();
35
void
enter
();
36
37
void
show_main
();
38
void
show
();
39
void
hide
();
40
41
void
draw
();
42
43
bool
is_active
()
const
{
return
this->
active_
; }
44
45
protected
:
46
void
reset_
();
47
void
process_initial_
();
48
bool
check_healthy_and_active_
();
49
MenuItem
*
get_selected_item_
() {
return
this->
displayed_item_
->
get_item
(this->
cursor_index_
); }
50
bool
cursor_up_
();
51
bool
cursor_down_
();
52
bool
enter_menu_
();
53
bool
leave_menu_
();
54
void
finish_editing_
();
55
virtual
void
draw_menu
();
56
virtual
void
draw_item
(
const
MenuItem
*item, uint8_t row,
bool
selected) = 0;
57
virtual
void
update
() {}
58
virtual
void
draw_and_update
() {
59
draw_menu
();
60
update
();
61
}
62
63
virtual
void
on_before_show
(){};
64
virtual
void
on_after_show
(){};
65
virtual
void
on_before_hide
(){};
66
virtual
void
on_after_hide
(){};
67
68
uint8_t
rows_
;
69
bool
active_
;
70
MenuMode
mode_
;
71
MenuItemMenu
*
root_item_
{
nullptr
};
72
73
MenuItemMenu
*
displayed_item_
{
nullptr
};
74
uint8_t
top_index_
{0};
75
uint8_t
cursor_index_
{0};
76
std::forward_list<std::pair<uint8_t, uint8_t>>
selection_stack_
{};
77
bool
editing_
{
false
};
78
bool
root_on_enter_called_
{
false
};
79
};
80
81
}
// namespace display_menu_base
82
}
// namespace esphome
esphome::display_menu_base::DisplayMenuComponent::set_mode
void set_mode(MenuMode mode)
Definition:
display_menu_base.h:26
esphome::display_menu_base::DisplayMenuComponent::get_setup_priority
float get_setup_priority() const override
Definition:
display_menu_base.h:29
esphome::display_menu_base::DisplayMenuComponent::mode_
MenuMode mode_
Definition:
display_menu_base.h:70
esphome::display_menu_base::DisplayMenuComponent::editing_
bool editing_
Definition:
display_menu_base.h:77
esphome::display_menu_base::DisplayMenuComponent::get_selected_item_
MenuItem * get_selected_item_()
Definition:
display_menu_base.h:49
esphome::display_menu_base::DisplayMenuComponent::root_on_enter_called_
bool root_on_enter_called_
Definition:
display_menu_base.h:78
esphome::display_menu_base::DisplayMenuComponent::up
void up()
Definition:
display_menu_base.cpp:7
esphome::display_menu_base::DisplayMenuComponent::hide
void hide()
Definition:
display_menu_base.cpp:215
esphome::display_menu_base::DisplayMenuComponent::root_item_
MenuItemMenu * root_item_
Definition:
display_menu_base.h:71
esphome::display_menu_base::DisplayMenuComponent::show
void show()
Definition:
display_menu_base.cpp:199
esphome::Component
Definition:
component.h:68
esphome::display_menu_base::MENU_MODE_ROTARY
Definition:
display_menu_base.h:13
esphome::display_menu_base::MenuMode
MenuMode
Definition:
display_menu_base.h:12
esphome::display_menu_base::MenuItem
Definition:
menu_item.h:40
esphome::display_menu_base::DisplayMenuComponent::leave_menu_
bool leave_menu_()
Definition:
display_menu_base.cpp:290
esphome::display_menu_base::DisplayMenuComponent::active_
bool active_
Definition:
display_menu_base.h:69
esphome::display_menu_base::DisplayMenuComponent::rows_
uint8_t rows_
Definition:
display_menu_base.h:66
esphome::display_menu_base::DisplayMenuComponent::draw_item
virtual void draw_item(const MenuItem *item, uint8_t row, bool selected)=0
esphome::display_menu_base::DisplayMenuComponent::check_healthy_and_active_
bool check_healthy_and_active_()
Definition:
display_menu_base.cpp:241
esphome::display_menu_base::DisplayMenuComponent::cursor_down_
bool cursor_down_()
Definition:
display_menu_base.cpp:265
esphome::display_menu_base::DisplayMenuComponent::left
void left()
Definition:
display_menu_base.cpp:49
esphome::display_menu_base::DisplayMenuComponent::update
virtual void update()
Definition:
display_menu_base.h:57
esphome::display_menu_base::DisplayMenuComponent::set_rows
void set_rows(uint8_t rows)
Definition:
display_menu_base.h:27
esphome::display_menu_base::DisplayMenuComponent::reset_
void reset_()
Definition:
display_menu_base.cpp:228
esphome::display_menu_base::DisplayMenuComponent::enter_menu_
bool enter_menu_()
Definition:
display_menu_base.cpp:280
esphome::display_menu_base::DisplayMenuComponent::selection_stack_
std::forward_list< std::pair< uint8_t, uint8_t > > selection_stack_
Definition:
display_menu_base.h:76
esphome::display_menu_base::DisplayMenuComponent::show_main
void show_main()
Definition:
display_menu_base.cpp:169
esphome::display_menu_base::DisplayMenuComponent::cursor_index_
uint8_t cursor_index_
Definition:
display_menu_base.h:75
mode
BedjetMode mode
BedJet operating mode.
Definition:
bedjet_codec.h:181
esphome::display_menu_base::DisplayMenuComponent::draw
void draw()
Definition:
display_menu_base.cpp:164
esphome::display_menu_base::DisplayMenuComponent::draw_and_update
virtual void draw_and_update()
Definition:
display_menu_base.h:58
esphome::display_menu_base::DisplayMenuComponent::on_after_show
virtual void on_after_show()
Definition:
display_menu_base.h:64
menu_item.h
esphome::setup_priority::PROCESSOR
const float PROCESSOR
For components that use data from sensors like displays.
Definition:
component.cpp:20
esphome::display_menu_base::MenuItemMenu::get_item
MenuItem * get_item(size_t i)
Definition:
menu_item.h:82
esphome::display_menu_base::DisplayMenuComponent::set_root_item
void set_root_item(MenuItemMenu *item)
Definition:
display_menu_base.h:24
esphome::display_menu_base::DisplayMenuComponent::on_before_show
virtual void on_before_show()
Definition:
display_menu_base.h:63
esphome::display_menu_base::DisplayMenuComponent::cursor_up_
bool cursor_up_()
Definition:
display_menu_base.cpp:250
esphome::display_menu_base::DisplayMenuComponent::on_after_hide
virtual void on_after_hide()
Definition:
display_menu_base.h:66
esphome::display_menu_base::DisplayMenuComponent::right
void right()
Definition:
display_menu_base.cpp:87
esphome::display_menu_base::DisplayMenuComponent::displayed_item_
MenuItemMenu * displayed_item_
Definition:
display_menu_base.h:73
esphome::display_menu_base::DisplayMenuComponent::draw_menu
virtual void draw_menu()
Definition:
display_menu_base.cpp:321
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::display_menu_base::DisplayMenuComponent::down
void down()
Definition:
display_menu_base.cpp:28
esphome::display_menu_base::DisplayMenuComponent::enter
void enter()
Definition:
display_menu_base.cpp:116
component.h
esphome::display_menu_base::MENU_MODE_JOYSTICK
Definition:
display_menu_base.h:14
esphome::display_menu_base::DisplayMenuComponent::top_index_
uint8_t top_index_
Definition:
display_menu_base.h:74
esphome::display_menu_base::DisplayMenuComponent::process_initial_
void process_initial_()
Definition:
display_menu_base.cpp:234
esphome::display_menu_base::DisplayMenuComponent::finish_editing_
void finish_editing_()
Definition:
display_menu_base.cpp:306
esphome::display_menu_base::DisplayMenuComponent::set_active
void set_active(bool active)
Definition:
display_menu_base.h:25
esphome::display_menu_base::DisplayMenuComponent::on_before_hide
virtual void on_before_hide()
Definition:
display_menu_base.h:65
esphome::display_menu_base::DisplayMenuComponent
Class to display a hierarchical menu.
Definition:
display_menu_base.h:22
esphome::display_menu_base::DisplayMenuComponent::is_active
bool is_active() const
Definition:
display_menu_base.h:43
esphome::display_menu_base::MenuItemMenu
Definition:
menu_item.h:74
Generated by
1.8.13