ESPHome  2024.6.1
micronova_number.cpp
Go to the documentation of this file.
1 #include "micronova_number.h"
2 
3 namespace esphome {
4 namespace micronova {
5 
6 void MicroNovaNumber::process_value_from_stove(int value_from_stove) {
7  float new_sensor_value = 0;
8 
9  if (value_from_stove == -1) {
10  this->publish_state(NAN);
11  return;
12  }
13 
14  switch (this->get_function()) {
16  new_sensor_value = ((float) value_from_stove) * this->traits.get_step();
17  break;
19  new_sensor_value = (float) value_from_stove;
20  break;
21  default:
22  break;
23  }
24  this->publish_state(new_sensor_value);
25 }
26 
27 void MicroNovaNumber::control(float value) {
28  uint8_t new_number = 0;
29 
30  switch (this->get_function()) {
32  new_number = (uint8_t) (value / this->traits.get_step());
33  break;
35  new_number = (uint8_t) value;
36  break;
37  default:
38  break;
39  }
40  this->micronova_->write_address(this->memory_write_location_, this->memory_address_, new_number);
41  this->micronova_->update();
42 }
43 
44 } // namespace micronova
45 } // namespace esphome
void publish_state(float state)
Definition: number.cpp:9
void write_address(uint8_t location, uint8_t address, uint8_t data)
Definition: micronova.cpp:118
void process_value_from_stove(int value_from_stove) override
NumberTraits traits
Definition: number.h:49
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void control(float value) override