From 17834afcfc9977d8a430c5356c9b24bdc6d04463 Mon Sep 17 00:00:00 2001
From: Federico Mandelli <federico.mandelli@skywarder.eu>
Date: Mon, 24 Jun 2024 22:16:27 +0200
Subject: [PATCH] [SensorConfig] Update BMX160_WITH_CORRECTION_SAMPLE_PERIOD to
 100ms

---
 src/boards/Parafoil/Configs/SensorsConfig.h | 4 ++++
 src/boards/Parafoil/Sensors/Sensors.cpp     | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/boards/Parafoil/Configs/SensorsConfig.h b/src/boards/Parafoil/Configs/SensorsConfig.h
index b9057e419..88d628e9e 100644
--- a/src/boards/Parafoil/Configs/SensorsConfig.h
+++ b/src/boards/Parafoil/Configs/SensorsConfig.h
@@ -119,6 +119,10 @@ constexpr float BATTERY_VOLTAGE_COEFF = (150 + 40.2) / 40.2;
 // imprecision, avoid clearing the fifo before the interrupt
 constexpr unsigned int BMX160_SAMPLE_PERIOD =
     BMX160_FIFO_FILL_TIME * (BMX160_FIFO_WATERMARK + 30) * 4 / 1024;  // [ms]
+// BMX160_WITH_CORRECTION_SAMPLE_PERIOD should be lower than the
+// BMX160_SAMPLE_PERIOD and faster then the NAS
+constexpr unsigned int BMX160_WITH_CORRECTION_SAMPLE_PERIOD = 100;  // [ms]
+
 constexpr unsigned int LIS3MDL_SAMPLE_PERIOD       = 15;
 constexpr unsigned int INTERNAL_ADC_SAMPLE_PERIOD  = 1000;  // [ms]
 constexpr unsigned int INTERNAL_TEMP_SAMPLE_PERIOD = 2000;  // [ms]
diff --git a/src/boards/Parafoil/Sensors/Sensors.cpp b/src/boards/Parafoil/Sensors/Sensors.cpp
index a6a3b393b..761cd429b 100644
--- a/src/boards/Parafoil/Sensors/Sensors.cpp
+++ b/src/boards/Parafoil/Sensors/Sensors.cpp
@@ -244,7 +244,8 @@ void Sensors::bmx160WithCorrectionInit()
     bmx160WithCorrection =
         new BMX160WithCorrection(bmx160, BMX160_AXIS_ROTATION);
 
-    SensorInfo info("BMX160WithCorrection", BMX160_SAMPLE_PERIOD,
+    SensorInfo info("BMX160WithCorrection",
+                    BMX160_WITH_CORRECTION_SAMPLE_PERIOD,
                     bind(&Sensors::bmx160WithCorrectionCallback, this));
 
     sensorMap.emplace(make_pair(bmx160WithCorrection, info));
-- 
GitLab