ESPHome 2025.5.0
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
22namespace esphome {
23namespace seeed_mr60fda2 {
24
25static const uint8_t DATA_BUF_MAX_SIZE = 28;
26static const uint8_t FRAME_BUF_MAX_SIZE = 37;
27static const uint8_t LEN_TO_HEAD_CKSUM = 8;
28static const uint8_t LEN_TO_DATA_FRAME = 9;
29
30static const uint8_t FRAME_HEADER_BUFFER = 0x01;
31static const uint16_t IS_FALL_TYPE_BUFFER = 0x0E02;
32static const uint16_t PEOPLE_EXIST_TYPE_BUFFER = 0x0F09;
33static const uint16_t RESULT_INSTALL_HEIGHT = 0x0E04;
34static const uint16_t RESULT_PARAMETERS = 0x0E06;
35static const uint16_t RESULT_HEIGHT_THRESHOLD = 0x0E08;
36static const uint16_t RESULT_SENSITIVITY = 0x0E0A;
37
46 LOCATE_HEAD_CKSUM_FRAME, // Header checksum: [from the first byte to the previous byte of the HEAD_CKSUM bit]
48 LOCATE_DATA_CKSUM_FRAME, // Data checksum: [from the first to the previous byte of the DATA_CKSUM bit]
50};
51
52static const float INSTALL_HEIGHT[7] = {2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f};
53static const float HEIGHT_THRESHOLD[7] = {0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f};
54static const float SENSITIVITY[3] = {3, 15, 30};
55
56static const char *const INSTALL_HEIGHT_STR[7] = {"2.4m", "2.5m", "2.6", "2.7m", "2.8", "2.9m", "3.0m"};
57static const char *const HEIGHT_THRESHOLD_STR[7] = {"0.0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m"};
58static const char *const SENSITIVITY_STR[3] = {"1", "2", "3"};
59
61 public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
62#ifdef USE_BINARY_SENSOR
63 SUB_BINARY_SENSOR(people_exist)
64 SUB_BINARY_SENSOR(fall_detected)
65#endif
66#ifdef USE_BUTTON
67 SUB_BUTTON(get_radar_parameters)
68 SUB_BUTTON(factory_reset)
69#endif
70#ifdef USE_SELECT
71 SUB_SELECT(install_height)
72 SUB_SELECT(height_threshold)
73 SUB_SELECT(sensitivity)
74#endif
75
76 protected:
77 uint8_t current_frame_locate_;
78 uint8_t current_frame_buf_[FRAME_BUF_MAX_SIZE];
79 uint8_t current_data_buf_[DATA_BUF_MAX_SIZE];
80 uint16_t current_frame_id_;
81 size_t current_frame_len_;
82 size_t current_data_frame_len_;
83 uint16_t current_frame_type_;
84
85 void split_frame_(uint8_t buffer);
86 void process_frame_();
87
88 public:
89 float get_setup_priority() const override { return esphome::setup_priority::LATE; }
90 void setup() override;
91 void dump_config() override;
92 void loop() override;
93 void set_install_height(uint8_t index);
94 void set_height_threshold(uint8_t index);
95 void set_sensitivity(uint8_t index);
97 void factory_reset();
98};
99
100} // namespace seeed_mr60fda2
101} // namespace esphome
const float LATE
For components that should be initialized at the very end of the setup process.
Definition component.cpp:28
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7