mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 19:32:19 +01:00
fix: non-optional x/y target calculation for ld2450 (#9849)
This commit is contained in:
committed by
Jesse Hills
parent
93028a4d90
commit
8b0ad3072f
@@ -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;
|
||||||
sensor::Sensor *sx = this->move_x_sensors_[index];
|
// tx is used for further calculations, so always needs to be populated
|
||||||
if (sx != nullptr) {
|
|
||||||
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
|
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
|
||||||
tx = val;
|
tx = val;
|
||||||
|
sensor::Sensor *sx = this->move_x_sensors_[index];
|
||||||
|
if (sx != nullptr) {
|
||||||
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;
|
||||||
sensor::Sensor *sy = this->move_y_sensors_[index];
|
// ty is used for further calculations, so always needs to be populated
|
||||||
if (sy != nullptr) {
|
|
||||||
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
|
val = ld2450::decode_coordinate(this->buffer_data_[start], this->buffer_data_[start + 1]);
|
||||||
ty = val;
|
ty = val;
|
||||||
|
sensor::Sensor *sy = this->move_y_sensors_[index];
|
||||||
|
if (sy != nullptr) {
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user