Skip to content

Commit

Permalink
re simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
StonedDawg committed Jan 16, 2021
1 parent 8976e11 commit 43852aa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/src/rx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,25 +314,25 @@ void ICACHE_RAM_ATTR HWtimerCallbackTick() // this is 180 out of phase with the
void ICACHE_RAM_ATTR HWtimerCallbackTock()
{
#if defined(GPIO_PIN_ANTENNA_SELECT) && defined(USE_DIVERSITY)
static int32_t otherRSSI;
static int32_t prevRSSI; // saved rssi so that we can compare if switching made things better or worse
static int32_t antennaSwitched;
static int32_t antennaSwitched2;
int32_t rssi = (antenna == 0) ? LPF_UplinkRSSI0.SmoothDataINT : LPF_UplinkRSSI1.SmoothDataINT;
int32_t otherRSSI = (antenna == 0) ? LPF_UplinkRSSI1.SmoothDataINT : LPF_UplinkRSSI0.SmoothDataINT;

// if rssi drop 5 from strongest rssi
// if we didn't get a packet switch the antenna
if ((rssi < (prevRSSI - 5) ) && antennaSwitched2 >= DIVERSITY_ANTENNA_INTERVAL){
otherRSSI = rssi;

switchAntenna();
antennaSwitched = 1;
antennaSwitched2 = 0;
} else if(rssi > prevRSSI || antennaSwitched2 < DIVERSITY_ANTENNA_INTERVAL){
prevRSSI = rssi;
antennaSwitched2++;
}
//if there is a packet drop

if (((!LQCALC.packetReceivedForPreviousFrame()) && antennaSwitched == 0)) {
otherRSSI = rssi;

switchAntenna();
antennaSwitched = 1;
antennaSwitched2 = 0;
Expand All @@ -342,7 +342,7 @@ void ICACHE_RAM_ATTR HWtimerCallbackTock()

if (rssi < otherRSSI) {
// things got worse when we switched, so change back.
otherRSSI = rssi;

switchAntenna();
antennaSwitched = 1;
antennaSwitched2 = 0;
Expand Down

0 comments on commit 43852aa

Please sign in to comment.