update
This commit is contained in:
parent
751053c64f
commit
e9f43d81a3
|
@ -60,15 +60,22 @@ namespace ratgdo {
|
||||||
this->update_state(value);
|
this->update_state(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
std::string mname = "rolling_code_counter2";
|
||||||
// A second subscription, which seem to overwrite the first subscription
|
// A second subscription, which seem to overwrite the first subscription
|
||||||
this->parent_->subscribe_rolling_code_counter([=](uint32_t value) {
|
this->parent_->subscribe_rolling_code_counter([=](uint32_t value, std::string mname) {
|
||||||
ESP_LOGD("XXX","A second rolling code counter subscription");
|
ESP_LOGD("XXX","A second rolling code counter subscription");
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (this->number_type_ == RATGDO_OPENING_DURATION) {
|
} else if (this->number_type_ == RATGDO_OPENING_DURATION) {
|
||||||
this->parent_->subscribe_opening_duration([=](float value) {
|
this->parent_->subscribe_opening_duration([=](float value) {
|
||||||
|
ESP_LOGD("ZZZ","The first opening duration subscription");
|
||||||
this->update_state(value);
|
this->update_state(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this->parent_->subscribe_opening_duration([=](float value) {
|
||||||
|
ESP_LOGD("ZZZ","The second opening duration subscription");
|
||||||
|
});
|
||||||
|
|
||||||
} else if (this->number_type_ == RATGDO_CLOSING_DURATION) {
|
} else if (this->number_type_ == RATGDO_CLOSING_DURATION) {
|
||||||
this->parent_->subscribe_closing_duration([=](float value) {
|
this->parent_->subscribe_closing_duration([=](float value) {
|
||||||
this->update_state(value);
|
this->update_state(value);
|
||||||
|
|
|
@ -597,13 +597,13 @@ namespace ratgdo {
|
||||||
this->protocol_->call(InactivateLearn {});
|
this->protocol_->call(InactivateLearn {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RATGDOComponent::subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f)
|
void RATGDOComponent::subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f, const std::string &name = "rolling_code_counter");
|
||||||
{
|
{
|
||||||
// change update to children is defered until after component loop
|
// change update to children is defered until after component loop
|
||||||
// if multiple changes occur during component loop, only the last one is notified
|
// if multiple changes occur during component loop, only the last one is notified
|
||||||
auto counter = this->protocol_->call(GetRollingCodeCounter {});
|
auto counter = this->protocol_->call(GetRollingCodeCounter {});
|
||||||
if (counter.tag == Result::Tag::rolling_code_counter) {
|
if (counter.tag == Result::Tag::rolling_code_counter) {
|
||||||
counter.value.rolling_code_counter.value->subscribe([=](uint32_t state) { defer("rolling_code_counter", [=] { f(state); }); });
|
counter.value.rolling_code_counter.value->subscribe([=](uint32_t state) { defer(name, [=] { f(state); }); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RATGDOComponent::subscribe_opening_duration(std::function<void(float)>&& f)
|
void RATGDOComponent::subscribe_opening_duration(std::function<void(float)>&& f)
|
||||||
|
|
|
@ -155,7 +155,7 @@ namespace ratgdo {
|
||||||
void sync();
|
void sync();
|
||||||
|
|
||||||
// children subscriptions
|
// children subscriptions
|
||||||
void subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f);
|
void subscribe_rolling_code_counter(std::function<void(uint32_t)>&& f, const std::string &name = "rolling_code_counter");
|
||||||
void subscribe_opening_duration(std::function<void(float)>&& f);
|
void subscribe_opening_duration(std::function<void(float)>&& f);
|
||||||
void subscribe_closing_duration(std::function<void(float)>&& f);
|
void subscribe_closing_duration(std::function<void(float)>&& f);
|
||||||
void subscribe_openings(std::function<void(uint16_t)>&& f);
|
void subscribe_openings(std::function<void(uint16_t)>&& f);
|
||||||
|
|
Loading…
Reference in New Issue