From 9601e900ac5a392ed919c3fcff99dafd408b8ed1 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 20 Jan 2024 13:09:50 +0100 Subject: [PATCH] 0.8.60 * merge PR: non blocking nRF loop #1371 --- src/CHANGES.md | 3 +++ src/defines.h | 2 +- src/hm/Communication.h | 4 ++-- src/hm/hmRadio.h | 22 +++++++++++----------- src/hms/hmsRadio.h | 3 --- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index b02c9a96..8f5488f6 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.60 - 2024-01-20 +* merge PR: non blocking nRF loop #1371 + ## 0.8.59 - 2024-01-18 * merge PR: solve display settings dependencies #1369 * fix language typos #1346 diff --git a/src/defines.h b/src/defines.h index 8262def3..8f3195f4 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 59 +#define VERSION_PATCH 60 //------------------------------------- typedef struct { diff --git a/src/hm/Communication.h b/src/hm/Communication.h index 8874a87a..d13ca158 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -96,7 +96,7 @@ class Communication : public CommQueue<> { case States::START: setTs(mTimestamp); - if(q->iv->ivRadioType == INV_RADIO_TYPE_CMT) { + if(INV_RADIO_TYPE_CMT == q->iv->ivRadioType) { // frequency was changed during runtime if(q->iv->curCmtFreq != q->iv->config->frequency) { if(q->iv->radio->switchFrequencyCh(q->iv, q->iv->curCmtFreq, q->iv->config->frequency)) @@ -284,7 +284,7 @@ class Communication : public CommQueue<> { DBGPRINT(String(p->millis)); DBGPRINT(F("ms | ")); DBGPRINT(String(p->len)); - if(q->iv->ivRadioType == INV_RADIO_TYPE_NRF) { + if(INV_RADIO_TYPE_NRF == q->iv->ivRadioType) { DBGPRINT(F(" CH")); if(3 == p->ch) DBGPRINT(F("0")); diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index 54dc0121..9aad3a54 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -120,21 +120,23 @@ class HmRadio : public Radio { yield(); - if (millis() - mTimeslotStart < innerLoopTimeout) + if ((millis() - mTimeslotStart) < innerLoopTimeout) return; // nothing to do // otherwise switch to next RX channel mTimeslotStart = millis(); - if(!mNRFloopChannels && (mTimeslotStart - mLastIrqTime > (DURATION_TXFRAME+DURATION_ONEFRAME))) + if(!mNRFloopChannels && ((mTimeslotStart - mLastIrqTime) > (DURATION_TXFRAME+DURATION_ONEFRAME))) mNRFloopChannels = true; rxPendular = !rxPendular; //innerLoopTimeout = (rxPendular ? 1 : 2)*DURATION_LISTEN_MIN; innerLoopTimeout = DURATION_LISTEN_MIN; - tempRxChIdx = mNRFloopChannels ? - (tempRxChIdx + 4) % RF_CHANNELS : - (mRxChIdx + rxPendular*4) % RF_CHANNELS; + if(mNRFloopChannels) + tempRxChIdx = (tempRxChIdx + 4) % RF_CHANNELS + else + tempRxChIdx = (mRxChIdx + rxPendular*4) % RF_CHANNELS; + mNrf24->setChannel(mRfChLst[tempRxChIdx]); isRxInit = false; @@ -144,7 +146,7 @@ class HmRadio : public Radio { // here we got news from the nRF mNrf24->whatHappened(tx_ok, tx_fail, rx_ready); // resets the IRQ pin to HIGH - mIrqRcvd = false; + mIrqRcvd = false; mLastIrqTime = millis(); if(tx_ok || tx_fail) { // tx related interrupt, basically we should start listening @@ -172,7 +174,6 @@ class HmRadio : public Radio { } if(rx_ready) { - if (getReceived()) { // check what we got, returns true for last package mNRFisInRX = false; mRadioWaitTime.startTimeMonitor(DURATION_PAUSE_LASTFR); // let the inverter first end his transmissions @@ -188,7 +189,6 @@ class HmRadio : public Radio { mNrf24->setChannel(mRfChLst[tempRxChIdx]); } else mRxChIdx = tempRxChIdx; - } } return; @@ -405,9 +405,9 @@ class HmRadio : public Radio { bool tx_ok, tx_fail, rx_ready = false; unsigned long mTimeslotStart = 0; unsigned long mLastIrqTime = 0; - bool mNRFloopChannels = false; - bool mNRFisInRX = false; - bool isRxInit = true; + bool mNRFloopChannels = false; + bool mNRFisInRX = false; + bool isRxInit = true; bool rxPendular = false; uint32_t innerLoopTimeout = DURATION_LISTEN_MIN; diff --git a/src/hms/hmsRadio.h b/src/hms/hmsRadio.h index aab8a6a7..1506f3fa 100644 --- a/src/hms/hmsRadio.h +++ b/src/hms/hmsRadio.h @@ -163,9 +163,6 @@ class CmtRadio : public Radio { uint8_t status = mCmt.getRx(p.packet, &p.len, 28, &p.rssi); if(CMT_SUCCESS == status) mBufCtrl.push(p); - //if(p.packet[9] > ALL_FRAMES) // indicates last frame - // mRadioWaitTime.stopTimeMonitor(); // we got everything we expected and can exit rx mode... - //optionally instead: mRadioWaitTime.startTimeMonitor(DURATION_PAUSE_LASTFR); // let the inverter first get back to rx mode? } CmtType mCmt;