SGP40.VocIndex (sgp40 v0.1.7)

View Source

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 interruptions 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

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_states(server)

@spec get_states(GenServer.server()) ::
  {: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.

process(server, sraw)

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

Calculate the VOC index value from the raw sensor value.

set_states(server, args)

@spec set_states(GenServer.server(), 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 interruptions 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_tuning_params(server, args)

@spec set_tuning_params(GenServer.server(), 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.

start_link(args \\ [])

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

Initialize the VOC algorithm