mirror of
https://github.com/esphome/esphome.git
synced 2025-02-21 20:38:16 +00:00
* Hass.io ingress * Update * Remove global vars * Fix * Fixes * Fixes * Upgrade base image to 1.5.1 * Lint
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/core/esphal.h"
|
|
#include "esphome/components/output/float_output.h"
|
|
|
|
#ifdef ARDUINO_ARCH_ESP32
|
|
|
|
namespace esphome {
|
|
namespace ledc {
|
|
|
|
extern uint8_t next_ledc_channel;
|
|
|
|
class LEDCOutput : public output::FloatOutput, public Component {
|
|
public:
|
|
explicit LEDCOutput(GPIOPin *pin) : pin_(pin) { this->channel_ = next_ledc_channel++; }
|
|
|
|
void set_channel(uint8_t channel) { this->channel_ = channel; }
|
|
void set_bit_depth(uint8_t bit_depth) { this->bit_depth_ = bit_depth; }
|
|
void set_frequency(float frequency) { this->frequency_ = frequency; }
|
|
|
|
// ========== INTERNAL METHODS ==========
|
|
// (In most use cases you won't need these)
|
|
/// Setup LEDC.
|
|
void setup() override;
|
|
void dump_config() override;
|
|
/// HARDWARE setup priority
|
|
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
|
|
|
/// Override FloatOutput's write_state.
|
|
void write_state(float adjusted_value) override;
|
|
|
|
protected:
|
|
GPIOPin *pin_;
|
|
uint8_t channel_{};
|
|
uint8_t bit_depth_{};
|
|
float frequency_{};
|
|
};
|
|
|
|
} // namespace ledc
|
|
} // namespace esphome
|
|
|
|
#endif
|