ESPHome
2026.6.0-dev
Loading...
Searching...
No Matches
esphome
components
m5stack_8angle
sensor
m5stack_8angle_sensor.cpp
Go to the documentation of this file.
1
#include "
m5stack_8angle_sensor.h
"
2
3
namespace
esphome::m5stack_8angle
{
4
5
void
M5Stack8AngleKnobSensor::update
() {
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
}
18
this->
status_clear_warning
();
19
};
20
}
21
22
}
// namespace esphome::m5stack_8angle
esphome::Component::status_set_warning
void status_set_warning()
Definition
component.cpp:370
esphome::Component::status_clear_warning
void status_clear_warning()
Definition
component.h:289
esphome::Parented< M5Stack8AngleComponent >::parent_
M5Stack8AngleComponent * parent_
Definition
helpers.h:1872
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::raw_
bool raw_
Definition
m5stack_8angle_sensor.h:22
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::bits_
AnalogBits bits_
Definition
m5stack_8angle_sensor.h:21
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::update
void update() override
Definition
m5stack_8angle_sensor.cpp:5
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::channel_
uint8_t channel_
Definition
m5stack_8angle_sensor.h:20
esphome::sensor::Sensor::publish_state
void publish_state(float state)
Publish a new state to the front-end.
Definition
sensor.cpp:68
m5stack_8angle_sensor.h
esphome::m5stack_8angle
Definition
m5stack_8angle_binary_sensor.cpp:3
Generated by
1.12.0