mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	dry
This commit is contained in:
		| @@ -118,14 +118,12 @@ class LambdaFilter : public Filter { | ||||
|  */ | ||||
| class StatelessLambdaFilter : public Filter { | ||||
|  public: | ||||
|   using stateless_lambda_filter_t = optional<bool> (*)(bool); | ||||
|  | ||||
|   explicit StatelessLambdaFilter(stateless_lambda_filter_t f) : f_(f) {} | ||||
|   explicit StatelessLambdaFilter(optional<bool> (*f)(bool)) : f_(f) {} | ||||
|  | ||||
|   optional<bool> new_value(bool value) override { return this->f_(value); } | ||||
|  | ||||
|  protected: | ||||
|   stateless_lambda_filter_t f_; | ||||
|   optional<bool> (*f_)(bool); | ||||
| }; | ||||
|  | ||||
| class SettleFilter : public Filter, public Component { | ||||
|   | ||||
| @@ -303,14 +303,12 @@ class LambdaFilter : public Filter { | ||||
|  */ | ||||
| class StatelessLambdaFilter : public Filter { | ||||
|  public: | ||||
|   using stateless_lambda_filter_t = optional<float> (*)(float); | ||||
|  | ||||
|   explicit StatelessLambdaFilter(stateless_lambda_filter_t lambda_filter) : lambda_filter_(lambda_filter) {} | ||||
|   explicit StatelessLambdaFilter(optional<float> (*lambda_filter)(float)) : lambda_filter_(lambda_filter) {} | ||||
|  | ||||
|   optional<float> new_value(float value) override { return this->lambda_filter_(value); } | ||||
|  | ||||
|  protected: | ||||
|   stateless_lambda_filter_t lambda_filter_; | ||||
|   optional<float> (*lambda_filter_)(float); | ||||
| }; | ||||
|  | ||||
| /// A simple filter that adds `offset` to each value it receives. | ||||
|   | ||||
| @@ -69,14 +69,12 @@ class LambdaFilter : public Filter { | ||||
|  */ | ||||
| class StatelessLambdaFilter : public Filter { | ||||
|  public: | ||||
|   using stateless_lambda_filter_t = optional<std::string> (*)(std::string); | ||||
|  | ||||
|   explicit StatelessLambdaFilter(stateless_lambda_filter_t lambda_filter) : lambda_filter_(lambda_filter) {} | ||||
|   explicit StatelessLambdaFilter(optional<std::string> (*lambda_filter)(std::string)) : lambda_filter_(lambda_filter) {} | ||||
|  | ||||
|   optional<std::string> new_value(std::string value) override { return this->lambda_filter_(value); } | ||||
|  | ||||
|  protected: | ||||
|   stateless_lambda_filter_t lambda_filter_; | ||||
|   optional<std::string> (*lambda_filter_)(std::string); | ||||
| }; | ||||
|  | ||||
| /// A simple filter that converts all text to uppercase | ||||
|   | ||||
		Reference in New Issue
	
	Block a user