ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
mt6701_spi_field_status.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
4
5namespace esphome::mt6701_spi {
6
7ESPHOME_LOG_TAG(TAG, "mt6701_spi.text_sensor");
8
9// Indexed by Mg[1:0]; 0b11 is reserved in the datasheet
10PROGMEM_STRING_TABLE(FieldStatusStrings, "OK", "TOO_STRONG", "TOO_WEAK", "UNKNOWN");
11
13 if (!this->parent_->read_encoder())
14 return;
15 char text[FieldStatusStrings::MAX_LENGTH + 1];
16 ESPHOME_strncpy_P(text,
17 reinterpret_cast<ESPHOME_PGM_P>(FieldStatusStrings::get_progmem_str(
18 this->parent_->get_status() & 0x03, FieldStatusStrings::LAST_INDEX)),
19 sizeof(text));
20 this->publish_state(text);
21}
22
24 LOG_TEXT_SENSOR("", "MT6701 field status", this);
25 LOG_UPDATE_INTERVAL(this);
26}
27
28} // namespace esphome::mt6701_spi
void publish_state(const std::string &state)
Definition text_sensor.h:42
ESPHOME_LOG_TAG(TAG, "mt6701_spi.binary_sensor")
PROGMEM_STRING_TABLE(FieldStatusStrings, "OK", "TOO_STRONG", "TOO_WEAK", "UNKNOWN")