7 #ifdef USE_BINARY_SENSOR 17 namespace dfrobot_sen0395 {
24 static const uint8_t COMMAND_QUEUE_SIZE = 20;
29 std::unique_ptr<Command>
dequeue();
37 std::unique_ptr<Command>
commands_[COMMAND_QUEUE_SIZE];
42 SUB_SWITCH(sensor_active)
43 SUB_SWITCH(turn_on_led)
44 SUB_SWITCH(presence_via_uart)
45 SUB_SWITCH(start_after_boot)
49 void dump_config()
override;
51 void set_active(
bool active) {
52 if (active != active_) {
54 if (this->sensor_active_switch_ !=
nullptr)
55 this->sensor_active_switch_->publish_state(active);
60 bool is_active() {
return active_; }
62 void set_led_active(
bool active) {
63 if (led_active_ != active) {
65 if (this->turn_on_led_switch_ !=
nullptr)
66 this->turn_on_led_switch_->publish_state(active);
71 bool is_led_active() {
return led_active_; }
73 void set_uart_presence_active(
bool active) {
74 uart_presence_active_ = active;
76 if (this->presence_via_uart_switch_ !=
nullptr)
77 this->presence_via_uart_switch_->publish_state(active);
80 bool is_uart_presence_active() {
return uart_presence_active_; }
82 void set_start_after_boot(
bool start) {
83 start_after_boot_ = start;
85 if (this->start_after_boot_switch_ !=
nullptr)
86 this->start_after_boot_switch_->publish_state(start);
89 bool does_start_after_boot() {
return start_after_boot_; }
91 #ifdef USE_BINARY_SENSOR 93 detected_binary_sensor_ = detected_binary_sensor;
100 #ifdef USE_BINARY_SENSOR 104 bool detected_{
false};
106 bool led_active_{
false};
107 bool uart_presence_active_{
false};
108 bool start_after_boot_{
false};
112 uint32_t ts_last_cmd_sent_{0};
114 uint8_t read_message_();
115 uint8_t find_prompt_();
116 uint8_t send_cmd_(
const char *cmd, uint32_t duration);
118 void set_detected_(
bool detected);
std::unique_ptr< Command > dequeue()
uint8_t process(DfrobotSen0395Component *parent)
CircularCommandQueue cmd_queue_
int8_t enqueue(std::unique_ptr< Command > cmd)
const uint8_t MMWAVE_READ_BUFFER_LENGTH
std::unique_ptr< Command > commands_[COMMAND_QUEUE_SIZE]
Implementation of SPI Controller mode.
Base class for all binary_sensor-type classes.