26 if (line !=
nullptr) {
27 ESP_LOGV(TAG,
"Read from serial: %s", line);
39 ESP_LOGW(TAG,
"Invalid data read from sensor: %s", line);
49 float meters = float(millimeters) / 1000.0f;
50 ESP_LOGV(TAG,
"Distance from sensor: %d mm, %f m", millimeters, meters);
55 ESP_LOGCONFIG(TAG,
"HRXL MaxSonar WR Sensor:");
56 LOG_SENSOR(
" ",
"Distance",
this);
const char * partial()
The partial line, NUL terminated, for prompts with no line end; the first N - 1 characters on the byt...
bool overflowed() const
True only right after the feed() that found the line too long; the rest of that line is then dropped.
char * feed(uint8_t c)
Feed one byte; returns the completed line (empty lines included), valid until the next call,...
void reset()
Forget the partial line and start a new one with the next byte.
void dump_config() override
void loop() override
HRXL sensors output the format "R1234\r" at 6Hz The 1234 means 1234mm XL sensors output the format "R...
void handle_line_(const char *line, size_t len)
LineReader< 6, '\r', static_cast< char >(0xFF)> line_reader_
void publish_state(float state)
Publish a new state to the front-end.
bool read_available(F &&on_byte)
Same as read_available_chunks(), calling on_byte(uint8_t) once per byte.
ESPHOME_LOG_TAG(TAG, "hrxl.maxsonar.wr.sensor")
optional< T > parse_number(const char *str)
Parse an unsigned decimal number from a null-terminated string.