ESPHome 2026.11.0b6
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
51class MR60FDA2Component final : public Component,
52 public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
53#ifdef USE_BINARY_SENSOR
54 SUB_BINARY_SENSOR(people_exist)
55 SUB_BINARY_SENSOR(fall_detected)
56#endif
57#ifdef USE_BUTTON
58 SUB_BUTTON(get_radar_parameters)
59 SUB_BUTTON(factory_reset)
60#endif
61#ifdef USE_SELECT
62 SUB_SELECT(install_height)
63 SUB_SELECT(height_threshold)
64 SUB_SELECT(sensitivity)
65#endif
66
67 protected:
68 uint8_t current_frame_locate_;
69 uint8_t current_frame_buf_[FRAME_BUF_MAX_SIZE];
70 uint8_t current_data_buf_[DATA_BUF_MAX_SIZE];
71 uint16_t current_frame_id_;
72 size_t current_frame_len_;
73 size_t current_data_frame_len_;
74 uint16_t current_frame_type_;
75
76 void split_frame_(uint8_t buffer);
77 void process_frame_();
78
79 public:
80 float get_setup_priority() const override { return esphome::setup_priority::LATE; }
81 void setup() override;
82 void dump_config() override;
83 void loop() override;
84 void set_install_height(uint8_t index);
85 void set_height_threshold(uint8_t index);
86 void set_sensitivity(uint8_t index);
88 void factory_reset();
89};
90
91} // namespace esphome::seeed_mr60fda2
uint32_t buffer
Definition gif.cpp:50
constexpr float LATE
For components that should be initialized at the very end of the setup process.
Definition component.h:59