6namespace key_collector {
8static const char *
const TAG =
"key_collector";
11 : progress_trigger_(new
Trigger<std::string, uint8_t>()),
12 result_trigger_(new
Trigger<std::string, uint8_t, uint8_t>()),
13 timeout_trigger_(new
Trigger<std::string, uint8_t>()) {}
23 ESP_LOGCONFIG(TAG,
"Key Collector:");
25 ESP_LOGCONFIG(TAG,
" min length: %d", this->
min_length_);
27 ESP_LOGCONFIG(TAG,
" max length: %d", this->
max_length_);
29 ESP_LOGCONFIG(TAG,
" erase keys '%s'", this->
back_keys_.c_str());
31 ESP_LOGCONFIG(TAG,
" clear keys '%s'", this->
clear_keys_.c_str());
33 ESP_LOGCONFIG(TAG,
" start keys '%s'", this->
start_keys_.c_str());
35 ESP_LOGCONFIG(TAG,
" end keys '%s'", this->
end_keys_.c_str());
39 ESP_LOGCONFIG(TAG,
" allowed keys '%s'", this->
allowed_keys_.c_str());
41 ESP_LOGCONFIG(TAG,
" entry timeout: %0.1f", this->
timeout_ / 1000.0);
67 if (!this->
start_keys_.empty() && !this->start_key_) {
68 if (this->
start_keys_.find(key) != std::string::npos) {
74 if (this->
back_keys_.find(key) != std::string::npos) {
81 if (this->
clear_keys_.find(key) != std::string::npos) {
86 if (this->
end_keys_.find(key) != std::string::npos) {
93 if (!this->
allowed_keys_.empty() && (this->allowed_keys_.find(key) == std::string::npos))
97 if ((this->
max_length_ > 0) && (this->
result_.size() == this->max_length_) && (!this->end_key_required_)) {
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
void set_provider(key_provider::KeyProvider *provider)
void key_pressed_(uint8_t key)
void set_enabled(bool enabled)
void send_key(uint8_t key)
Trigger< std::string, uint8_t > * progress_trigger_
std::string allowed_keys_
void dump_config() override
Trigger< std::string, uint8_t, uint8_t > * result_trigger_
Trigger< std::string, uint8_t > * timeout_trigger_
void clear(bool progress_update=true)
interface for components that provide keypresses
void add_on_key_callback(std::function< void(uint8_t)> &&callback)
Providing packet encoding functions for exchanging data with a remote host.
uint32_t IRAM_ATTR HOT millis()