ESPHome  2022.9.2
fan_traits.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace esphome {
4 namespace fan {
5 
6 class FanTraits {
7  public:
8  FanTraits() = default;
9  FanTraits(bool oscillation, bool speed, bool direction, int speed_count)
10  : oscillation_(oscillation), speed_(speed), direction_(direction), speed_count_(speed_count) {}
11 
13  bool supports_oscillation() const { return this->oscillation_; }
15  void set_oscillation(bool oscillation) { this->oscillation_ = oscillation; }
17  bool supports_speed() const { return this->speed_; }
19  void set_speed(bool speed) { this->speed_ = speed; }
21  int supported_speed_count() const { return this->speed_count_; }
23  void set_supported_speed_count(int speed_count) { this->speed_count_ = speed_count; }
25  bool supports_direction() const { return this->direction_; }
27  void set_direction(bool direction) { this->direction_ = direction; }
28 
29  protected:
30  bool oscillation_{false};
31  bool speed_{false};
32  bool direction_{false};
33  int speed_count_{};
34 };
35 
36 } // namespace fan
37 } // namespace esphome
int speed
Definition: fan.h:35
bool supports_direction() const
Return if this fan supports changing direction.
Definition: fan_traits.h:25
bool supports_oscillation() const
Return if this fan supports oscillation.
Definition: fan_traits.h:13
int supported_speed_count() const
Return how many speed levels the fan has.
Definition: fan_traits.h:21
FanDirection direction
Definition: fan.h:37
void set_oscillation(bool oscillation)
Set whether this fan supports oscillation.
Definition: fan_traits.h:15
void set_speed(bool speed)
Set whether this fan supports speed levels.
Definition: fan_traits.h:19
void set_direction(bool direction)
Set whether this fan supports changing direction.
Definition: fan_traits.h:27
Definition: a4988.cpp:4
FanTraits(bool oscillation, bool speed, bool direction, int speed_count)
Definition: fan_traits.h:9
void set_supported_speed_count(int speed_count)
Set how many speed levels this fan has.
Definition: fan_traits.h:23
bool supports_speed() const
Return if this fan supports speed modes.
Definition: fan_traits.h:17