1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 11:22:24 +01:00

fix: non-optional x/y target calculation for ld2450 (#9849)

This commit is contained in:
Eric Hoffmann
2025-07-23 23:55:31 +02:00
committed by Jesse Hills
parent 93028a4d90
commit 8b0ad3072f

View File

@@ -477,10 +477,11 @@ void LD2450Component::handle_periodic_data_() {
// X // X
start = TARGET_X + index * 8; start = TARGET_X + index * 8;
is_moving = false; is_moving = false;
// tx is used for further calculations, so always needs to be populated
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
tx = val;
sensor::Sensor *sx = this->move_x_sensors_[index]; sensor::Sensor *sx = this->move_x_sensors_[index];
if (sx != nullptr) { if (sx != nullptr) {
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
tx = val;
if (this->cached_target_data_[index].x != val) { if (this->cached_target_data_[index].x != val) {
sx->publish_state(val); sx->publish_state(val);
this->cached_target_data_[index].x = val; this->cached_target_data_[index].x = val;
@@ -488,10 +489,11 @@ void LD2450Component::handle_periodic_data_() {
} }
// Y // Y
start = TARGET_Y + index * 8; start = TARGET_Y + index * 8;
// ty is used for further calculations, so always needs to be populated
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
ty = val;
sensor::Sensor *sy = this->move_y_sensors_[index]; sensor::Sensor *sy = this->move_y_sensors_[index];
if (sy != nullptr) { if (sy != nullptr) {
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
ty = val;
if (this->cached_target_data_[index].y != val) { if (this->cached_target_data_[index].y != val) {
sy->publish_state(val); sy->publish_state(val);
this->cached_target_data_[index].y = val; this->cached_target_data_[index].y = val;