ESPHome 2026.6.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 (raw_pos == -1) {
9 this->status_set_warning(LOG_STR("Could not read knob position from M5Stack 8Angle."));
10 return;
11 }
12 if (this->raw_) {
13 this->publish_state(raw_pos);
14 } else {
15 float knob_pos = (float) raw_pos / ((1 << this->bits_) - 1);
16 this->publish_state(knob_pos);
17 }
19 };
20}
21
22} // namespace esphome::m5stack_8angle
void status_clear_warning()
Definition component.h:289
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68