set_detected_target_* helpers

This commit is contained in:
Robin Thoni 2024-06-24 08:42:03 +00:00 committed by GitHub
parent 45a6ca7451
commit a2f02aba57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -101,6 +101,26 @@ void DfrobotSen0395Component::set_detected_(bool detected) {
#endif
}
void DfrobotSen0395Component::set_detected_target_distance_(int target, float value) {
#ifdef USE_SENSOR
if (is_valid_target_(target)) {
if (detected_targets_distance_sensors_[target - 1]) {
detected_targets_distance_sensors_[target - 1]->publish_state(value);
}
}
#endif
}
void DfrobotSen0395Component::set_detected_target_snr_(int target, float value) {
#ifdef USE_SENSOR
if (is_valid_target_(target)) {
if (detected_targets_snr_sensors_[target - 1]) {
detected_targets_snr_sensors_[target - 1]->publish_state(value);
}
}
#endif
}
int8_t CircularCommandQueue::enqueue(std::unique_ptr<Command> cmd) {
if (this->is_full()) {
ESP_LOGE(TAG, "Command queue is full");

View file

@ -139,6 +139,9 @@ class DfrobotSen0395Component : public uart::UARTDevice, public Component {
void set_detected_(bool detected);
void set_detected_target_distance_(int target, float value);
void set_detected_target_snr_(int target, float value);
bool is_valid_target_(int target) { return target >= 1 && target <= TARGET_COUNT; }
friend class Command;