From 295585379ecb4e4d12047e3cc3e608f8002193b7 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 24 Apr 2019 14:30:09 +0200 Subject: [PATCH] Auto-set LEDC channel Fixes https://github.com/esphome/issues/issues/258 --- esphome/components/ledc/ledc_output.h | 8 +++++--- esphome/components/time_based/time_based_cover.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/esphome/components/ledc/ledc_output.h b/esphome/components/ledc/ledc_output.h index 3672cab906..ce09db130a 100644 --- a/esphome/components/ledc/ledc_output.h +++ b/esphome/components/ledc/ledc_output.h @@ -9,9 +9,13 @@ namespace esphome { namespace ledc { +extern uint8_t next_ledc_channel; + class LEDCOutput : public output::FloatOutput, public Component { public: - explicit LEDCOutput(GPIOPin *pin) : pin_(pin) {} + 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; } @@ -35,8 +39,6 @@ class LEDCOutput : public output::FloatOutput, public Component { float frequency_{}; }; -extern uint8_t next_ledc_channel; - } // namespace ledc } // namespace esphome diff --git a/esphome/components/time_based/time_based_cover.cpp b/esphome/components/time_based/time_based_cover.cpp index 2aafaf09f4..bbc887debc 100644 --- a/esphome/components/time_based/time_based_cover.cpp +++ b/esphome/components/time_based/time_based_cover.cpp @@ -45,7 +45,7 @@ float TimeBasedCover::get_setup_priority() const { return setup_priority::DATA; CoverTraits TimeBasedCover::get_traits() { auto traits = CoverTraits(); traits.set_supports_position(true); - traits.set_is_assumed_state(false); + traits.set_is_assumed_state(true); return traits; } void TimeBasedCover::control(const CoverCall &call) {