1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-21 20:38:16 +00:00
esphome/esphome/components/ledc/ledc_output.h
Otto Winter 5e5b9f2205
Hass.io Ingress (#519)
* Hass.io ingress

* Update

* Remove global vars

* Fix

* Fixes

* Fixes

* Upgrade base image to 1.5.1

* Lint
2019-04-24 17:08:05 +02:00

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