Skip to content

Commit faf07f6

Browse files
committed
Unextern the hell out of everything
1 parent 44391e2 commit faf07f6

File tree

12 files changed

+35
-40
lines changed

12 files changed

+35
-40
lines changed

src/include/common.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ extern bool crsfBaroSensorDetected;
340340
void ChannelDataReset();
341341
uint32_t uidMacSeedGet();
342342
bool isDualRadio();
343-
void EnterBindingModeSafely(); // defined in rx_main/tx_main
343+
344+
// defined in rx_main/tx_main
345+
extern unsigned long rebootTime;
346+
void EnterBindingModeSafely();
344347

345348
#if defined(RADIO_LR1121)
346349
bool isSupportedRFRate(uint8_t index);

src/include/rxtx_intf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
* TX interface
1010
***/
1111
#if defined(TARGET_TX)
12+
extern bool RxWiFiReadyToSend;
13+
1214
void SetSyncSpam();
15+
void ResetPower();
16+
uint8_t adjustPacketRateForBaud(uint8_t rate);
1317

1418
void tx_SetPacketRateIdx(uint8_t idx, bool forceChange);
1519
void tx_SetSwitchMode(uint8_t idx);

src/lib/Backpack/devBackpack.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "config.h"
66
#include "device.h"
77
#include "logging.h"
8-
#include "msp.h"
98
#include "msptypes.h"
109

1110
// How often to check for backpack commands

src/lib/Backpack/devBackpack.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "device.h"
4+
#include "msp.h"
45

56
/**
67
* @brief process backpack PTR (pan/tilt/roll) MSP packet from goggles/head tracker.
@@ -35,4 +36,8 @@ void sendCRSFTelemetryToBackpack(const uint8_t *data);
3536
*/
3637
void sendMAVLinkTelemetryToBackpack(const uint8_t *data);
3738

39+
extern bool TxBackpackWiFiReadyToSend;
40+
extern bool VRxBackpackWiFiReadyToSend;
41+
extern bool BackpackTelemReadyToSend;
42+
3843
extern device_t Backpack_device;

src/lib/OTA/OTA.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ bool ICACHE_RAM_ATTR UnpackChannelData8ch(OTA_Packet_s const * const otaPktPtr,
461461
}
462462
#endif
463463

