ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ld2410s_number.h
Go to the documentation of this file.
1#pragma once
2
4#if defined(USE_NUMBER) && defined(USE_LD2410S_PARAMETERS)
5
6#include "ld2410s.h"
8
9namespace esphome::ld2410s {
10
12class LD2410SNumber final : public number::Number, public Parented<LD2410SComponent> {
13 public:
14 LD2410SNumber(Parameter parameter, float scale) : parameter_(parameter), scale_(scale) {}
15
16 void publish_raw(uint8_t raw) { this->publish_state(raw * this->scale_); }
17
18 protected:
19 void control(float value) override {
20 // Show the step the module got, not a value between two steps
21 const uint8_t raw = lroundf(value / this->scale_); // the schema keeps every parameter within a byte
22 if (this->parent_->set_parameter(this->parameter_, raw))
23 this->publish_raw(raw);
24 }
25
27 const float scale_;
28};
29
30} // namespace esphome::ld2410s
31
32#endif // USE_NUMBER && USE_LD2410S_PARAMETERS
uint8_t raw[35]
Definition bl0939.h:0
Helper class to easily give an object a parent of type T.
Definition helpers.h:1997
Edits one common parameter; scale converts the module's units to the number's.
void control(float value) override
LD2410SNumber(Parameter parameter, float scale)
Base-class for all numbers.
Definition number.h:29
void publish_state(float state)
Definition number.cpp:22
Parameter
The module's common parameters, in the order the parameter read answers them.
Definition ld2410s.h:28