ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
m5stack_8angle_sensor.cpp
Go to the documentation of this file.
2
4
6 if (this->parent_ != nullptr) {
7 int32_t raw_pos = this->parent_->read_knob_pos_raw(this->channel_, this->bits_);
8 if (!this->status_comm_result(raw_pos != -1, LOG_STR("Could not read knob position from M5Stack 8Angle.")))
9 return;
10 if (this->raw_) {
11 this->publish_state(raw_pos);
12 } else {
13 float knob_pos = (float) raw_pos / ((1 << this->bits_) - 1);
14 this->publish_state(knob_pos);
15 }
16 };
17}
18
19} // namespace esphome::m5stack_8angle
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65