fan state callback mechanism

master
HB 5 years ago
parent 3b52c00f28
commit 8b9f4c78b8

@ -18,7 +18,12 @@ void EmptyCustomFan::setup() {
} }
void EmptyCustomFan::loop() { 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() { void EmptyCustomFan::dump_config() {

@ -14,14 +14,10 @@ class EmptyCustomFan : public Component {
void setup() override; void setup() override;
void loop() override; void loop() override;
void dump_config() override; void dump_config() override;
void set_oscillating(output::BinaryOutput *oscillating) { this->oscillating_ = oscillating; }
void set_direction(output::BinaryOutput *direction) { this->direction_ = direction; }
protected: protected:
fan::FanState *fan_; fan::FanState *fan_;
output::BinaryOutput *output_; output::BinaryOutput *output_;
output::BinaryOutput *oscillating_{nullptr};
output::BinaryOutput *direction_{nullptr};
bool next_update_{true}; bool next_update_{true};
}; };

Loading…
Cancel
Save