ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
seeed_mr60fda2.h
Go to the documentation of this file.
1#pragma once
4#ifdef USE_BINARY_SENSOR
6#endif
7#ifdef USE_BUTTON
9#endif
10#ifdef USE_SELECT
12#endif
13#ifdef USE_TEXT_SENSOR
15#endif
19
20#include <map>
21
23
24static const uint8_t DATA_BUF_MAX_SIZE = 28;
25static const uint8_t FRAME_BUF_MAX_SIZE = 37;
26static const uint8_t LEN_TO_HEAD_CKSUM = 8;
27static const uint8_t LEN_TO_DATA_FRAME = 9;
28
29static const uint8_t FRAME_HEADER_BUFFER = 0x01;
30static const uint16_t IS_FALL_TYPE_BUFFER = 0x0E02;
31static const uint16_t PEOPLE_EXIST_TYPE_BUFFER = 0x0F09;
32static const uint16_t RESULT_INSTALL_HEIGHT = 0x0E04;
33static const uint16_t RESULT_PARAMETERS = 0x0E06;
34static const uint16_t RESULT_HEIGHT_THRESHOLD = 0x0E08;
35static const uint16_t RESULT_SENSITIVITY = 0x0E0A;
36
45 LOCATE_HEAD_CKSUM_FRAME, // Header checksum: [from the first byte to the previous byte of the HEAD_CKSUM bit]
47 LOCATE_DATA_CKSUM_FRAME, // Data checksum: [from the first to the previous byte of the DATA_CKSUM bit]
49};
50
51static const float INSTALL_HEIGHT[7] = {2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f};
52static const float HEIGHT_THRESHOLD[7] = {0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f};
53static const float SENSITIVITY[3] = {3, 15, 30};
54
55static const char *const INSTALL_HEIGHT_STR[7] = {"2.4m", "2.5m", "2.6", "2.7m", "2.8", "2.9m", "3.0m"};
56static const char *const HEIGHT_THRESHOLD_STR[7] = {"0.0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m"};
57static const char *const SENSITIVITY_STR[3] = {"1", "2", "3"};
58
60 public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
61#ifdef USE_BINARY_SENSOR
62 SUB_BINARY_SENSOR(people_exist)
63 SUB_BINARY_SENSOR(fall_detected)
64#endif
65#ifdef USE_BUTTON
66 SUB_BUTTON(get_radar_parameters)
67 SUB_BUTTON(factory_reset)
68#endif
69#ifdef USE_SELECT
70 SUB_SELECT(install_height)
71 SUB_SELECT(height_threshold)
72 SUB_SELECT(sensitivity)
73#endif
74
75 protected:
76 uint8_t current_frame_locate_;
77 uint8_t current_frame_buf_[FRAME_BUF_MAX_SIZE];
78 uint8_t current_data_buf_[DATA_BUF_MAX_SIZE];
79 uint16_t current_frame_id_;
80 size_t current_frame_len_;
81 size_t current_data_frame_len_;
82 uint16_t current_frame_type_;
83
84 void split_frame_(uint8_t buffer);
85 void process_frame_();
86
87 public:
88 float get_setup_priority() const override { return esphome::setup_priority::LATE; }
89 void setup() override;
90 void dump_config() override;
91 void loop() override;
92 void set_install_height(uint8_t index);
93 void set_height_threshold(uint8_t index);
94 void set_sensitivity(uint8_t index);
96 void factory_reset();
97};
98
99} // namespace esphome::seeed_mr60fda2
constexpr float LATE
For components that should be initialized at the very end of the setup process.
Definition component.h:57