Expand description
The C ABI for the goal-named helper math.
These functions wrap [pamoja_kit] for callers that reach the SDK through the
flat C boundary: smoothing a noisy reading, holding a value with a PID,
switching a load with hysteresis, warning before a tank runs dry, and placing
a fix against a geofence.
The helpers are infallible pure math, so unlike the transport capabilities
nothing here returns a status for the work itself. Each stateful helper is an
opaque handle whose methods document what they return for a null handle,
following pamoja_mqtt_client_is_connected. A constructor never returns null,
except a windowed helper’s _with_capacity constructor given a capacity it
cannot keep. Helpers that answer “maybe” return a bool and write the value
through an out-parameter.
A reading that is not a finite number is ignored by every helper that keeps state, as the Rust crate documents, and an anomaly detector flags it.
Structs§
- Pamoja
Anomaly - An opaque handle to an anomaly detector.
- Pamoja
Calibration - An opaque handle to a raw-to-units calibration.
- Pamoja
Complementary - An opaque handle to a complementary filter.
- Pamoja
Coordinate - A latitude and longitude in degrees.
- Pamoja
Debounce - An opaque handle to a boolean debouncer.
- Pamoja
Depletion - An opaque handle to a depletion estimator.
- Pamoja
Geofence - An opaque handle to a circular geofence.
- Pamoja
Kalman - An opaque handle to a one-dimensional Kalman filter.
- Pamoja
Median - An opaque handle to a median filter.
- Pamoja
Pid - An opaque handle to a PID controller.
- Pamoja
Ramp - An opaque handle to a rate limiter.
- Pamoja
Smoother - An opaque handle to an exponential smoother.
- Pamoja
Surge - An opaque handle to a step-change detector.
- Pamoja
Thermostat - An opaque handle to an on/off controller with hysteresis.
- Pamoja
Tilt - Roll and pitch, in degrees.
- Pamoja
Trend - An opaque handle to a trend estimator.
- Pamoja
Trigger - An opaque handle to a threshold with hysteresis that reports its edges.
- Pamoja
Window - An opaque handle to a rolling window of readings.
Enums§
- Pamoja
Boundary - Where a fix sits relative to a geofence, including the moment it crosses.
- Pamoja
Edge - What a trigger reports when a reading changes its state, if anything.
Constants§
- PAMOJA_
WINDOW_ CAPACITY - The most readings a windowed helper keeps, and the number it keeps unless told fewer.
Functions§
- pamoja_
anomaly_ ⚠capacity - Returns how many readings an anomaly detector’s baseline keeps.
- pamoja_
anomaly_ ⚠check - Folds a reading in and reports whether it stands out from the readings before it.
- pamoja_
anomaly_ ⚠free - Releases an anomaly detector handle.
- pamoja_
anomaly_ ⚠new - Creates an anomaly detector that flags a reading
sigmasdeviations out. - pamoja_
anomaly_ ⚠with_ capacity - Creates an anomaly detector whose baseline keeps up to
capacityreadings. - pamoja_
calibration_ ⚠apply - Converts a raw reading into calibrated units.
- pamoja_
calibration_ ⚠free - Releases a calibration handle.
- pamoja_
calibration_ ⚠linear - Creates a calibration applying
raw * scale + offset. - pamoja_
calibration_ ⚠two_ point - Creates a calibration fitted through two known reference points.
- pamoja_
complementary_ ⚠estimate - Reads a complementary filter’s estimate.
- pamoja_
complementary_ ⚠free - Releases a complementary filter handle.
- pamoja_
complementary_ ⚠new - Creates a complementary filter, which fuses a drifting rate with a noisy absolute reading.
- pamoja_
complementary_ ⚠update - Fuses a rate and an absolute reading over a time step.
- pamoja_
coordinate_ bearing_ to - Returns the initial bearing from one coordinate to another, in degrees.
- pamoja_
coordinate_ distance_ to - Returns the great-circle distance between two coordinates, in meters.
- pamoja_
debounce_ ⚠free - Releases a debouncer handle.
- pamoja_
debounce_ ⚠new - Creates a debouncer that requires
samplesagreeing readings to change state. - pamoja_
debounce_ ⚠state - Reports a debouncer’s settled state without feeding it a reading.
- pamoja_
debounce_ ⚠update - Feeds a raw reading to a debouncer and returns the settled state.
- pamoja_
depletion_ ⚠free - Releases a depletion estimator handle.
- pamoja_
depletion_ ⚠new - Creates a depletion estimator that warns as a level approaches
threshold. - pamoja_
depletion_ ⚠update - Records a level and estimates how many samples remain before the threshold.
- pamoja_
geofence_ ⚠contains - Reports whether a fix lies inside a geofence, without recording a crossing.
- pamoja_
geofence_ ⚠free - Releases a geofence handle.
- pamoja_
geofence_ ⚠new - Creates a circular geofence of
radius_maroundcenter. - pamoja_
geofence_ ⚠update - Feeds a fix to a geofence and reports where it sits, including a crossing.
- pamoja_
imu_ tilt_ from_ accel - Computes roll and pitch from a three-axis accelerometer at rest.
- pamoja_
kalman_ ⚠estimate - Reads a Kalman filter’s current estimate without folding in a reading.
- pamoja_
kalman_ ⚠free - Releases a Kalman filter handle.
- pamoja_
kalman_ ⚠new - Creates a one-dimensional Kalman filter.
- pamoja_
kalman_ ⚠update - Folds a reading into a Kalman filter and returns the new estimate.
- pamoja_
kit_ deadband - Holds a reading at
centerwhile it stays withinwidtheither side, so small wiggle around a setpoint does not act. - pamoja_
median_ ⚠capacity - Returns how many readings a median filter keeps.
- pamoja_
median_ ⚠free - Releases a median filter handle.
- pamoja_
median_ ⚠new - Creates an empty median filter over
PAMOJA_WINDOW_CAPACITYreadings. - pamoja_
median_ ⚠update - Folds a reading in and returns the median of the window.
- pamoja_
median_ ⚠value - Reads the current median without folding in a reading.
- pamoja_
median_ ⚠with_ capacity - Creates an empty median filter over up to
capacityreadings. - pamoja_
pid_ ⚠free - Releases a PID controller handle.
- pamoja_
pid_ ⚠new - Creates a PID controller with the given gains and no output limits.
- pamoja_
pid_ ⚠new_ with_ limits - Creates a PID controller whose output is clamped to
[min, max]. - pamoja_
pid_ ⚠reset - Clears a PID controller’s accumulated integral, its last error, and the output it last returned.
- pamoja_
pid_ ⚠update - Advances a PID controller by one step.
- pamoja_
ramp_ ⚠free - Releases a rate limiter handle.
- pamoja_
ramp_ ⚠new - Creates a rate limiter starting at
startand moving at mostmax_step. - pamoja_
ramp_ ⚠set - Forces a ramp to a value without rate limiting.
- pamoja_
ramp_ ⚠update - Moves a ramp one step toward
targetand returns the new value. - pamoja_
ramp_ ⚠value - Reads a ramp’s current value.
- pamoja_
smoother_ ⚠free - Releases a smoother handle.
- pamoja_
smoother_ ⚠new - Creates an exponential smoother.
- pamoja_
smoother_ ⚠reset - Clears a smoother back to its initial state.
- pamoja_
smoother_ ⚠update - Folds a sample into a smoother and returns the smoothed value.
- pamoja_
smoother_ ⚠value - Reads a smoother’s current value without folding in a sample.
- pamoja_
surge_ ⚠falling - Creates a detector for falls of more than
limitbetween readings. - pamoja_
surge_ ⚠free - Releases a surge detector handle.
- pamoja_
surge_ ⚠rising - Creates a detector for rises of more than
limitbetween readings. - pamoja_
surge_ ⚠update - Feeds a value to a surge detector.
- pamoja_
thermostat_ ⚠cooling - Creates a cooling thermostat, which switches on when the reading rises.
- pamoja_
thermostat_ ⚠free - Releases a thermostat handle.
- pamoja_
thermostat_ ⚠heating - Creates a heating thermostat, which switches on when the reading falls.
- pamoja_
thermostat_ ⚠is_ on - Reports a thermostat’s current output without feeding it a reading.
- pamoja_
thermostat_ ⚠update - Feeds a reading to a thermostat and returns whether the load should be on.
- pamoja_
trend_ ⚠capacity - Returns how many readings a trend estimator keeps.
- pamoja_
trend_ ⚠free - Releases a trend estimator handle.
- pamoja_
trend_ ⚠new - Creates an empty trend estimator over
PAMOJA_WINDOW_CAPACITYreadings. - pamoja_
trend_ ⚠push - Adds a reading to a trend estimator.
- pamoja_
trend_ ⚠slope - Reads the slope a trend estimator has fitted, in units per reading.
- pamoja_
trend_ ⚠with_ capacity - Creates an empty trend estimator over up to
capacityreadings. - pamoja_
trigger_ ⚠above - Creates a trigger that fires when a reading rises above the line and clears once it has fallen below the line by the hysteresis.
- pamoja_
trigger_ ⚠below - Creates a trigger that fires when a reading falls below the line and clears once it has risen above the line by the hysteresis.
- pamoja_
trigger_ ⚠free - Releases a trigger handle.
- pamoja_
trigger_ ⚠hysteresis - Reads the release band on the far side of a trigger’s line.
- pamoja_
trigger_ ⚠is_ set - Reports whether a trigger’s condition currently holds.
- pamoja_
trigger_ ⚠threshold - Reads the line a trigger watches.
- pamoja_
trigger_ ⚠update - Feeds a reading to a trigger and returns the edge it caused.
- pamoja_
trigger_ ⚠watches_ above - Reports whether a trigger watches a rising reading.
- pamoja_
units_ celsius_ to_ fahrenheit - Converts degrees Celsius to degrees Fahrenheit.
- pamoja_
units_ celsius_ to_ kelvin - Converts degrees Celsius to kelvin.
- pamoja_
units_ fahrenheit_ to_ celsius - Converts degrees Fahrenheit to degrees Celsius.
- pamoja_
units_ hectopascals_ to_ pascals - Converts hectopascals to pascals.
- pamoja_
units_ kelvin_ to_ celsius - Converts kelvin to degrees Celsius.
- pamoja_
units_ kilopascals_ to_ pascals - Converts kilopascals to pascals.
- pamoja_
units_ pascals_ to_ hectopascals - Converts pascals to hectopascals.
- pamoja_
units_ pascals_ to_ kilopascals - Converts pascals to kilopascals.
- pamoja_
units_ pascals_ to_ psi - Converts pascals to pounds per square inch.
- pamoja_
units_ percent_ to_ ratio - Converts a percentage to a ratio from 0 to 1.
- pamoja_
units_ psi_ to_ pascals - Converts pounds per square inch to pascals.
- pamoja_
units_ ratio_ to_ percent - Converts a ratio from 0 to 1 to a percentage.
- pamoja_
weather_ dew_ point - Computes the dew point from the air temperature and relative humidity.
- pamoja_
window_ ⚠capacity - Returns how many readings a window holds before it starts dropping.
- pamoja_
window_ ⚠free - Releases a rolling window handle.
- pamoja_
window_ ⚠is_ full - Reports whether a window holds as many readings as it keeps.
- pamoja_
window_ ⚠latest - Reads the most recent reading in a window.
- pamoja_
window_ ⚠len - Returns how many readings a window holds.
- pamoja_
window_ ⚠max - Reads the largest reading in a window.
- pamoja_
window_ ⚠mean - Reads the mean of a window’s readings.
- pamoja_
window_ ⚠min - Reads the smallest reading in a window.
- pamoja_
window_ ⚠new - Creates an empty rolling window of
PAMOJA_WINDOW_CAPACITYreadings. - pamoja_
window_ ⚠oldest - Reads the oldest reading a window still holds.
- pamoja_
window_ ⚠push - Adds a reading, dropping the oldest once the window is full.
- pamoja_
window_ ⚠range - Reads the spread between a window’s smallest and largest readings.
- pamoja_
window_ ⚠variance - Reads the population variance of a window’s readings.
- pamoja_
window_ ⚠with_ capacity - Creates an empty rolling window that keeps up to
capacityreadings.