ESPHome  2024.11.0
emc2101.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace emc2101 {
8 
24 };
25 
29 class Emc2101Component : public Component, public i2c::I2CDevice {
30  public:
35  void set_dac_mode(bool dac_mode) {
36  this->dac_mode_ = dac_mode;
37  this->max_output_value_ = 63;
38  }
39 
44  void set_pwm_resolution(uint8_t resolution) {
45  this->pwm_resolution_ = resolution;
46  this->max_output_value_ = 2 * resolution;
47  }
48 
53  void set_pwm_divider(uint8_t divider) { this->pwm_divider_ = divider; }
54 
60  this->dac_conversion_rate_ = conversion_rate;
61  }
62 
67  void set_inverted(bool inverted) { this->inverted_ = inverted; }
68 
73  void set_duty_cycle(float value);
74 
79  float get_duty_cycle();
80 
86 
92 
97  float get_speed();
98 
100  void setup() override;
102  void dump_config() override;
104  float get_setup_priority() const override;
105 
106  bool dac_mode_{false};
107  bool inverted_{false};
110  uint8_t pwm_divider_;
112 };
113 
114 } // namespace emc2101
115 } // namespace esphome
void set_inverted(bool inverted)
Inverts the polarity of the Fan output.
Definition: emc2101.h:67
void set_dac_conversion_rate(Emc2101DACConversionRate conversion_rate)
Sets the DAC conversion rate (how many conversions per second).
Definition: emc2101.h:59
void set_pwm_divider(uint8_t divider)
Sets the PWM divider used to derive the PWM frequency.
Definition: emc2101.h:53
void dump_config() override
Used by ESPHome framework.
Definition: emc2101.cpp:93
Emc2101DACConversionRate
Enum listing all DAC conversion rates for the EMC2101.
Definition: emc2101.h:13
Emc2101DACConversionRate dac_conversion_rate_
Definition: emc2101.h:111
void set_pwm_resolution(uint8_t resolution)
Sets the PWM resolution.
Definition: emc2101.h:44
float get_internal_temperature()
Gets the internal temperature sensor reading.
Definition: emc2101.cpp:129
void setup() override
Used by ESPHome framework.
Definition: emc2101.cpp:59
float get_duty_cycle()
Gets the Fan output duty cycle.
Definition: emc2101.cpp:119
float get_speed()
Gets the tachometer speed sensor reading.
Definition: emc2101.cpp:154
float get_external_temperature()
Gets the external temperature sensor reading.
Definition: emc2101.cpp:139
void set_duty_cycle(float value)
Sets the Fan output duty cycle.
Definition: emc2101.cpp:109
This class includes support for the EMC2101 i2c fan controller.
Definition: emc2101.h:29
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
float get_setup_priority() const override
Used by ESPHome framework.
Definition: emc2101.cpp:57
void set_dac_mode(bool dac_mode)
Sets the mode of the output.
Definition: emc2101.h:35