mirror of
https://github.com/esphome/esphome.git
synced 2026-10-15 02:32:49 +00:00
[seeed_mr60fda2] Compile without binary sensors or selects
This commit is contained in:
@@ -96,6 +96,7 @@ static bool validate_checksum(const uint8_t *data, size_t len, uint8_t expected_
|
||||
return calculate_checksum(data, len) == expected_checksum;
|
||||
}
|
||||
|
||||
#ifdef USE_SELECT
|
||||
static uint8_t find_nearest_index(float value, const float *arr, int size) {
|
||||
int nearest_index = 0;
|
||||
float min_diff = std::abs(value - arr[0]);
|
||||
@@ -108,6 +109,7 @@ static uint8_t find_nearest_index(float value, const float *arr, int size) {
|
||||
}
|
||||
return nearest_index;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Convert a float value to a byte array.
|
||||
@@ -250,15 +252,19 @@ void MR60FDA2Component::split_frame_(uint8_t buffer) {
|
||||
void MR60FDA2Component::process_frame_() {
|
||||
switch (this->current_frame_type_) {
|
||||
case IS_FALL_TYPE_BUFFER:
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->fall_detected_binary_sensor_ != nullptr) {
|
||||
this->fall_detected_binary_sensor_->publish_state(this->current_frame_buf_[LEN_TO_HEAD_CKSUM]);
|
||||
}
|
||||
#endif
|
||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||
break;
|
||||
|
||||
case PEOPLE_EXIST_TYPE_BUFFER:
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->people_exist_binary_sensor_ != nullptr)
|
||||
this->people_exist_binary_sensor_->publish_state(this->current_frame_buf_[LEN_TO_HEAD_CKSUM]);
|
||||
#endif
|
||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||
break;
|
||||
|
||||
@@ -293,6 +299,7 @@ void MR60FDA2Component::process_frame_() {
|
||||
float install_height_float = 0;
|
||||
float height_threshold_float = 0;
|
||||
uint32_t current_sensitivity = 0;
|
||||
#ifdef USE_SELECT
|
||||
if (this->install_height_select_ != nullptr) {
|
||||
uint32_t current_install_height_int =
|
||||
encode_uint32(current_data_buf_[3], current_data_buf_[2], current_data_buf_[1], current_data_buf_[0]);
|
||||
@@ -318,6 +325,7 @@ void MR60FDA2Component::process_frame_() {
|
||||
uint32_t select_index = find_nearest_index(current_sensitivity, SENSITIVITY, 3);
|
||||
this->sensitivity_select_->publish_state(select_index);
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGD(TAG, "Mounting height: %.2f, Height threshold: %.2f, Sensitivity: %" PRIu32, install_height_float,
|
||||
height_threshold_float, current_sensitivity);
|
||||
|
||||
Reference in New Issue
Block a user