From 9e807b8d0d9ff4cfeefa812938ef49ade1d94714 Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Sun, 3 May 2020 14:40:59 +0200 Subject: [PATCH] feat(bsec): add option to set a static temperature offset --- Documentation/card10-cfg.rst | 2 ++ epicardium/modules/bsec.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/card10-cfg.rst b/Documentation/card10-cfg.rst index 0c992b15..b24c7b54 100644 --- a/Documentation/card10-cfg.rst +++ b/Documentation/card10-cfg.rst @@ -60,4 +60,6 @@ Option name Type Description ``bsec_enable`` Boolean Activate the Bosch :ref:`BSEC` binary blob to compute an Indoor Air Quality indication. ------------------ ---------- ----------- ``bsec_debug`` Boolean Turn on debug output of the BSEC system. Prints each meaurement on the console. +------------------ ---------- ----------- +``bsec_offset`` Integer Temperature offset in .1 K. Example: Set to `-14` if temperature reads 1.4 "C" to high. ================== ========== =========== diff --git a/epicardium/modules/bsec.c b/epicardium/modules/bsec.c index 443d7a4b..53c2da85 100644 --- a/epicardium/modules/bsec.c +++ b/epicardium/modules/bsec.c @@ -363,8 +363,6 @@ int bsec_activate(void) float sample_rate = BSEC_SAMPLE_RATE_LP; #endif - float temperature_offset = 0.0; - bool bsec_enabled = config_get_boolean_with_default("bsec_enabled", false); if (!bsec_enabled) { @@ -372,10 +370,18 @@ int bsec_activate(void) } debug = config_get_boolean_with_default("bsec_debug", false); + + float temperature_offset = + config_get_integer_with_default("bsec_offset", 0) / 10.; + if (temperature_offset != 0.0) { + printf("BSEC Temp offset %d/10 K\n", + (int)(temperature_offset * 10)); + } + /* Puts AT LEAST 2 * #BSEC_MAX_PROPERTY_BLOB_SIZE = 2 * 454 = 908 bytes onto the stack */ ret = bsec_iot_init( sample_rate, - temperature_offset, + -temperature_offset, i2c_write, i2c_read, delay, -- GitLab