ESPHome
2024.11.0
|
Base class for all output components that can output a variable level, like PWM. More...
#include <float_output.h>
Public Member Functions | |
void | set_max_power (float max_power) |
Set the maximum power output of this component. More... | |
void | set_min_power (float min_power) |
Set the minimum power output of this component. More... | |
void | set_zero_means_zero (bool zero_means_zero) |
Sets this output to ignore min_power for a 0 state. More... | |
void | set_level (float state) |
Set the level of this float output, this is called from the front-end. More... | |
virtual void | update_frequency (float frequency) |
Set the frequency of the output for PWM outputs. More... | |
float | get_max_power () const |
Get the maximum power output. More... | |
float | get_min_power () const |
Get the minimum power output. More... | |
Public Member Functions inherited from esphome::output::BinaryOutput | |
void | set_inverted (bool inverted) |
Set the inversion state of this binary output. More... | |
void | set_power_supply (power_supply::PowerSupply *power_supply) |
Use this to connect up a power supply to this output. More... | |
virtual void | set_state (bool state) |
Enable or disable this binary output. More... | |
virtual void | turn_on () |
Enable this binary output. More... | |
virtual void | turn_off () |
Disable this binary output. More... | |
bool | is_inverted () const |
Return whether this binary output is inverted. More... | |
Protected Member Functions | |
void | write_state (bool state) override |
Implement BinarySensor's write_enabled; this should never be called. More... | |
virtual void | write_state (float state)=0 |
Protected Attributes | |
float | max_power_ {1.0f} |
float | min_power_ {0.0f} |
bool | zero_means_zero_ |
Protected Attributes inherited from esphome::output::BinaryOutput | |
bool | inverted_ {false} |
power_supply::PowerSupplyRequester | power_ {} |
Base class for all output components that can output a variable level, like PWM.
Floating Point Outputs always use output values in the range from 0.0 to 1.0 (inclusive), where 0.0 means off and 1.0 means fully on. While using floating point numbers might make computation slower, it makes using maths much easier and (in theory) supports all possible bit depths.
If you want to create a FloatOutput yourself, you essentially just have to override write_state(float). That method will be called for you with inversion and max-min power and offset to min power already applied.
This interface is compatible with BinaryOutput (and will automatically convert the binary states to floating point states for you). Additionally, this class provides a way for users to set a minimum and/or maximum power output
Definition at line 31 of file float_output.h.
float esphome::output::FloatOutput::get_max_power | ( | ) | const |
Get the maximum power output.
Definition at line 14 of file float_output.cpp.
float esphome::output::FloatOutput::get_min_power | ( | ) | const |
Get the minimum power output.
Definition at line 22 of file float_output.cpp.
void esphome::output::FloatOutput::set_level | ( | float | state | ) |
Set the level of this float output, this is called from the front-end.
state | The new state. |
Definition at line 24 of file float_output.cpp.
void esphome::output::FloatOutput::set_max_power | ( | float | max_power | ) |
Set the maximum power output of this component.
All values are multiplied by max_power - min_power and offset to min_power to get the adjusted value.
max_power | Automatically clamped from 0 or min_power to 1. |
Definition at line 10 of file float_output.cpp.
void esphome::output::FloatOutput::set_min_power | ( | float | min_power | ) |
Set the minimum power output of this component.
All values are multiplied by max_power - min_power and offset by min_power to get the adjusted value.
min_power | Automatically clamped from 0 to max_power or 1. |
Definition at line 16 of file float_output.cpp.
void esphome::output::FloatOutput::set_zero_means_zero | ( | bool | zero_means_zero | ) |
Sets this output to ignore min_power for a 0 state.
zero | True if a 0 state should mean 0 and not min_power. |
Definition at line 20 of file float_output.cpp.
|
inlinevirtual |
Set the frequency of the output for PWM outputs.
Implemented only by components which can set the output PWM frequency.
frequence | The new frequency. |
Reimplemented in esphome::ledc::LEDCOutput, esphome::libretiny_pwm::LibreTinyPWM, esphome::esp8266_pwm::ESP8266PWM, and esphome::rp2040_pwm::RP2040PWM.
Definition at line 67 of file float_output.h.
|
overrideprotectedvirtual |
Implement BinarySensor's write_enabled; this should never be called.
Implements esphome::output::BinaryOutput.
Definition at line 43 of file float_output.cpp.
|
protectedpure virtual |
Implemented in esphome::pid::PIDSimulator, esphome::sm2135::SM2135::Channel, esphome::ac_dimmer::AcDimmer, esphome::slow_pwm::SlowPWMOutput, esphome::bp1658cj::BP1658CJ::Channel, esphome::modbus_controller::ModbusFloatOutput, esphome::sm10bit_base::Sm10BitBase::Channel, esphome::my9231::MY9231OutputComponent::Channel, esphome::sm16716::SM16716::Channel, esphome::bp5758d::BP5758D::Channel, esphome::ledc::LEDCOutput, esphome::tlc59208f::TLC59208FChannel, esphome::pca9685::PCA9685Channel, esphome::rp2040_pwm::RP2040PWM, esphome::esp8266_pwm::ESP8266PWM, esphome::sigma_delta_output::SigmaDeltaOutput, esphome::libretiny_pwm::LibreTinyPWM, esphome::mcp4728::MCP4728Channel, esphome::template_::TemplateFloatOutput, esphome::esp32_dac::ESP32DAC, esphome::x9c::X9cOutput, esphome::pipsolar::PipsolarOutput, esphome::dac7678::DAC7678Channel, esphome::opentherm::OpenthermOutput, esphome::max6956::MAX6956LedChannel, esphome::sx1509::SX1509FloatOutputChannel, esphome::gp8403::GP8403Output, esphome::tlc5947::TLC5947Channel, esphome::tlc5971::TLC5971Channel, esphome::emc2101::EMC2101Output, esphome::mcp4725::MCP4725, and esphome::mcp47a1::MCP47A1.
|
protected |
Definition at line 83 of file float_output.h.
|
protected |
Definition at line 84 of file float_output.h.
|
protected |
Definition at line 85 of file float_output.h.