refactor(mr60fda2): get the string from the select itself

This commit is contained in:
Spencer Yan 2024-10-22 15:54:48 +08:00
parent 09cb47d427
commit 31d27cb8db

View file

@ -285,17 +285,17 @@ void MR60FDA2Component::process_frame_() {
float install_height_float; float install_height_float;
memcpy(&install_height_float, &current_install_height_int_, sizeof(float)); memcpy(&install_height_float, &current_install_height_int_, sizeof(float));
select_index_ = find_nearest_index_(install_height_float, INSTALL_HEIGHT, 7); select_index_ = find_nearest_index_(install_height_float, INSTALL_HEIGHT, 7);
this->install_height_select_->publish_state(INSTALL_HEIGHT_STR[select_index_]); this->install_height_select_->publish_state(this->install_height_select_.at(select_index_));
this->current_height_threshold_int_ = this->current_height_threshold_int_ =
encode_uint32(current_data_buf_[7], current_data_buf_[6], current_data_buf_[5], current_data_buf_[4]); encode_uint32(current_data_buf_[7], current_data_buf_[6], current_data_buf_[5], current_data_buf_[4]);
float height_threshold_float; float height_threshold_float;
memcpy(&height_threshold_float, &current_height_threshold_int_, sizeof(float)); memcpy(&height_threshold_float, &current_height_threshold_int_, sizeof(float));
select_index_ = find_nearest_index_(height_threshold_float, HEIGHT_THRESHOLD, 7); select_index_ = find_nearest_index_(height_threshold_float, HEIGHT_THRESHOLD, 7);
this->height_threshold_select_->publish_state(HEIGHT_THRESHOLD_STR[select_index_]); this->height_threshold_select_->publish_state(this->height_threshold_select_.at(select_index_));
this->current_sensitivity_ = this->current_sensitivity_ =
encode_uint32(current_data_buf_[11], current_data_buf_[10], current_data_buf_[9], current_data_buf_[8]); encode_uint32(current_data_buf_[11], current_data_buf_[10], current_data_buf_[9], current_data_buf_[8]);
select_index_ = find_nearest_index_(this->current_sensitivity_, SENSITIVITY, 3); select_index_ = find_nearest_index_(this->current_sensitivity_, SENSITIVITY, 3);
this->sensitivity_select_->publish_state(SENSITIVITY_STR[select_index_]); this->sensitivity_select_->publish_state(this->sensitivity_select_.at(select_index_));
ESP_LOGD(TAG, "Mounting height: %.2f, Height threshold: %.2f, Sensitivity: %u", install_height_float, ESP_LOGD(TAG, "Mounting height: %.2f, Height threshold: %.2f, Sensitivity: %u", install_height_float,
height_threshold_float, this->current_sensitivity_); height_threshold_float, this->current_sensitivity_);
this->current_frame_locate_ = LOCATE_FRAME_HEADER; this->current_frame_locate_ = LOCATE_FRAME_HEADER;