464+
uint8_t OtaAdjustSwitchModeForAirRate(OtaSwitchMode_e eSwitchMode, uint8_t packetSize)
465+
{
466+
// Only the fullres modes have 3 switch modes, so reset the switch mode if outside the
467+
// range for 4ch mode
468+
if (packetSize == OTA4_PACKET_SIZE && eSwitchMode > smHybridOr16ch)
469+
return smWideOr8ch;
470+
return eSwitchMode;
471+
}
472+
464473
bool ICACHE_RAM_ATTR ValidatePacketCrcFull(OTA_Packet_s * const otaPktPtr)
465474
{
466475
uint16_t nonceValidator = (otaPktPtr->std.type == PACKET_TYPE_SYNC) ? 0 : OtaNonce;

src/lib/OTA/OTA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void OtaUpdateCrcInitFromUid();
174174

175175
enum OtaSwitchMode_e { smWideOr8ch = 0, smHybridOr16ch = 1, sm12ch = 2 };
176176
void OtaUpdateSerializers(OtaSwitchMode_e const mode, uint8_t packetSize);
177+
uint8_t OtaAdjustSwitchModeForAirRate(OtaSwitchMode_e eSwitchMode, uint8_t packetSize);
177178
extern OtaSwitchMode_e OtaSwitchModeCurrent;
178179

179180
// CRC

src/lib/SCREEN/menu.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,20 @@
77
#include "logging.h"
88
#include "POWERMGNT.h"
99
#include "handset.h"
10-
#include "OTA.h"
1110
#include "deferred.h"
1211

12+
#include "devBackpack.h"
13+
#include "devVTX.h"
14+
#include "devWIFI.h"
15+
1316
#include "thermal.h"
1417
#define UPDATE_TEMP_TIMEOUT 5000
1518
extern Thermal thermal;
1619

1720
extern FiniteStateMachine state_machine;
1821

19-
extern bool RxWiFiReadyToSend;
20-
extern bool TxBackpackWiFiReadyToSend;
21-
extern bool VRxBackpackWiFiReadyToSend;
22-
extern void VtxTriggerSend();
23-
extern void ResetPower();
24-
extern void setWifiUpdateMode();
25-
extern uint8_t adjustPacketRateForBaud(uint8_t rate);
26-
extern uint8_t adjustSwitchModeForAirRate(OtaSwitchMode_e eSwitchMode, uint8_t packetSize);
27-
2822
extern Display *display;
2923

30-
extern unsigned long rebootTime;
31-
3224
fsm_state_t getInitialState()
3325
{
3426
#if defined(PLATFORM_ESP32)

src/lib/WIFI/devWIFI.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
extern void setButtonColors(uint8_t b1, uint8_t b2);
5252
#endif
5353

54-
extern unsigned long rebootTime;
55-
5654
static char station_ssid[33];
5755
static char station_password[65];
5856

src/lib/WIFI/devWIFI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
#include "device.h"
44

5+
void setWifiUpdateMode();
6+
57
extern device_t WIFI_device;

src/lib/tx-crsf/TXModuleParameters.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#include "deferred.h"
1212
#include "msptypes.h"
1313

14+
#include "devBackpack.h"
15+
#include "devVTX.h"
16+
#include "devWIFI.h"
17+
1418
#define STR_LUA_ALLAUX "AUX1;AUX2;AUX3;AUX4;AUX5;AUX6;AUX7;AUX8;AUX9;AUX10"
1519

1620
#define STR_LUA_ALLAUX_UPDOWN "AUX1" LUASYM_ARROW_UP ";AUX1" LUASYM_ARROW_DN ";AUX2" LUASYM_ARROW_UP ";AUX2" LUASYM_ARROW_DN \
@@ -319,18 +323,6 @@ static stringParameter luaBackpackVersion = {
319323

320324
//---------------------------- BACKPACK ------------------
321325

322-
extern TxConfig config;
323-
extern void VtxTriggerSend();
324-
extern void ResetPower();
325-
extern uint8_t adjustPacketRateForBaud(uint8_t rate);
326-
extern uint8_t adjustSwitchModeForAirRate(OtaSwitchMode_e eSwitchMode, uint8_t packetSize);
327-
extern bool RxWiFiReadyToSend;
328-
extern bool BackpackTelemReadyToSend;
329-
extern bool TxBackpackWiFiReadyToSend;
330-
extern bool VRxBackpackWiFiReadyToSend;
331-
extern unsigned long rebootTime;
332-
extern void setWifiUpdateMode();
333-
334326
void TXModuleEndpoint::supressCriticalErrors()
335327
{
336328
// clear the critical error bits of the warning flags
@@ -647,7 +639,7 @@ void TXModuleEndpoint::SetPacketRateIdx(uint8_t idx, bool forceChange)
647639
return;
648640

649641
const auto newModParams = get_elrs_airRateConfig(actualRate);
650-
uint8_t newSwitchMode = adjustSwitchModeForAirRate((OtaSwitchMode_e)config.GetSwitchMode(), newModParams->PayloadLength);
642+
uint8_t newSwitchMode = OtaAdjustSwitchModeForAirRate((OtaSwitchMode_e)config.GetSwitchMode(), newModParams->PayloadLength);
651643
// Force Gemini when using dual band modes.
652644
uint8_t newAntennaMode = (newModParams->radio_type == RADIO_TYPE_LR1121_LORA_DUAL) ? TX_RADIO_MODE_GEMINI : config.GetAntennaMode();
653645
// If the switch mode is going to change, block the change while connected
@@ -1013,7 +1005,7 @@ void TXModuleEndpoint::registerParameters()
10131005
void TXModuleEndpoint::updateParameters()
10141006
{
10151007
bool isMavlinkMode = config.GetLinkMode() == TX_MAVLINK_MODE;
1016-
uint8_t currentRate = adjustPacketRateForBaud(config.GetRate());
1008+
uint8_t currentRate = ExpressLRS_currAirRate_Modparams->index;
10171009
#if defined(RADIO_LR1121)
10181010
// calculate RFMode from current packet-rate
10191011
switch (get_elrs_airRateConfig(currentRate)->radio_type)

0 commit comments

Comments
 (0)