ESPHome  2024.4.2
key_collector.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
6 
7 namespace esphome {
8 namespace key_collector {
9 
10 class KeyCollector : public Component {
11  public:
12  KeyCollector();
13  void loop() override;
14  void dump_config() override;
16  void set_min_length(int min_length) { this->min_length_ = min_length; };
17  void set_max_length(int max_length) { this->max_length_ = max_length; };
18  void set_start_keys(std::string start_keys) { this->start_keys_ = std::move(start_keys); };
19  void set_end_keys(std::string end_keys) { this->end_keys_ = std::move(end_keys); };
20  void set_end_key_required(bool end_key_required) { this->end_key_required_ = end_key_required; };
21  void set_back_keys(std::string back_keys) { this->back_keys_ = std::move(back_keys); };
22  void set_clear_keys(std::string clear_keys) { this->clear_keys_ = std::move(clear_keys); };
23  void set_allowed_keys(std::string allowed_keys) { this->allowed_keys_ = std::move(allowed_keys); };
27  void set_timeout(int timeout) { this->timeout_ = timeout; };
28 
29  void clear(bool progress_update = true);
30  void send_key(uint8_t key);
31 
32  protected:
33  void key_pressed_(uint8_t key);
34 
35  int min_length_{0};
36  int max_length_{0};
37  std::string start_keys_;
38  std::string end_keys_;
39  bool end_key_required_{false};
40  std::string back_keys_;
41  std::string clear_keys_;
42  std::string allowed_keys_;
43  std::string result_;
44  uint8_t start_key_{0};
48  uint32_t last_key_time_;
49  uint32_t timeout_{0};
50 };
51 
52 } // namespace key_collector
53 } // namespace esphome
void set_start_keys(std::string start_keys)
Definition: key_collector.h:18
void set_max_length(int max_length)
Definition: key_collector.h:17
interface for components that provide keypresses
Definition: key_provider.h:10
void set_clear_keys(std::string clear_keys)
Definition: key_collector.h:22
Trigger< std::string, uint8_t > * progress_trigger_
Definition: key_collector.h:45
void set_end_keys(std::string end_keys)
Definition: key_collector.h:19
void set_end_key_required(bool end_key_required)
Definition: key_collector.h:20
void set_min_length(int min_length)
Definition: key_collector.h:16
Trigger< std::string, uint8_t, uint8_t > * get_result_trigger() const
Definition: key_collector.h:25
void set_provider(key_provider::KeyProvider *provider)
Trigger< std::string, uint8_t, uint8_t > * result_trigger_
Definition: key_collector.h:46
Trigger< std::string, uint8_t > * get_timeout_trigger() const
Definition: key_collector.h:26
void set_allowed_keys(std::string allowed_keys)
Definition: key_collector.h:23
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Trigger< std::string, uint8_t > * timeout_trigger_
Definition: key_collector.h:47
void clear(bool progress_update=true)
void set_back_keys(std::string back_keys)
Definition: key_collector.h:21
Trigger< std::string, uint8_t > * get_progress_trigger() const
Definition: key_collector.h:24