From aee25b21dfd4632877f975899d00da1d461b8fb7 Mon Sep 17 00:00:00 2001 From: dhineshkumarmcci Date: Wed, 27 Sep 2023 19:53:14 +0530 Subject: [PATCH 1/2] fix #21: fixed bug in feature of dynamic gain change --- Catena4430_cMeasurementLoopV2.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Catena4430_cMeasurementLoopV2.cpp b/Catena4430_cMeasurementLoopV2.cpp index ba4173a..5d8a759 100644 --- a/Catena4430_cMeasurementLoopV2.cpp +++ b/Catena4430_cMeasurementLoopV2.cpp @@ -89,32 +89,37 @@ bool cMeasurementLoopV2::takeMeasurements(void) { this->m_fHardError = true; if (gLog.isEnabled(gLog.DebugFlags::kError)) + { gLog.printf( gLog.kAlways, "LTR329 queryReady failed: status %s(%u)\n", this->m_Ltr.getLastErrorName(), unsigned(this->m_Ltr.getLastError()) ); + + this->m_Ltr.begin(); + } } else { currentLux = this->m_Ltr.getLux(); - this->m_data.flags |= FlagsV2::Light; - this->m_data.light.Lux = currentLux; - if (currentLux <= kMax_Gain_96) - m_AlsCtrl.setGain(96); + this->m_Ltr.setGain(96); else if (currentLux <= kMax_Gain_48) - m_AlsCtrl.setGain(48); + this->m_Ltr.setGain(48); else if (currentLux <= kMax_Gain_8) - m_AlsCtrl.setGain(8); + this->m_Ltr.setGain(8); else if (currentLux <= kMax_Gain_4) - m_AlsCtrl.setGain(4); + this->m_Ltr.setGain(4); else if (currentLux <= kMax_Gain_2) - m_AlsCtrl.setGain(2); + this->m_Ltr.setGain(2); else - m_AlsCtrl.setGain(1); + this->m_Ltr.setGain(1); + + currentLux = this->m_Ltr.getLux(); + this->m_data.flags |= FlagsV2::Light; + this->m_data.light.Lux = currentLux; if (currentLux <= 100) gpMeasurementLoopConcrete->m_fLowLight = true; From a589f224f88120e020af299eb2f764b29797387f Mon Sep 17 00:00:00 2001 From: dhineshkumarmcci Date: Wed, 27 Sep 2023 19:57:08 +0530 Subject: [PATCH 2/2] This is v2.2.1 --- Catena4430_Sensor.ino | 2 +- Catena4430_cMeasurementLoop.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Catena4430_Sensor.ino b/Catena4430_Sensor.ino index e5ea7f6..e7b630a 100644 --- a/Catena4430_Sensor.ino +++ b/Catena4430_Sensor.ino @@ -43,7 +43,7 @@ static_assert( "This sketch requires Catena-Arduino-Platform v0.21.0-5 or later" ); -constexpr std::uint32_t kAppVersion = McciCatena4430::makeVersion(2,2,0,0); +constexpr std::uint32_t kAppVersion = McciCatena4430::makeVersion(2,2,1,0); constexpr std::uint32_t kDoubleResetWaitMs = 3000; constexpr std::uint32_t kSetDoubleResetMagic = 0xCA44301; constexpr std::uint32_t kClearDoubleResetMagic = 0xCA44300; diff --git a/Catena4430_cMeasurementLoop.h b/Catena4430_cMeasurementLoop.h index ea568d1..a30cba6 100644 --- a/Catena4430_cMeasurementLoop.h +++ b/Catena4430_cMeasurementLoop.h @@ -141,7 +141,7 @@ class cMeasurementLoop : public McciCatena::cPollableObject // version parameters static constexpr std::uint8_t kMajor = 2; static constexpr std::uint8_t kMinor = 2; - static constexpr std::uint8_t kPatch = 0; + static constexpr std::uint8_t kPatch = 1; static constexpr std::uint8_t kLocal = 0; // some parameters