Browse Source

0.8.60

* merge PR: non blocking nRF loop #1371
pull/1376/head
lumapu 1 year ago
parent
commit
9601e900ac
  1. 3
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 4
      src/hm/Communication.h
  4. 22
      src/hm/hmRadio.h
  5. 3
      src/hms/hmsRadio.h

3
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

2
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 {

4
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"));

22
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;

3
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;

Loading…
Cancel
Save