Skip to content

Commit

Permalink
Elrs: proper buffers sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjjjjjjj committed Jul 25, 2023
1 parent 68f70c8 commit 4dba994
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion radio/src/opentx.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
#endif

#if defined(PCBI6X_ELRS)
#define CTOOL_DATA_SIZE 816
#define CTOOL_DATA_SIZE (460 + 176 + 140 + 4) // 780
#else
#define CTOOL_DATA_SIZE 512 // minimize RAM usage for non PCBI6X_ELRS enabled builds, like DEBUG
#endif
Expand Down
52 changes: 26 additions & 26 deletions radio/src/targets/flysky/tools/elrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ struct FieldFunctions {
void (*display)(FieldProps*, uint8_t, uint8_t);
};

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

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

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

static constexpr uint8_t DEVICES_MAX_COUNT = 4;
static uint8_t *deviceIds = &reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE + FIELDS_SIZE];
//static uint8_t deviceIds[DEVICES_MAX_COUNT];
uint8_t devicesLen = 0;
static uint8_t devicesLen = 0;

static constexpr uint8_t backButtonId = 100;
static constexpr uint8_t otherDevicesId = 101;

#define BTN_NONE 0
#define BTN_REQUESTED 1
#define BTN_ADDED 2
uint8_t otherDevicesState = BTN_NONE;
static uint8_t otherDevicesState = BTN_NONE;

uint8_t deviceId = 0xEE;
uint8_t handsetId = 0xEF;
static uint8_t deviceId = 0xEE;
static uint8_t handsetId = 0xEF;

static constexpr uint8_t DEVICE_NAME_MAX_LEN = 20;
//static uint8_t *deviceName = &reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE + FIELDS_SIZE + DEVICES_MAX_COUNT];
static char deviceName[DEVICE_NAME_MAX_LEN];
uint8_t lineIndex = 1;
uint8_t pageOffset = 0;
uint8_t edit = 0;
static uint8_t lineIndex = 1;
static uint8_t pageOffset = 0;
static uint8_t edit = 0;
static FieldProps * fieldPopup = nullptr;
tmr10ms_t fieldTimeout = 0;
uint8_t fieldId = 1;
uint8_t fieldChunk = 0;
static tmr10ms_t fieldTimeout = 0;
static uint8_t fieldId = 1;
static uint8_t fieldChunk = 0;

static char goodBadPkt[11] = "";
uint8_t elrsFlags = 0;
static uint8_t elrsFlags = 0;
static constexpr uint8_t ELRS_FLAGS_INFO_MAX_LEN = 20;
//static char *elrsFlagsInfo = (char *)&reusableBuffer.cToolData[BUFFER_SIZE + FIELD_DATA_BUFFER_SIZE + FIELDS_SIZE + DEVICES_MAX_COUNT + DEVICE_NAME_MAX_LEN];
static char elrsFlagsInfo[ELRS_FLAGS_INFO_MAX_LEN] = "";
uint8_t expectedFieldsCount = 0;

tmr10ms_t devicesRefreshTimeout = 50;
uint8_t allParamsLoaded = 0;
uint8_t folderAccess = 0; // folder id
int8_t expectedChunks = -1;
uint8_t deviceIsELRS_TX = 0;
tmr10ms_t linkstatTimeout = 100;
uint8_t titleShowWarn = 0;
tmr10ms_t titleShowWarnTimeout = 100;
static uint8_t expectedFieldsCount = 0;

static tmr10ms_t devicesRefreshTimeout = 50;
static uint8_t allParamsLoaded = 0;
static uint8_t folderAccess = 0; // folder id
static int8_t expectedChunks = -1;
static uint8_t deviceIsELRS_TX = 0;
static tmr10ms_t linkstatTimeout = 100;
static uint8_t titleShowWarn = 0;
static tmr10ms_t titleShowWarnTimeout = 100;

static constexpr uint8_t COL2 = 70;
static constexpr uint8_t maxLineIndex = 6;
Expand Down

0 comments on commit 4dba994

Please sign in to comment.