Skip to content

Commit

Permalink
Merge pull request betaflight#11170 from daleckystepan/flash-save-msp
Browse files Browse the repository at this point in the history
Reorder box_t to save few hundreds of bytes
  • Loading branch information
blckmn committed Jun 28, 2022
2 parents 00cd0e5 + 579e800 commit 959accc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 55 deletions.
106 changes: 53 additions & 53 deletions src/main/msp/msp_box.c
Expand Up @@ -47,59 +47,59 @@

// permanent IDs must uniquely identify BOX meaning, DO NOT REUSE THEM!
static const box_t boxes[CHECKBOX_ITEM_COUNT] = {
{ BOXARM, "ARM", 0 },
{ BOXANGLE, "ANGLE", 1 },
{ BOXHORIZON, "HORIZON", 2 },
// { BOXBARO, "BARO", 3 },
{ BOXANTIGRAVITY, "ANTI GRAVITY", 4 },
{ BOXMAG, "MAG", 5 },
{ BOXHEADFREE, "HEADFREE", 6 },
{ BOXHEADADJ, "HEADADJ", 7 },
{ BOXCAMSTAB, "CAMSTAB", 8 },
// { BOXCAMTRIG, "CAMTRIG", 9 },
// { BOXGPSHOME, "GPS HOME", 10 },
// { BOXGPSHOLD, "GPS HOLD", 11 },
{ BOXPASSTHRU, "PASSTHRU", 12 },
{ BOXBEEPERON, "BEEPER", 13 },
// { BOXLEDMAX, "LEDMAX", 14 }, (removed)
{ BOXLEDLOW, "LEDLOW", 15 },
// { BOXLLIGHTS, "LLIGHTS", 16 }, (removed)
{ BOXCALIB, "CALIB", 17 },
// { BOXGOV, "GOVERNOR", 18 }, (removed)
{ BOXOSD, "OSD DISABLE", 19 },
{ BOXTELEMETRY, "TELEMETRY", 20 },
// { BOXGTUNE, "GTUNE", 21 }, (removed)
// { BOXRANGEFINDER, "RANGEFINDER", 22 }, (removed)
{ BOXSERVO1, "SERVO1", 23 },
{ BOXSERVO2, "SERVO2", 24 },
{ BOXSERVO3, "SERVO3", 25 },
{ BOXBLACKBOX, "BLACKBOX", 26 },
{ BOXFAILSAFE, "FAILSAFE", 27 },
{ BOXAIRMODE, "AIR MODE", 28 },
{ BOX3D, "3D DISABLE / SWITCH", 29},
{ BOXFPVANGLEMIX, "FPV ANGLE MIX", 30},
{ BOXBLACKBOXERASE, "BLACKBOX ERASE (>30s)", 31 },
{ BOXCAMERA1, "CAMERA CONTROL 1", 32},
{ BOXCAMERA2, "CAMERA CONTROL 2", 33},
{ BOXCAMERA3, "CAMERA CONTROL 3", 34 },
{ BOXFLIPOVERAFTERCRASH, "FLIP OVER AFTER CRASH", 35 },
{ BOXPREARM, "PREARM", 36 },
{ BOXBEEPGPSCOUNT, "GPS BEEP SATELLITE COUNT", 37 },
// { BOX3DONASWITCH, "3D ON A SWITCH", 38 }, (removed)
{ BOXVTXPITMODE, "VTX PIT MODE", 39 },
{ BOXUSER1, "USER1", 40 },
{ BOXUSER2, "USER2", 41 },
{ BOXUSER3, "USER3", 42 },
{ BOXUSER4, "USER4", 43 },
{ BOXPIDAUDIO, "PID AUDIO", 44 },
{ BOXPARALYZE, "PARALYZE", 45 },
{ BOXGPSRESCUE, "GPS RESCUE", 46 },
{ BOXACROTRAINER, "ACRO TRAINER", 47 },
{ BOXVTXCONTROLDISABLE, "VTX CONTROL DISABLE", 48},
{ BOXLAUNCHCONTROL, "LAUNCH CONTROL", 49 },
{ BOXMSPOVERRIDE, "MSP OVERRIDE", 50},
{ BOXSTICKCOMMANDDISABLE, "STICK COMMANDS DISABLE", 51},
{ BOXBEEPERMUTE, "BEEPER MUTE", 52},
{ .boxId = BOXARM, .boxName = "ARM", .permanentId = 0 },
{ .boxId = BOXANGLE, .boxName = "ANGLE", .permanentId = 1 },
{ .boxId = BOXHORIZON, .boxName = "HORIZON", .permanentId = 2 },
// { .boxId = BOXBARO, .boxName = "BARO", .permanentId = 3 },
{ .boxId = BOXANTIGRAVITY, .boxName = "ANTI GRAVITY", .permanentId = 4 },
{ .boxId = BOXMAG, .boxName = "MAG", .permanentId = 5 },
{ .boxId = BOXHEADFREE, .boxName = "HEADFREE", .permanentId = 6 },
{ .boxId = BOXHEADADJ, .boxName = "HEADADJ", .permanentId = 7 },
{ .boxId = BOXCAMSTAB, .boxName = "CAMSTAB", .permanentId = 8 },
// { .boxId = BOXCAMTRIG, .boxName = "CAMTRIG", .permanentId = 9 },
// { .boxId = BOXGPSHOME, .boxName = "GPS HOME", .permanentId = 10 },
// { .boxId = BOXGPSHOLD, .boxName = "GPS HOLD", .permanentId = 11 },
{ .boxId = BOXPASSTHRU, .boxName = "PASSTHRU", .permanentId = 12 },
{ .boxId = BOXBEEPERON, .boxName = "BEEPER", .permanentId = 13 },
// { .boxId = BOXLEDMAX, .boxName = "LEDMAX", .permanentId = 14 }, (removed)
{ .boxId = BOXLEDLOW, .boxName = "LEDLOW", .permanentId = 15 },
// { .boxId = BOXLLIGHTS, .boxName = "LLIGHTS", .permanentId = 16 }, (removed)
{ .boxId = BOXCALIB, .boxName = "CALIB", .permanentId = 17 },
// { .boxId = BOXGOV, .boxName = "GOVERNOR", .permanentId = 18 }, (removed)
{ .boxId = BOXOSD, .boxName = "OSD DISABLE", .permanentId = 19 },
{ .boxId = BOXTELEMETRY, .boxName = "TELEMETRY", .permanentId = 20 },
// { .boxId = BOXGTUNE, .boxName = "GTUNE", .permanentId = 21 }, (removed)
// { .boxId = BOXRANGEFINDER, .boxName = "RANGEFINDER", .permanentId = 22 }, (removed)
{ .boxId = BOXSERVO1, .boxName = "SERVO1", .permanentId = 23 },
{ .boxId = BOXSERVO2, .boxName = "SERVO2", .permanentId = 24 },
{ .boxId = BOXSERVO3, .boxName = "SERVO3", .permanentId = 25 },
{ .boxId = BOXBLACKBOX, .boxName = "BLACKBOX", .permanentId = 26 },
{ .boxId = BOXFAILSAFE, .boxName = "FAILSAFE", .permanentId = 27 },
{ .boxId = BOXAIRMODE, .boxName = "AIR MODE", .permanentId = 28 },
{ .boxId = BOX3D, .boxName = "3D DISABLE / SWITCH", .permanentId = 29},
{ .boxId = BOXFPVANGLEMIX, .boxName = "FPV ANGLE MIX", .permanentId = 30},
{ .boxId = BOXBLACKBOXERASE, .boxName = "BLACKBOX ERASE (>30s)", .permanentId = 31 },
{ .boxId = BOXCAMERA1, .boxName = "CAMERA CONTROL 1", .permanentId = 32},
{ .boxId = BOXCAMERA2, .boxName = "CAMERA CONTROL 2", .permanentId = 33},
{ .boxId = BOXCAMERA3, .boxName = "CAMERA CONTROL 3", .permanentId = 34 },
{ .boxId = BOXFLIPOVERAFTERCRASH, .boxName = "FLIP OVER AFTER CRASH", .permanentId = 35 },
{ .boxId = BOXPREARM, .boxName = "PREARM", .permanentId = 36 },
{ .boxId = BOXBEEPGPSCOUNT, .boxName = "GPS BEEP SATELLITE COUNT", .permanentId = 37 },
// { .boxId = BOX3DONASWITCH, .boxName = "3D ON A SWITCH", .permanentId = 38 }, (removed)
{ .boxId = BOXVTXPITMODE, .boxName = "VTX PIT MODE", .permanentId = 39 },
{ .boxId = BOXUSER1, .boxName = "USER1", .permanentId = 40 },
{ .boxId = BOXUSER2, .boxName = "USER2", .permanentId = 41 },
{ .boxId = BOXUSER3, .boxName = "USER3", .permanentId = 42 },
{ .boxId = BOXUSER4, .boxName = "USER4", .permanentId = 43 },
{ .boxId = BOXPIDAUDIO, .boxName = "PID AUDIO", .permanentId = 44 },
{ .boxId = BOXPARALYZE, .boxName = "PARALYZE", .permanentId = 45 },
{ .boxId = BOXGPSRESCUE, .boxName = "GPS RESCUE", .permanentId = 46 },
{ .boxId = BOXACROTRAINER, .boxName = "ACRO TRAINER", .permanentId = 47 },
{ .boxId = BOXVTXCONTROLDISABLE, .boxName = "VTX CONTROL DISABLE", .permanentId = 48},
{ .boxId = BOXLAUNCHCONTROL, .boxName = "LAUNCH CONTROL", .permanentId = 49 },
{ .boxId = BOXMSPOVERRIDE, .boxName = "MSP OVERRIDE", .permanentId = 50},
{ .boxId = BOXSTICKCOMMANDDISABLE, .boxName = "STICK COMMANDS DISABLE", .permanentId = 51},
{ .boxId = BOXBEEPERMUTE, .boxName = "BEEPER MUTE", .permanentId = 52},
};

// mask of enabled IDs, calculated on startup based on enabled features. boxId_e is used as bit index
Expand Down
2 changes: 1 addition & 1 deletion src/main/msp/msp_box.h
Expand Up @@ -23,8 +23,8 @@
#include "fc/rc_modes.h"

typedef struct box_s {
const uint8_t boxId; // see boxId_e
const char *boxName; // GUI-readable box name
const uint8_t boxId; // see boxId_e
const uint8_t permanentId; // permanent ID used to identify BOX. This ID is unique for one function, DO NOT REUSE IT
} box_t;

Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/cli_unittest.cc
Expand Up @@ -235,7 +235,7 @@ size_t getEEPROMStorageSize() {

void setPrintfSerialPort(struct serialPort_s) {}

static const box_t boxes[] = { { 0, "DUMMYBOX", 0 } };
static const box_t boxes[] = { { "DUMMYBOX", 0, 0 } };
const box_t *findBoxByPermanentId(uint8_t) { return &boxes[0]; }
const box_t *findBoxByBoxId(boxId_e) { return &boxes[0]; }

Expand Down

0 comments on commit 959accc

Please sign in to comment.