SGP40.VocIndex (sgp40 v0.1.7)
View SourceProcess 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
Returns a specification to start this module under a supervisor.
See Supervisor
.
@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.
@spec process(GenServer.server(), 0..65535) :: {:ok, 1..500} | {:error, any()}
Calculate the VOC index value from the raw sensor value.
@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.
@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.
@spec start_link(keyword()) :: GenServer.on_start()
Initialize the VOC algorithm