ESPHome  2024.11.0
gate_config_number.cpp
Go to the documentation of this file.
1 #include "gate_config_number.h"
2 #include "esphome/core/helpers.h"
3 #include "esphome/core/log.h"
4 
5 static const char *const TAG = "LD2420.number";
6 
7 namespace esphome {
8 namespace ld2420 {
9 
10 void LD2420TimeoutNumber::control(float timeout) {
11  this->publish_state(timeout);
12  this->parent_->new_config.timeout = timeout;
13 }
14 
15 void LD2420MinDistanceNumber::control(float min_gate) {
16  if ((uint16_t) min_gate > this->parent_->new_config.max_gate) {
17  min_gate = this->parent_->get_min_gate_distance_value();
18  } else {
19  this->parent_->new_config.min_gate = (uint16_t) min_gate;
20  }
21  this->publish_state(min_gate);
22 }
23 
24 void LD2420MaxDistanceNumber::control(float max_gate) {
25  if ((uint16_t) max_gate < this->parent_->new_config.min_gate) {
26  max_gate = this->parent_->get_max_gate_distance_value();
27  } else {
28  this->parent_->new_config.max_gate = (uint16_t) max_gate;
29  }
30  this->publish_state(max_gate);
31 }
32 
33 void LD2420GateSelectNumber::control(float gate_select) {
34  const uint8_t gate = (uint8_t) gate_select;
35  this->publish_state(gate_select);
36  this->parent_->publish_gate_move_threshold(gate);
37  this->parent_->publish_gate_still_threshold(gate);
38 }
39 
40 void LD2420MoveSensFactorNumber::control(float move_factor) {
41  this->publish_state(move_factor);
42  this->parent_->gate_move_sensitivity_factor = move_factor;
43 }
44 
45 void LD2420StillSensFactorNumber::control(float still_factor) {
46  this->publish_state(still_factor);
47  this->parent_->gate_still_sensitivity_factor = still_factor;
48 }
49 
51 
52 void LD2420MoveThresholdNumbers::control(float move_threshold) {
53  this->publish_state(move_threshold);
54  if (!this->parent_->is_gate_select()) {
55  this->parent_->new_config.move_thresh[this->gate_] = move_threshold;
56  } else {
57  this->parent_->new_config.move_thresh[this->parent_->get_gate_select_value()] = move_threshold;
58  }
59 }
60 
62 
63 void LD2420StillThresholdNumbers::control(float still_threshold) {
64  this->publish_state(still_threshold);
65  if (!this->parent_->is_gate_select()) {
66  this->parent_->new_config.still_thresh[this->gate_] = still_threshold;
67  } else {
68  this->parent_->new_config.still_thresh[this->parent_->get_gate_select_value()] = still_threshold;
69  }
70 }
71 
72 } // namespace ld2420
73 } // namespace esphome
void control(float still_factor) override
void control(float move_threshold) override
void publish_state(float state)
Definition: number.cpp:9
void control(float gate_select) override
void control(float still_threshold) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void control(float timeout) override
void control(float move_factor) override