Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single antenna usage on diversity setups #266

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions mLRS/Common/rf_power.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,26 @@
class tRfPower
{
public:
void Init(void);
void Init(bool _antenna1, bool _antenna2);
void Update(void);
void Set(tRcData* const rc, uint8_t power_switch_channel, uint8_t power);
void Set(uint8_t power);

private:
uint8_t rfpower_current_idx;
uint8_t rfpower_new_idx;
bool do_antenna1;
bool do_antenna2;
};


void tRfPower::Init(void)
void tRfPower::Init(bool _antenna1, bool _antenna2)
{
rfpower_current_idx = 0;
rfpower_new_idx = rfpower_current_idx; // to prevent update before first Set

do_antenna1 = _antenna1;
do_antenna2 = _antenna2;
}


Expand All @@ -49,8 +54,8 @@ void tRfPower::Update(void)
Config.Sx.Power_dbm = rfpower_list[rfpower_current_idx].dbm;
Config.Sx2.Power_dbm = Config.Sx.Power_dbm;

sx.UpdateRfPower(&Config.Sx);
sx2.UpdateRfPower(&Config.Sx2);
if (do_antenna1) sx.UpdateRfPower(&Config.Sx);
if (do_antenna2) sx2.UpdateRfPower(&Config.Sx2);
}


Expand Down
2 changes: 1 addition & 1 deletion mLRS/CommonRx/mlrs-rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ RESTARTCONTROLLER
bind.Init();
fhss.Init(&Config.Fhss, &Config.Fhss2);
fhss.Start();
rfpower.Init();
rfpower.Init(TRANSMIT_USE_ANTENNA1, TRANSMIT_USE_ANTENNA2);

sx.SetRfFrequency(fhss.GetCurrFreq());
sx2.SetRfFrequency(fhss.GetCurrFreq2());
Expand Down
11 changes: 9 additions & 2 deletions mLRS/CommonTx/mbridge_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,15 @@ tMBridgeInfo info = {};

info.tx_config_id = Config.ConfigId;

info.receiver_sensitivity = sx.ReceiverSensitivity_dbm(); // is equal for Tx and Rx
info.tx_actual_power_dbm = sx.RfPower_dbm();
if (Config.TransmitUseAntenna1) {
info.receiver_sensitivity = sx.ReceiverSensitivity_dbm(); // is equal for Tx and Rx
info.tx_actual_power_dbm = sx.RfPower_dbm();
}
else {
info.receiver_sensitivity = sx2.ReceiverSensitivity_dbm();
info.tx_actual_power_dbm = sx2.RfPower_dbm();
}

info.tx_actual_diversity = Config.Diversity;

if (SetupMetaData.rx_available) {
Expand Down
2 changes: 1 addition & 1 deletion mLRS/CommonTx/mlrs-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ RESTARTCONTROLLER
bind.Init();
fhss.Init(&Config.Fhss, &Config.Fhss2);
fhss.Start();
rfpower.Init();
rfpower.Init(TRANSMIT_USE_ANTENNA1, TRANSMIT_USE_ANTENNA2);

sx.SetRfFrequency(fhss.GetCurrFreq());
sx2.SetRfFrequency(fhss.GetCurrFreq2());
Expand Down