View Source SGP40.VocIndex (sgp40 v0.1.6)

Process the raw output of the SGP40 sensor into the VOC Index.

Summary

Functions

Returns a specification to start this module under a supervisor.

Get current algorithm states. Retrieved values can be used in set_states/1 to resume operation after a short interruption, skipping initial learning phase. This feature can only be used after at least 3 hours of continuous operation.

Calculate the VOC index value from the raw sensor value.

Set previously retrieved algorithm states to resume operation after a short interruption, skipping initial learning phase. This feature should not be used after inerruptions of more than 10 minutes. Call this once after start_link/1 and the optional set_tuning_params/1, if desired. Otherwise, the algorithm will start with initial learning phase.

Set parameters to customize the VOC algorithm. Call this once after start_link/1, if desired. Otherwise, the default values will be used.

Initialize the VOC algorithm parameters. Call this once at the beginning or whenever the sensor stopped measurements.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec get_states() :: {:ok, SGP40.VocIndex.AlgorithmStates.t()} | {:error, any()}

Get current algorithm states. Retrieved values can be used in set_states/1 to resume operation after a short interruption, skipping initial learning phase. This feature can only be used after at least 3 hours of continuous operation.

@spec process(0..65535) :: {:ok, 1..500} | {:error, any()}

Calculate the VOC index value from the raw sensor value.

@spec set_states(SGP40.VocIndex.AlgorithmStates.t()) ::
  {:ok, binary()} | {:error, any()}

Set previously retrieved algorithm states to resume operation after a short interruption, skipping initial learning phase. This feature should not be used after inerruptions of more than 10 minutes. Call this once after start_link/1 and the optional set_tuning_params/1, if desired. Otherwise, the algorithm will start with initial learning phase.

@spec set_tuning_params(SGP40.VocIndex.AlgorithmTuningParams.t()) ::
  {:ok, binary()} | {:error, any()}

Set parameters to customize the VOC algorithm. Call this once after start_link/1, if desired. Otherwise, the default values will be used.

@spec start_link(any()) :: GenServer.on_start()

Initialize the VOC algorithm parameters. Call this once at the beginning or whenever the sensor stopped measurements.