|
|
@ -23,8 +23,8 @@ |
|
|
|
class Heuristic { |
|
|
|
public: |
|
|
|
uint8_t getTxCh(Inverter<> *iv) { |
|
|
|
if((IV_HMS == iv->ivGen) || (IV_HMT == iv->ivGen)) |
|
|
|
return 0; // not used for these inverter types
|
|
|
|
if(iv->ivRadioType != INV_RADIO_TYPE_NRF) |
|
|
|
return 0; // not used for other than nRF inverter types
|
|
|
|
|
|
|
|
HeuristicInv *ih = &iv->heuristics; |
|
|
|
|
|
|
@ -66,6 +66,8 @@ class Heuristic { |
|
|
|
ih->testPeriodFailCnt = 0; |
|
|
|
} |
|
|
|
|
|
|
|
iv->radio->mTxRetriesNext = getIvRetries(iv); |
|
|
|
|
|
|
|
return id2Ch(ih->txRfChId); |
|
|
|
} |
|
|
|
|
|
|
@ -155,6 +157,48 @@ class Heuristic { |
|
|
|
DBGPRINTLN(String(iv->config->powerLevel)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t getIvRetries(Inverter<> *iv) { |
|
|
|
if(iv->heuristics.rxSpeeds[0]) |
|
|
|
return 5; |
|
|
|
if(iv->heuristics.rxSpeeds[1]) |
|
|
|
return 10; |
|
|
|
return 15; |
|
|
|
} |
|
|
|
|
|
|
|
void setIvRetriesGood(Inverter<> *iv, bool veryGood) { |
|
|
|
if(iv->ivRadioType != INV_RADIO_TYPE_NRF) |
|
|
|
return; // not used for other than nRF inverter types
|
|
|
|
|
|
|
|
if(iv->heuristics.rxSpeedCnt[veryGood] > 9) |
|
|
|
return; |
|
|
|
iv->heuristics.rxSpeedCnt[veryGood]++; |
|
|
|
iv->heuristics.rxSpeeds[veryGood] = true; |
|
|
|
} |
|
|
|
|
|
|
|
void setIvRetriesBad(Inverter<> *iv) { |
|
|
|
if(iv->ivRadioType != INV_RADIO_TYPE_NRF) |
|
|
|
return; // not used for other than nRF inverter types
|
|
|
|
|
|
|
|
if(iv->heuristics.rxSpeedCnt[0]) { |
|
|
|
iv->heuristics.rxSpeedCnt[0]--; |
|
|
|
return; |
|
|
|
} |
|
|
|
if(iv->heuristics.rxSpeeds[0]) { |
|
|
|
iv->heuristics.rxSpeeds[0] = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if(iv->heuristics.rxSpeedCnt[1]) { |
|
|
|
iv->heuristics.rxSpeedCnt[1]--; |
|
|
|
return; |
|
|
|
} |
|
|
|
if(iv->heuristics.rxSpeeds[1]) { |
|
|
|
iv->heuristics.rxSpeeds[1] = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
bool isNewTxCh(HeuristicInv *ih) { |
|
|
|
return ih->txRfChId != ih->lastBestTxChId; |
|
|
|