Skip to content

Commit 4dba994

Browse files
committed
Elrs: proper buffers sizes
1 parent 68f70c8 commit 4dba994

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

radio/src/opentx.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
#endif
208208

209209
#if defined(PCBI6X_ELRS)
210-
#define CTOOL_DATA_SIZE 816
210+
#define CTOOL_DATA_SIZE (460 + 176 + 140 + 4) // 780
211211
#else
212212
#define CTOOL_DATA_SIZE 512 // minimize RAM usage for non PCBI6X_ELRS enabled builds, like DEBUG
213213
#endif

radio/src/targets/flysky/tools/elrs.cpp

+26-26
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ struct FieldFunctions {
6666
void (*display)(FieldProps*, uint8_t, uint8_t);
6767
};
6868

69-
static constexpr uint16_t BUFFER_SIZE = 486;
69+
static constexpr uint16_t BUFFER_SIZE = 459 + 1;
7070
static uint8_t *buffer = &reusableBuffer.cToolData[0];
71-
uint16_t bufferOffset = 0;
71+
static uint16_t bufferOffset = 0;
7272

7373
// last 25b are also used for popup messages
7474
static constexpr uint8_t FIELD_DATA_BUFFER_SIZE = 176; // 8 + 56 + 56 + 56
@@ -77,55 +77,55 @@ static uint8_t *fieldData = &reusableBuffer.cToolData[BUFFER_SIZE];
7777
// Reuse tail of fieldData for popup messages
7878
static constexpr uint8_t POPUP_MSG_MAX_LEN = 24; // popup hard limit is 32
7979
static constexpr uint8_t POPUP_MSG_OFFSET = FIELD_DATA_BUFFER_SIZE - POPUP_MSG_MAX_LEN;
80-
uint8_t fieldDataLen = 0;
80+
static uint8_t fieldDataLen = 0;
8181

82-
static constexpr uint8_t FIELDS_MAX_COUNT = 15;
82+
static constexpr uint8_t FIELDS_MAX_COUNT = 14;
8383
static constexpr uint8_t FIELDS_SIZE = FIELDS_MAX_COUNT * sizeof(FieldProps);
8484
static FieldProps *fields = (FieldProps *)&reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE];
85-
uint8_t allocatedFieldsCount = 0;
85+
static uint8_t allocatedFieldsCount = 0;
8686

8787
static constexpr uint8_t DEVICES_MAX_COUNT = 4;
8888
static uint8_t *deviceIds = &reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE + FIELDS_SIZE];
8989
//static uint8_t deviceIds[DEVICES_MAX_COUNT];
90-
uint8_t devicesLen = 0;
90+
static uint8_t devicesLen = 0;
9191

9292
static constexpr uint8_t backButtonId = 100;
9393
static constexpr uint8_t otherDevicesId = 101;
9494

9595
#define BTN_NONE 0
9696
#define BTN_REQUESTED 1
9797
#define BTN_ADDED 2
98-
uint8_t otherDevicesState = BTN_NONE;
98+
static uint8_t otherDevicesState = BTN_NONE;
9999

100-
uint8_t deviceId = 0xEE;
101-
uint8_t handsetId = 0xEF;
100+
static uint8_t deviceId = 0xEE;
101+
static uint8_t handsetId = 0xEF;
102102

103103
static constexpr uint8_t DEVICE_NAME_MAX_LEN = 20;
104104
//static uint8_t *deviceName = &reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE + FIELDS_SIZE + DEVICES_MAX_COUNT];
105105
static char deviceName[DEVICE_NAME_MAX_LEN];
106-
uint8_t lineIndex = 1;
107-
uint8_t pageOffset = 0;
108-
uint8_t edit = 0;
106+
static uint8_t lineIndex = 1;
107+
static uint8_t pageOffset = 0;
108+
static uint8_t edit = 0;
109109
static FieldProps * fieldPopup = nullptr;
110-
tmr10ms_t fieldTimeout = 0;
111-
uint8_t fieldId = 1;
112-
uint8_t fieldChunk = 0;
110+
static tmr10ms_t fieldTimeout = 0;
111+
static uint8_t fieldId = 1;
112+
static uint8_t fieldChunk = 0;
113113

114114
static char goodBadPkt[11] = "";
115-
uint8_t elrsFlags = 0;
115+
static uint8_t elrsFlags = 0;
116116
static constexpr uint8_t ELRS_FLAGS_INFO_MAX_LEN = 20;
117117
//static char *elrsFlagsInfo = (char *)&reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE + FIELDS_SIZE + DEVICES_MAX_COUNT + DEVICE_NAME_MAX_LEN];
118118
static char elrsFlagsInfo[ELRS_FLAGS_INFO_MAX_LEN] = "";
119-
uint8_t expectedFieldsCount = 0;
120-
121-
tmr10ms_t devicesRefreshTimeout = 50;
122-
uint8_t allParamsLoaded = 0;
123-
uint8_t folderAccess = 0; // folder id
124-
int8_t expectedChunks = -1;
125-
uint8_t deviceIsELRS_TX = 0;
126-
tmr10ms_t linkstatTimeout = 100;
127-
uint8_t titleShowWarn = 0;
128-
tmr10ms_t titleShowWarnTimeout = 100;
119+
static uint8_t expectedFieldsCount = 0;
120+
121+
static tmr10ms_t devicesRefreshTimeout = 50;
122+
static uint8_t allParamsLoaded = 0;
123+
static uint8_t folderAccess = 0; // folder id
124+
static int8_t expectedChunks = -1;
125+
static uint8_t deviceIsELRS_TX = 0;
126+
static tmr10ms_t linkstatTimeout = 100;
127+
static uint8_t titleShowWarn = 0;
128+
static tmr10ms_t titleShowWarnTimeout = 100;
129129

130130
static constexpr uint8_t COL2 = 70;
131131
static constexpr uint8_t maxLineIndex = 6;

0 commit comments

Comments
 (0)