ESPHome  2024.11.2
float_output.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "binary_output.h"
5 
6 namespace esphome {
7 namespace output {
8 
9 #define LOG_FLOAT_OUTPUT(this) \
10  LOG_BINARY_OUTPUT(this) \
11  if (this->max_power_ != 1.0f) { \
12  ESP_LOGCONFIG(TAG, " Max Power: %.1f%%", this->max_power_ * 100.0f); \
13  } \
14  if (this->min_power_ != 0.0f) { \
15  ESP_LOGCONFIG(TAG, " Min Power: %.1f%%", this->min_power_ * 100.0f); \
16  }
17 
31 class FloatOutput : public BinaryOutput {
32  public:
39  void set_max_power(float max_power);
40 
47  void set_min_power(float min_power);
48 
53  void set_zero_means_zero(bool zero_means_zero);
54 
59  void set_level(float state);
60 
67  virtual void update_frequency(float frequency) {}
68 
69  // ========== INTERNAL METHODS ==========
70  // (In most use cases you won't need these)
71 
73  float get_max_power() const;
74 
76  float get_min_power() const;
77 
78  protected:
80  void write_state(bool state) override;
81  virtual void write_state(float state) = 0;
82 
83  float max_power_{1.0f};
84  float min_power_{0.0f};
86 };
87 
88 } // namespace output
89 } // namespace esphome
void set_zero_means_zero(bool zero_means_zero)
Sets this output to ignore min_power for a 0 state.
void set_max_power(float max_power)
Set the maximum power output of this component.
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
float get_max_power() const
Get the maximum power output.
void set_min_power(float min_power)
Set the minimum power output of this component.
void set_level(float state)
Set the level of this float output, this is called from the front-end.
uint16_le_t frequency
Definition: bl0942.h:72
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void write_state(bool state) override
Implement BinarySensor's write_enabled; this should never be called.
float get_min_power() const
Get the minimum power output.
virtual void update_frequency(float frequency)
Set the frequency of the output for PWM outputs.
Definition: float_output.h:67
bool state
Definition: fan.h:34