ESPHome  2024.11.1
nextion_base.h
Go to the documentation of this file.
1 #pragma once
2 #include "esphome/core/defines.h"
3 #include "esphome/core/color.h"
5 namespace esphome {
6 namespace nextion {
7 
8 #ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
9 #define NEXTION_PROTOCOL_LOG
10 #endif
11 
12 #ifdef NEXTION_PROTOCOL_LOG
13 #ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
14 #define ESP_LOGN(tag, ...) ESP_LOGVV(tag, __VA_ARGS__)
15 #else
16 #define ESP_LOGN(tag, ...) ESP_LOGD(tag, __VA_ARGS__)
17 #endif
18 #else
19 #define ESP_LOGN(tag, ...) \
20  {}
21 #endif
22 
23 class NextionBase;
24 
25 class NextionBase {
26  public:
27  virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) = 0;
28  virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
29  const std::string &variable_name_to_send, int32_t state_value) = 0;
30 
31  virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) = 0;
32  virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
33  const std::string &variable_name_to_send,
34  const std::string &state_value) = 0;
35 
36  virtual void add_addt_command_to_queue(NextionComponentBase *component) = 0;
37 
38  virtual void add_to_get_queue(NextionComponentBase *component) = 0;
39 
40  virtual void set_component_background_color(const char *component, Color color) = 0;
41  virtual void set_component_pressed_background_color(const char *component, Color color) = 0;
42  virtual void set_component_foreground_color(const char *component, Color color) = 0;
43  virtual void set_component_pressed_foreground_color(const char *component, Color color) = 0;
44  virtual void set_component_font_color(const char *component, Color color) = 0;
45  virtual void set_component_pressed_font_color(const char *component, Color color) = 0;
46  virtual void set_component_font(const char *component, uint8_t font_id) = 0;
47 
48  virtual void show_component(const char *component) = 0;
49  virtual void hide_component(const char *component) = 0;
50 
51  virtual bool is_updating() { return false; }
52 
53  bool is_sleeping() { return this->is_sleeping_; }
54  bool is_setup() { return this->is_setup_; }
55  bool is_detected() { return this->is_detected_; }
56 
57  protected:
58  bool is_setup_ = false;
59  bool is_sleeping_ = false;
60  bool is_detected_ = false;
61 };
62 
63 } // namespace nextion
64 } // namespace esphome
virtual void set_component_font(const char *component, uint8_t font_id)=0
virtual void set_component_pressed_foreground_color(const char *component, Color color)=0
virtual void set_component_pressed_font_color(const char *component, Color color)=0
virtual void set_component_pressed_background_color(const char *component, Color color)=0
virtual void add_to_get_queue(NextionComponentBase *component)=0
virtual void add_addt_command_to_queue(NextionComponentBase *component)=0
virtual void hide_component(const char *component)=0
virtual void show_component(const char *component)=0
virtual void set_component_background_color(const char *component, Color color)=0
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
virtual void set_component_foreground_color(const char *component, Color color)=0
virtual void set_component_font_color(const char *component, Color color)=0
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value)=0