16static uint16_t temp2regvalue(
float temp);
17static float regvalue2temp(uint16_t regvalue);
22 ESP_LOGE(TAG,
"'%s' - unable to read", LOG_STR_ARG(this->
get_log_name()));
33 ESP_LOGW(TAG,
"'%s' - unable to read temperature register", LOG_STR_ARG(this->
get_log_name()));
37 const float temp = regvalue2temp(regvalue);
42 LOG_SENSOR(
"",
"TMP1075 Sensor",
this);
46 " limit low : %.4f °C\n"
47 " limit high : %.4f °C\n"
55 this->config_.faults, this->config_.polarity, this->config_.alert_mode, this->config_.shutdown);
60 ESP_LOGE(TAG,
"'%s' - fault_count too low: %d", LOG_STR_ARG(this->
get_log_name()), faults);
64 ESP_LOGE(TAG,
"'%s' - fault_count too high: %d", LOG_STR_ARG(this->
get_log_name()), faults);
78 this->
config_.
oneshot, this->config_.rate, this->config_.faults, this->config_.polarity,
79 this->config_.alert_mode, this->config_.shutdown);
92 ESP_LOGW(TAG,
"'%s' - unable to write configuration register", LOG_STR_ARG(this->
get_log_name()));
101 ESP_LOGW(TAG,
"'%s' - unable to write low limit register", LOG_STR_ARG(this->
get_log_name()));
110 ESP_LOGW(TAG,
"'%s' - unable to write high limit register", LOG_STR_ARG(this->
get_log_name()));
115static uint16_t temp2regvalue(
const float temp) {
116 const int16_t regvalue =
static_cast<int16_t
>(temp / 0.0625f);
117 return static_cast<uint16_t
>(regvalue << 4);
120static float regvalue2temp(
const uint16_t regvalue) {
121 const int16_t signed_value = regvalue;
122 return (signed_value >> 4) * 0.0625f;
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
bool write_byte(uint8_t a_register, uint8_t data) const
bool read_byte(uint8_t a_register, uint8_t *data)
bool read_byte_16(uint8_t a_register, uint16_t *data)
bool write_byte_16(uint8_t a_register, uint16_t data) const
void publish_state(float state)
Publish a new state to the front-end.
void send_alert_limit_high_()
void dump_config() override
void send_alert_limit_low_()
void set_fault_count(int faults)
constexpr uint16_t EXPECT_DIEID
constexpr uint8_t REG_LLIM
constexpr uint8_t REG_TEMP
constexpr uint8_t REG_DIEID
constexpr uint8_t REG_HLIM
ESPHOME_LOG_TAG(TAG, "tmp1075")
constexpr uint8_t REG_CFGR