rateOfChange Helper

template<size_t MaxDeps = 8, typename Source>
auto RxESP32::Helpers::Numerical::rateOfChange(Source &source, const typename Computed<decltype(source.get()), 1, MaxDeps>::Options &options = {})

Calculate rate of change per second.

Creates a Computed that returns the rate of change (units per second).

Since

v0.1.0

Signal<float> position(0.0f);
auto velocity = rateOfChange(position);
// After some time...
position.set(10.0f);
Serial.println(velocity.get()); // e.g., 2.5 (units per second)

Note

Stateful helper. On first call, returns 0.

Warning

Only accepts arithmetic types (integral and floating-point).

Template Parameters:
size_t MaxDeps = 8

Maximum number of dependents for the computed signal.

Parameters:
Source &source

Source (determines result type).

const typename Computed<decltype(source.get()), 1, MaxDeps>::Options &options = {}

Optional Computed configuration.

Returns:

Computed with rate of change values.

See Also