diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 485dd6bc9a..cbaa60e33a 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -1612,6 +1612,14 @@ const clivalue_t valueTable[] = { // PG_POSITION { "position_alt_source", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_POSITION_ALT_SOURCE }, PG_POSITION, offsetof(positionConfig_t, altSource) }, + +// PG_MODE_ACTIVATION_CONFIG +#if defined(USE_CUSTOM_BOX_NAMES) + { "box_user_1_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_1_name) }, + { "box_user_2_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_2_name) }, + { "box_user_3_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_3_name) }, + { "box_user_4_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_BOX_USER_NAME_LENGTH, STRING_FLAGS_NONE }, PG_MODE_ACTIVATION_CONFIG, offsetof(modeActivationConfig_t, box_user_4_name) }, +#endif }; const uint16_t valueTableEntryCount = ARRAYLEN(valueTable); diff --git a/src/main/config/config.h b/src/main/config/config.h index e66d262125..7c94486ff7 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -27,8 +27,6 @@ #define MAX_NAME_LENGTH 16u -#define MAX_PROFILE_NAME_LENGTH 8u - typedef enum { CONFIGURATION_STATE_DEFAULTS_BARE = 0, CONFIGURATION_STATE_DEFAULTS_CUSTOM, diff --git a/src/main/fc/rc_modes.c b/src/main/fc/rc_modes.c index 6cc13376ba..49785ce80e 100644 --- a/src/main/fc/rc_modes.c +++ b/src/main/fc/rc_modes.c @@ -54,6 +54,17 @@ static uint8_t activeLinkedMacArray[MAX_MODE_ACTIVATION_CONDITION_COUNT]; PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions, PG_MODE_ACTIVATION_PROFILE, 2); +#if defined(USE_CUSTOM_BOX_NAMES) +PG_REGISTER_WITH_RESET_TEMPLATE(modeActivationConfig_t, modeActivationConfig, PG_MODE_ACTIVATION_CONFIG, 0); + +PG_RESET_TEMPLATE(modeActivationConfig_t, modeActivationConfig, + .box_user_1_name = { 0 }, + .box_user_2_name = { 0 }, + .box_user_3_name = { 0 }, + .box_user_4_name = { 0 }, +); +#endif + bool IS_RC_MODE_ACTIVE(boxId_e boxId) { return bitArrayGet(&rcModeActivationMask, boxId); diff --git a/src/main/fc/rc_modes.h b/src/main/fc/rc_modes.h index 86f6da25d8..0f95fefc85 100644 --- a/src/main/fc/rc_modes.h +++ b/src/main/fc/rc_modes.h @@ -115,6 +115,20 @@ typedef struct modeActivationCondition_s { PG_DECLARE_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions); +#if defined(USE_CUSTOM_BOX_NAMES) + +#define MAX_BOX_USER_NAME_LENGTH 16 + +typedef struct modeActivationConfig_s { + char box_user_1_name[MAX_BOX_USER_NAME_LENGTH]; + char box_user_2_name[MAX_BOX_USER_NAME_LENGTH]; + char box_user_3_name[MAX_BOX_USER_NAME_LENGTH]; + char box_user_4_name[MAX_BOX_USER_NAME_LENGTH]; +} modeActivationConfig_t; + +PG_DECLARE(modeActivationConfig_t, modeActivationConfig); +#endif + typedef struct modeActivationProfile_s { modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT]; } modeActivationProfile_t; diff --git a/src/main/msp/msp_box.c b/src/main/msp/msp_box.c index d49d4a210b..b20a062531 100644 --- a/src/main/msp/msp_box.c +++ b/src/main/msp/msp_box.c @@ -131,7 +131,20 @@ static bool activeBoxIdGet(boxId_e boxId) void serializeBoxNameFn(sbuf_t *dst, const box_t *box) { - sbufWriteString(dst, box->boxName); +#if defined(USE_CUSTOM_BOX_NAMES) + if (box->boxId == BOXUSER1 && strlen(modeActivationConfig()->box_user_1_name) > 0) { + sbufWriteString(dst, modeActivationConfig()->box_user_1_name); + } else if (box->boxId == BOXUSER2 && strlen(modeActivationConfig()->box_user_2_name) > 0) { + sbufWriteString(dst, modeActivationConfig()->box_user_2_name); + } else if (box->boxId == BOXUSER3 && strlen(modeActivationConfig()->box_user_3_name) > 0) { + sbufWriteString(dst, modeActivationConfig()->box_user_3_name); + } else if (box->boxId == BOXUSER4 && strlen(modeActivationConfig()->box_user_4_name) > 0) { + sbufWriteString(dst, modeActivationConfig()->box_user_4_name); + } else +#endif + { + sbufWriteString(dst, box->boxName); + } sbufWriteU8(dst, ';'); } diff --git a/src/main/pg/pg_ids.h b/src/main/pg/pg_ids.h index a5a21c33f8..e683f291bb 100644 --- a/src/main/pg/pg_ids.h +++ b/src/main/pg/pg_ids.h @@ -96,7 +96,7 @@ // betaflight specific parameter group ids start at 500 #define PG_BETAFLIGHT_START 500 -#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 500 +//#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 500 removed #define PG_OSD_CONFIG 501 #define PG_BEEPER_CONFIG 502 #define PG_BEEPER_DEV_CONFIG 503 @@ -149,7 +149,8 @@ #define PG_SDIO_PIN_CONFIG 550 #define PG_PULLUP_CONFIG 551 #define PG_PULLDOWN_CONFIG 552 -#define PG_BETAFLIGHT_END 552 +#define PG_MODE_ACTIVATION_CONFIG 553 +#define PG_BETAFLIGHT_END 553 // OSD configuration (subject to change) diff --git a/src/main/pg/piniobox.c b/src/main/pg/piniobox.c index f7794c3cac..076e8cba7c 100644 --- a/src/main/pg/piniobox.c +++ b/src/main/pg/piniobox.c @@ -34,6 +34,6 @@ PG_REGISTER_WITH_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, PG_PINIOBOX_CONFIG, 1); PG_RESET_TEMPLATE(pinioBoxConfig_t, pinioBoxConfig, - { PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE } + { PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE, PERMANENT_ID_NONE }, ); #endif diff --git a/src/main/target/common_pre.h b/src/main/target/common_pre.h index c3ecd0f795..59c2ee2828 100644 --- a/src/main/target/common_pre.h +++ b/src/main/target/common_pre.h @@ -366,4 +366,5 @@ #define USE_PROFILE_NAMES #define USE_SERIALRX_SRXL2 // Spektrum SRXL2 protocol #define USE_INTERPOLATED_SP +#define USE_CUSTOM_BOX_NAMES #endif