mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 08:41:59 +00:00
[template.output] Avoid heap allocation for triggers
This commit is contained in:
@@ -8,22 +8,22 @@ namespace esphome::template_ {
|
||||
|
||||
class TemplateBinaryOutput final : public output::BinaryOutput {
|
||||
public:
|
||||
Trigger<bool> *get_trigger() const { return trigger_; }
|
||||
Trigger<bool> *get_trigger() { return &this->trigger_; }
|
||||
|
||||
protected:
|
||||
void write_state(bool state) override { this->trigger_->trigger(state); }
|
||||
void write_state(bool state) override { this->trigger_.trigger(state); }
|
||||
|
||||
Trigger<bool> *trigger_ = new Trigger<bool>();
|
||||
Trigger<bool> trigger_;
|
||||
};
|
||||
|
||||
class TemplateFloatOutput final : public output::FloatOutput {
|
||||
public:
|
||||
Trigger<float> *get_trigger() const { return trigger_; }
|
||||
Trigger<float> *get_trigger() { return &this->trigger_; }
|
||||
|
||||
protected:
|
||||
void write_state(float state) override { this->trigger_->trigger(state); }
|
||||
void write_state(float state) override { this->trigger_.trigger(state); }
|
||||
|
||||
Trigger<float> *trigger_ = new Trigger<float>();
|
||||
Trigger<float> trigger_;
|
||||
};
|
||||
|
||||
} // namespace esphome::template_
|
||||
|
||||
Reference in New Issue
Block a user