ESPHome
2026.11.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
(!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
esphome::Component::status_comm_result
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
Definition
component.cpp:293
esphome::Parented< M5Stack8AngleComponent >::parent_
M5Stack8AngleComponent * parent_
Definition
helpers.h:2084
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:65
m5stack_8angle_sensor.h
esphome::m5stack_8angle
Definition
m5stack_8angle_binary_sensor.cpp:3
Generated by
1.12.0