ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
mt6701.cpp
Go to the documentation of this file.
1#include "mt6701.h"
2#include "esphome/core/log.h"
3
4namespace esphome::mt6701 {
5
7 if (this->is_failed() || this->suspend_sampling_)
8 return false;
9
10 uint16_t count;
11 if (!this->read_count(count)) {
12 if (this->consecutive_errors_ < MAX_CONSECUTIVE_ERRORS) {
13 this->consecutive_errors_++;
14 if (this->consecutive_errors_ == MAX_CONSECUTIVE_ERRORS)
15 this->status_set_warning(LOG_STR("repeated read/CRC errors"));
16 }
17 return false;
18 }
19 if (this->consecutive_errors_ != 0) {
20 this->consecutive_errors_ = 0;
22 }
23
24 this->count_ = count;
25 return true;
26}
27
28} // namespace esphome::mt6701
bool is_failed() const
Definition component.h:274
void status_clear_warning()
Definition component.h:296
virtual bool read_count(uint16_t &count)=0
The current 14-bit count from the bus; false on a bus or CRC error.
bool read_encoder()
Read a fresh angle; false on a bus or CRC error, while suspended, or when setup failed.
Definition mt6701.cpp:6
unsigned count
Definition gif.cpp:51