25 #ifdef USE_TEXT_SENSOR 28 #ifdef USE_BINARY_SENSOR 40 static const uint8_t DEFAULT_PRESENCE_TIMEOUT = 5;
41 static const uint8_t MAX_LINE_LENGTH = 60;
42 static const uint8_t MAX_TARGETS = 3;
43 static const uint8_t MAX_ZONES = 3;
81 static const std::map<std::string, uint8_t> BAUD_RATE_ENUM_TO_INT{
90 static const std::map<ZoneTypeStructure, std::string> ZONE_TYPE_INT_TO_ENUM{
94 static const std::map<std::string, uint8_t> ZONE_TYPE_ENUM_TO_INT{
98 static const uint8_t CMD_FRAME_HEADER[4] = {0xFD, 0xFC, 0xFB, 0xFA};
99 static const uint8_t CMD_FRAME_END[4] = {0x04, 0x03, 0x02, 0x01};
114 SUB_SENSOR(target_count)
115 SUB_SENSOR(still_target_count)
116 SUB_SENSOR(moving_target_count)
118 #ifdef USE_BINARY_SENSOR 119 SUB_BINARY_SENSOR(target)
120 SUB_BINARY_SENSOR(moving_target)
121 SUB_BINARY_SENSOR(still_target)
123 #ifdef USE_TEXT_SENSOR 128 SUB_SELECT(baud_rate)
129 SUB_SELECT(zone_type)
132 SUB_SWITCH(bluetooth)
133 SUB_SWITCH(multi_target)
140 SUB_NUMBER(presence_timeout)
145 void setup()
override;
146 void dump_config()
override;
147 void loop()
override;
148 void set_presence_timeout();
149 void set_throttle(uint16_t value) { this->throttle_ = value; };
150 void read_all_info();
151 void query_zone_info();
152 void restart_and_read_all_info();
153 void set_bluetooth(
bool enable);
154 void set_multi_target(
bool enable);
155 void set_baud_rate(
const std::string &
state);
156 void set_zone_type(
const std::string &state);
157 void publish_zone_type();
158 void factory_reset();
159 #ifdef USE_TEXT_SENSOR 163 void set_zone_coordinate(uint8_t zone);
172 void set_move_resolution_sensor(uint8_t target,
sensor::Sensor *s);
173 void set_zone_target_count_sensor(uint8_t zone,
sensor::Sensor *s);
174 void set_zone_still_target_count_sensor(uint8_t zone,
sensor::Sensor *s);
175 void set_zone_moving_target_count_sensor(uint8_t zone,
sensor::Sensor *s);
177 void reset_radar_zone();
178 void set_radar_zone(int32_t zone_type, int32_t zone1_x1, int32_t zone1_y1, int32_t zone1_x2, int32_t zone1_y2,
179 int32_t zone2_x1, int32_t zone2_y1, int32_t zone2_x2, int32_t zone2_y2, int32_t zone3_x1,
180 int32_t zone3_y1, int32_t zone3_x2, int32_t zone3_y2);
183 void send_command_(uint8_t command_str,
const uint8_t *command_value, uint8_t command_value_len);
184 void set_config_mode_(
bool enable);
185 void handle_periodic_data_(uint8_t *buffer, uint8_t
len);
186 bool handle_ack_data_(uint8_t *buffer, uint8_t len);
187 void process_zone_(uint8_t *buffer);
188 void readline_(
int readch, uint8_t *buffer, uint8_t len);
191 void query_target_tracking_mode_();
194 void send_set_zone_command_();
195 void save_to_flash_(
float value);
196 float restore_from_flash_();
197 bool get_timeout_status_(uint32_t check_millis);
198 uint8_t count_targets_in_zone_(
const Zone &zone,
bool is_moving);
202 uint8_t buffer_pos_ = 0;
203 uint8_t buffer_data_[MAX_LINE_LENGTH];
204 uint32_t last_periodic_millis_ = 0;
205 uint32_t presence_millis_ = 0;
206 uint32_t still_presence_millis_ = 0;
207 uint32_t moving_presence_millis_ = 0;
208 uint16_t throttle_ = 0;
209 uint16_t timeout_ = 5;
210 uint8_t zone_type_ = 0;
211 std::string version_{};
218 std::vector<sensor::Sensor *> move_x_sensors_ = std::vector<sensor::Sensor *>(MAX_TARGETS);
219 std::vector<sensor::Sensor *> move_y_sensors_ = std::vector<sensor::Sensor *>(MAX_TARGETS);
220 std::vector<sensor::Sensor *> move_speed_sensors_ = std::vector<sensor::Sensor *>(MAX_TARGETS);
221 std::vector<sensor::Sensor *> move_angle_sensors_ = std::vector<sensor::Sensor *>(MAX_TARGETS);
222 std::vector<sensor::Sensor *> move_distance_sensors_ = std::vector<sensor::Sensor *>(MAX_TARGETS);
223 std::vector<sensor::Sensor *> move_resolution_sensors_ = std::vector<sensor::Sensor *>(MAX_TARGETS);
224 std::vector<sensor::Sensor *> zone_target_count_sensors_ = std::vector<sensor::Sensor *>(MAX_ZONES);
225 std::vector<sensor::Sensor *> zone_still_target_count_sensors_ = std::vector<sensor::Sensor *>(MAX_ZONES);
226 std::vector<sensor::Sensor *> zone_moving_target_count_sensors_ = std::vector<sensor::Sensor *>(MAX_ZONES);
228 #ifdef USE_TEXT_SENSOR 229 std::vector<text_sensor::TextSensor *> direction_text_sensors_ = std::vector<text_sensor::TextSensor *>(3);
Base-class for all numbers.
Implementation of SPI Controller mode.
Base-class for all sensors.
ESPPreferenceObject pref_