clamp Helper¶
-
template<size_t MaxDeps = 8, typename Source>
auto RxESP32::Helpers::Numerical::clamp(Source &source, decltype(source.get()) min_val, decltype(source.get()) max_val, const typename Computed<decltype(source.get()), 1, MaxDeps>::Options &options = {})¶ Clamp source value to a range [min, max].
Creates a Computed that constrains source values to the specified range.
- Since
v0.1.0
Signal<int> input(0); auto limited = clamp(input, -100, 100); input.set(150); // limited.get() == 100 input.set(-200); // limited.get() == -100 input.set(50); // limited.get() == 50Warning
Only accepts arithmetic types (integral and floating-point).
See Also¶
Numerical Helpers - Overview