fan state callback mechanism
This commit is contained in:
@@ -18,7 +18,12 @@ void EmptyCustomFan::setup() {
|
||||
}
|
||||
|
||||
void EmptyCustomFan::loop() {
|
||||
if (!this->next_update_) {
|
||||
return; //no state change, nothing to do
|
||||
}
|
||||
this->next_update_ = false;
|
||||
|
||||
//there was a state change, do something here.
|
||||
}
|
||||
|
||||
void EmptyCustomFan::dump_config() {
|
||||
|
||||
@@ -14,14 +14,10 @@ class EmptyCustomFan : public Component {
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
void set_oscillating(output::BinaryOutput *oscillating) { this->oscillating_ = oscillating; }
|
||||
void set_direction(output::BinaryOutput *direction) { this->direction_ = direction; }
|
||||
|
||||
protected:
|
||||
fan::FanState *fan_;
|
||||
output::BinaryOutput *output_;
|
||||
output::BinaryOutput *oscillating_{nullptr};
|
||||
output::BinaryOutput *direction_{nullptr};
|
||||
bool next_update_{true};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user