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 constructor returns null only when allocation is refused, and whose methods document what they return for a null handle, following pamoja_mqtt_client_is_connected. Helpers that answer “maybe” return a bool and write the value through an out-parameter.

Structs§

PamojaAnomaly
An opaque handle to an anomaly detector.
PamojaCalibration
An opaque handle to a raw-to-units calibration.
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.
PamojaTrend
An opaque handle to a trend estimator.
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.

Constants§

PAMOJA_WINDOW_CAPACITY
The number of readings a windowed helper keeps.

Functions§

pamoja_anomaly_check
Folds a reading in and reports whether it stands out from the window.
pamoja_anomaly_free
Releases an anomaly detector handle.
pamoja_anomaly_new
Creates an anomaly detector that flags a reading sigmas deviations out.
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_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 metres.
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_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
Suppresses movement within width of center, so noise does not act.
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_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 and last error.
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 at least limit between readings.
pamoja_surge_free
Releases a surge detector handle.
pamoja_surge_rising
Creates a detector for rises of at least 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_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_window_capacity
Returns how many readings a window holds before it starts dropping.
pamoja_window_free
Releases a rolling window handle.
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_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 variance of a window’s readings.