7 namespace dfrobot_sen0395 {
9 static const char *
const TAG =
"dfrobot_sen0395";
14 ESP_LOGCONFIG(TAG,
"Dfrobot Mmwave Radar:");
15 #ifdef USE_BINARY_SENSOR 19 LOG_SWITCH(
" ",
"Sensor Active Switch", this->sensor_active_switch_);
20 LOG_SWITCH(
" ",
"Turn on LED Switch", this->turn_on_led_switch_);
21 LOG_SWITCH(
" ",
"Presence via UART Switch", this->presence_via_uart_switch_);
22 LOG_SWITCH(
" ",
"Start after Boot Switch", this->start_after_boot_switch_);
26 void DfrobotSen0395Component::loop() {
39 int8_t DfrobotSen0395Component::enqueue(std::unique_ptr<Command>
cmd) {
51 ESP_LOGVV(TAG,
"Buffer pos: %u %d", this->
read_pos_, byte);
77 if (message.rfind(
"leapMMW:/>") != std::string::npos) {
97 #ifdef USE_BINARY_SENSOR 104 if (this->is_full()) {
105 ESP_LOGE(TAG,
"Command queue is full");
107 }
else if (this->is_empty())
109 rear_ = (rear_ + 1) % COMMAND_QUEUE_SIZE;
110 commands_[rear_] = std::move(cmd);
115 if (this->is_empty())
117 std::unique_ptr<Command> dequeued_cmd = std::move(commands_[front_]);
118 if (front_ == rear_) {
122 front_ = (front_ + 1) % COMMAND_QUEUE_SIZE;
135 return commands_[front_]->execute(parent);
void write_str(const char *str)
virtual void dump_config()
uint32_t IRAM_ATTR HOT millis()
std::unique_ptr< Command > dequeue()
binary_sensor::BinarySensor * detected_binary_sensor_
uint8_t send_cmd_(const char *cmd, uint32_t duration)
bool read_byte(uint8_t *data)
uint8_t process(DfrobotSen0395Component *parent)
char read_buffer_[MMWAVE_READ_BUFFER_LENGTH]
void publish_state(bool state)
Publish a new state to the front-end.
CircularCommandQueue cmd_queue_
int8_t enqueue(std::unique_ptr< Command > cmd)
uint32_t ts_last_cmd_sent_
const uint8_t MMWAVE_READ_BUFFER_LENGTH
void set_detected_(bool detected)
Implementation of SPI Controller mode.