Skip to main content

Module kit

Module kit 

Source
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§

PamojaAnomaly
An opaque handle to an anomaly detector.
PamojaCalibration
An opaque handle to a raw-to-units calibration.
PamojaComplementary
An opaque handle to a complementary filter.
PamojaCoordinate
A latitude and longitude in degrees.
PamojaDebounce
An opaque handle to a boolean debouncer.
PamojaDepletion
An opaque handle to a depletion estimator.
PamojaGeofence
An opaque handle to a circular geofence.
PamojaKalman
An opaque handle to a one-dimensional Kalman filter.
PamojaMedian
An opaque handle to a median filter.
PamojaPid
An opaque handle to a PID controller.
PamojaRamp
An opaque handle to a rate limiter.
PamojaSmoother
An opaque handle to an exponential smoother.
PamojaSurge
An opaque handle to a step-change detector.
PamojaThermostat
An opaque handle to an on/off controller with hysteresis.
PamojaTilt
Roll and pitch, in degrees.
PamojaTrend
An opaque handle to a trend estimator.
PamojaTrigger
An opaque handle to a threshold with hysteresis that reports its edges.
PamojaWindow
An opaque handle to a rolling window of readings.

Enums§

PamojaBoundary
Where a fix sits relative to a geofence, including the moment it crosses.
PamojaEdge
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 sigmas deviations out.
pamoja_anomaly_with_capacity⚠
Creates an anomaly detector whose baseline keeps up to capacity readings.
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 samples agreeing 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_m around center.
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 center while it stays within width either 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_CAPACITY readings.
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 capacity readings.
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 start and moving at most max_step.
pamoja_ramp_set⚠
Forces a ramp to a value without rate limiting.
pamoja_ramp_update⚠
Moves a ramp one step toward target and 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 limit between readings.
pamoja_surge_free⚠
Releases a surge detector handle.
pamoja_surge_rising⚠
Creates a detector for rises of more than limit between 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_CAPACITY readings.
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 capacity readings.
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_CAPACITY readings.
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 capacity readings.