ESPHome
2025.5.0
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
{
4
namespace
m5stack_8angle {
5
6
void
M5Stack8AngleKnobSensor::update
() {
7
if
(this->
parent_
!=
nullptr
) {
8
int32_t raw_pos = this->
parent_
->read_knob_pos_raw(this->
channel_
, this->
bits_
);
9
if
(raw_pos == -1) {
10
this->
status_set_warning
(
"Could not read knob position from M5Stack 8Angle."
);
11
return
;
12
}
13
if
(this->
raw_
) {
14
this->
publish_state
(raw_pos);
15
}
else
{
16
float
knob_pos = (float) raw_pos / ((1 << this->
bits_
) - 1);
17
this->
publish_state
(knob_pos);
18
}
19
this->
status_clear_warning
();
20
};
21
}
22
23
}
// namespace m5stack_8angle
24
}
// namespace esphome
esphome::Component::status_set_warning
void status_set_warning(const char *message="unspecified")
Definition
component.cpp:161
esphome::Component::status_clear_warning
void status_clear_warning()
Definition
component.cpp:178
esphome::Parented< M5Stack8AngleComponent >::parent_
M5Stack8AngleComponent * parent_
Definition
helpers.h:549
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::raw_
bool raw_
Definition
m5stack_8angle_sensor.h:23
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::bits_
AnalogBits bits_
Definition
m5stack_8angle_sensor.h:22
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::update
void update() override
Definition
m5stack_8angle_sensor.cpp:6
esphome::m5stack_8angle::M5Stack8AngleKnobSensor::channel_
uint8_t channel_
Definition
m5stack_8angle_sensor.h:21
esphome::sensor::Sensor::publish_state
void publish_state(float state)
Publish a new state to the front-end.
Definition
sensor.cpp:39
m5stack_8angle_sensor.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
Generated by
1.12.0