Skip to content

Commit 2a04226

Browse files
committed
Remove config passthroughs from tx_main
1 parent faf07f6 commit 2a04226

File tree

5 files changed

+30
-45
lines changed

5 files changed

+30
-45
lines changed

src/include/rxtx_intf.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ extern bool RxWiFiReadyToSend;
1414
void SetSyncSpam();
1515
void ResetPower();
1616
uint8_t adjustPacketRateForBaud(uint8_t rate);
17-
18-
void tx_SetPacketRateIdx(uint8_t idx, bool forceChange);
19-
void tx_SetSwitchMode(uint8_t idx);
20-
void tx_SetAntennaMode(uint8_t idx);
21-
void tx_SetTlmRatio(uint8_t idx);
2217
#endif
2318

2419
/***

src/lib/SCREEN/menu.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "OLED/oleddisplay.h"
22
#include "TFT/tftdisplay.h"
33

4+
#include "TXModuleEndpoint.h"
45
#include "rxtx_intf.h"
56
#include "config.h"
67
#include "helpers.h"
@@ -221,16 +222,16 @@ static void saveValueIndex(bool init)
221222
switch (state_machine.getParentState())
222223
{
223224
case STATE_PACKET:
224-
tx_SetPacketRateIdx(val, false);
225+
crsfTransmitter.SetPacketRateIdx(val, false);
225226
break;
226227
case STATE_SWITCH:
227-
tx_SetSwitchMode(val);
228+
crsfTransmitter.SetSwitchMode(val);
228229
break;
229230
case STATE_ANTENNA:
230-
tx_SetAntennaMode(val);
231+
crsfTransmitter.SetAntennaMode(val);
231232
break;
232233
case STATE_TELEMETRY:
233-
tx_SetTlmRatio(val);
234+
crsfTransmitter.SetTlmRatio(val);
234235
break;
235236
case STATE_POWERSAVE:
236237
config.SetMotionMode(values_index);
@@ -240,15 +241,10 @@ static void saveValueIndex(bool init)
240241
break;
241242

242243
case STATE_POWER_MAX:
243-
config.SetPower(values_index);
244-
if (!config.IsModified())
245-
{
246-
ResetPower();
247-
}
244+
crsfTransmitter.SetMaxPower(values_index);
248245
break;
249246
case STATE_POWER_DYNAMIC:
250-
config.SetDynamicPower(values_index > 0);
251-
config.SetBoostChannel((values_index - 1) > 0 ? values_index - 1 : 0);
247+
crsfTransmitter.SetDynamicPower(values_index);
252248
break;
253249

254250
case STATE_VTX_BAND:

src/lib/tx-crsf/TXModuleEndpoint.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class TXModuleEndpoint final : public CRSFEndpoint {
3939
void SetSwitchMode(uint8_t idx);
4040
void SetAntennaMode(uint8_t idx);
4141
void SetTlmRatio(uint8_t idx);
42+
void SetMaxPower(uint8_t idx);
43+
void SetDynamicPower(uint8_t idx);
4244
protected:
4345
void devicePingCalled() override;
4446
void updateModelID();
@@ -60,4 +62,6 @@ class TXModuleEndpoint final : public CRSFEndpoint {
6062
void updateBackpackOpts();
6163
};
6264

65+
extern TXModuleEndpoint crsfTransmitter;
66+
6367
#endif //TX_MODULE_ENDPOINT_H

src/lib/tx-crsf/TXModuleParameters.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,21 @@ void TXModuleEndpoint::SetTlmRatio(uint8_t idx)
710710
}
711711
}
712712

713+
void TXModuleEndpoint::SetMaxPower(uint8_t idx)
714+
{
715+
config.SetPower(idx);
716+
if (!config.IsModified())
717+
{
718+
ResetPower();
719+
}
720+
}
721+
722+
void TXModuleEndpoint::SetDynamicPower(uint8_t idx)
723+
{
724+
config.SetDynamicPower(idx > 0);
725+
config.SetBoostChannel((idx - 1) > 0 ? idx - 1 : 0);
726+
}
727+
713728
/***
714729
* @brief: Update the dynamic strings used for folder names and labels
715730
***/
@@ -885,16 +900,11 @@ void TXModuleEndpoint::registerParameters()
885900
// POWER folder
886901
registerParameter(&luaPowerFolder);
887902
filterOptions(&luaPower, POWERMGNT::getMinPower(), POWERMGNT::getMaxPower(), strPowerLevels);
888-
registerParameter(&luaPower, [](propertiesCommon *item, uint8_t arg) {
889-
config.SetPower((PowerLevels_e)constrain(arg + POWERMGNT::getMinPower(), POWERMGNT::getMinPower(), POWERMGNT::getMaxPower()));
890-
if (!config.IsModified())
891-
{
892-
ResetPower();
893-
}
903+
registerParameter(&luaPower, [this](propertiesCommon *item, uint8_t arg) {
904+
SetMaxPower(constrain(arg + POWERMGNT::getMinPower(), POWERMGNT::getMinPower(), POWERMGNT::getMaxPower()));
894905
}, luaPowerFolder.common.id);
895-
registerParameter(&luaDynamicPower, [](propertiesCommon *item, uint8_t arg) {
896-
config.SetDynamicPower(arg > 0);
897-
config.SetBoostChannel((arg - 1) > 0 ? arg - 1 : 0);
906+
registerParameter(&luaDynamicPower, [this](propertiesCommon *item, uint8_t arg) {
907+
SetDynamicPower(arg);
898908
}, luaPowerFolder.common.id);
899909
}
900910
if (GPIO_PIN_FAN_EN != UNDEF_PIN || GPIO_PIN_FAN_PWM != UNDEF_PIN) {

src/src/tx_main.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -424,26 +424,6 @@ uint8_t adjustPacketRateForBaud(const uint8_t rateIndex)
424424
return get_elrs_HandsetRate_max(rateIndex, handset->getMinPacketInterval());
425425
}
426426

427-
void tx_SetPacketRateIdx(uint8_t idx, bool forceChange)
428-
{
429-
crsfTransmitter.SetPacketRateIdx(idx, forceChange);
430-
}
431-
432-
void tx_SetSwitchMode(uint8_t idx)
433-
{
434-
crsfTransmitter.SetSwitchMode(idx);
435-
}
436-
437-
void tx_SetAntennaMode(uint8_t idx)
438-
{
439-
crsfTransmitter.SetAntennaMode(idx);
440-
}
441-
442-
void tx_SetTlmRatio(uint8_t idx)
443-
{
444-
crsfTransmitter.SetTlmRatio(idx);
445-
}
446-
447427
void SetRFLinkRate(uint8_t index) // Set speed of RF link
448428
{
449429
expresslrs_mod_settings_s *const ModParams = get_elrs_airRateConfig(index);

0 commit comments

Comments
 (0)